Skip to main content

Pythinker โ€” a tiny agent framework with built-in chat channels, memory, MCP, and an OpenAI-compatible API.

Project description

Pythinker

Pythinker

PyPI Downloads Python License

๐Ÿค– Pythinker is an open-source tiny agent framework. It keeps the core agent loop compact and readable while still supporting chat channels, long-term memory, MCP, and practical deployment paths โ€” so you can go from local setup to a long-running personal agent with minimal overhead.

Powered by a tiny, multiplexing agent loop: one Python process listens to Slack, Telegram, Discord, WhatsApp, Matrix, MS Teams, email, a WebSocket WebUI, and an OpenAI-compatible HTTP API โ€” all backed by a single session-scoped memory layer.

What's new in 2.6.0 โ€” New Signal channel (signal-cli HTTP/SSE) with full DM and group support. New DM pairing system: first-time senders receive a one-time code; owner approves via /pairing approve. Channel modules now load lazily (only enabled channels import their SDKs at startup), and the OpenAI-compatible provider client initializes on first use (~700 ms cold-start savings). AnthropicProvider transparently retries long requests via streaming. Shell tool detaches stdin so interactive prompts no longer block turns. See the changelog for details.

๐Ÿ’ก Key Features

  • Tiny agent โ€” a compact readable core. Stable long-running behavior without orchestration sprawl.
  • Channel-agnostic โ€” Slack, Telegram, Discord, WhatsApp, Matrix, MS Teams, email, WebSocket, plus an OpenAI-compatible HTTP API.
  • Full-screen TUI โ€” pythinker-ai tui (alias chat) opens a prompt_toolkit chat with live streaming, slash-command pickers (/model, /provider, /sessions, /theme, /help, /status), fuzzy search, themable chrome (default + monochrome), and Ctrl+C cancellation of in-flight turns.
  • Provider-rich โ€” 25+ LLM providers (Anthropic, OpenAI, Azure OpenAI, OpenAI Codex, GitHub Copilot, Qwen/DashScope, MiniMax, VolcEngine, Moonshot, DeepSeek, StepFun, and more) behind a single interface.
  • Provider hot-reload โ€” edits to model / provider / API key in ~/.pythinker-ai/config.json land at the next turn boundary. No restart of the SDK or gateway. Same-signature snapshots short-circuit; broken configs are logged and swallowed so an in-flight session can't crash on a typo.
  • Headless browser tool (opt-in) โ€” drives Playwright-managed Chromium for JavaScript-rendered pages, click/form flows, screenshots, and DOM snapshots. mode="auto" launches a packaged headless Chromium without Docker; mode="cdp" connects to an external service for hardened deployments. First-use Chromium binary installs lazily, with idle eviction, per-context page caps, SSRF route handling, and turn-boundary hot reload of browser config.
  • Governed-execution runtime (off by default) โ€” opt-in RuntimeConfig wires a PolicyService (allow-lists from agent manifests, per-turn budgets, recursion depth), a ToolEgressGateway chokepoint, an AgentRegistry directory loader, RequestContext + BudgetCounters plumbing, and a pluggable TelemetrySink (loguru / JSONL / composite). When the loader is None and policy is off, the runtime is bit-for-bit identical to the legacy path.
  • Autonomous subagent tracking โ€” spawned subagents are first-class task records with durable output under .pythinker-ai/task-results/. Pick a role at spawn time โ€” coder (full tools), explore (read-only navigation), or plan (planning-only, no write/edit/shell) โ€” and use /tasks, /task-output <task_id>, and /task-stop <task_id> to inspect or stop background work from chat.
  • Memory that learns โ€” a two-phase "Dream" process consolidates long-term memory into MEMORY.md / SOUL.md / USER.md, auto-versioned with pure-Python git.
  • Skills & MCP โ€” bundled skills (GitHub, cron, weather, tmux, summarize, skill-creator, โ€ฆ) plus first-class Model Context Protocol tool access with defensive HTTP probing and provider-safe tool names.
  • Research-grade PDF reports โ€” opt-in make_pdf tool renders structured Markdown to a styled PDF via ReportLab (pip install 'pythinker-ai[reports]').
  • Safer channel ingress โ€” chat/email adapters apply allowFrom before costly side effects like media downloads, attachment extraction, or voice transcription; Matrix also drops replayed pre-startup events.
  • Sandboxed shell โ€” every command is wrapped in a bubblewrap sandbox on Linux; file tools enforce workspace boundaries.
  • Hackable โ€” the Python package is ~58k LOC with zero monolithic orchestration layer. Read it, fork it, extend it.

๐Ÿ“ฆ Install

Pythinker ships native installers for every platform alongside the PyPI wheel. Pick the row that matches your OS โ€” no Python, Node, or uv prerequisite for the native paths.

โœ… Status note (May 2026): native installers are now the canonical path for new installs. The short URLs below always resolve to the latest GitHub Release artifact, verify its .sha256 sidecar, and install pythinker-ai.

Platform One-line install Artifact
๐ŸชŸ Windows irm https://pythinker.com/ai.ps1 | iex PythinkerSetup-<version>.exe
๐ŸŽ / ๐Ÿง macOS / Linux curl -fsSL https://pythinker.com/ai | bash native tarball
๐ŸŽ macOS (Homebrew) brew install mohamed-elkholy95/pythinker/pythinker-ai Homebrew tap
๐Ÿง Linux packages .deb / .rpm from Releases system package
๐Ÿ Python fallback pip install pythinker-ai PyPI

Every artifact ships with a matching .sha256 file โ€” verify before install on any platform with sha256sum, shasum -a 256, or Get-FileHash.

After install, on any OS:

pythinker-ai --version                # confirm install
pythinker-ai onboard                  # interactive setup wizard
pythinker-ai                          # start the interactive CLI

In-app updates โ€” pythinker-ai update queries the GitHub Releases API and re-runs the right installer for your build with SHA-256 verification. Set PYTHINKER_AI_CLI_NO_AUTO_UPDATE=1 to disable the proactive startup check.

๐ŸชŸ Windows โ€” native installer

The short PowerShell installer downloads the latest PythinkerSetup-<version>.exe, verifies its .sha256 sidecar, and runs the Inno Setup installer silently. It installs per-user into %LOCALAPPDATA%\Programs\Pythinker, registers pythinker-ai on your user PATH (HKCU\Environment), broadcasts WM_SETTINGCHANGE so new shells see the change, and does not require UAC.

irm https://pythinker.com/ai.ps1 | iex
pythinker-ai --version

For a pinned version or an IT-managed per-machine install, download the script first and pass flags:

irm https://pythinker.com/ai.ps1 -OutFile install.ps1
powershell -ExecutionPolicy Bypass -File .\install.ps1 -Version 2.7.1
powershell -ExecutionPolicy Bypass -File .\install.ps1 -AllUsers

Manual .exe downloads from Releases still work; verify them with Get-FileHash before running.

Upgrade: pythinker-ai update from inside the running app โ€” it downloads the newest installer, verifies SHA-256, and re-runs it silently (/VERYSILENT /SUPPRESSMSGBOXES /NORESTART).

Uninstall: Apps & Features โ†’ Pythinker โ†’ Uninstall reverts both the files and the PATH edit.

๐Ÿ›ก First-launch SmartScreen warning โ€” until the Authenticode cert is provisioned in CI, the installer ships unsigned and Windows shows "Windows protected your PC." Click More info โ†’ Run anyway. Use the published .sha256 as your integrity check until signing comes online.

๐ŸŽ macOS โ€” Homebrew tap

# 1. Install โ€” always pulls the newest pythinker-ai release on PyPI
brew install mohamed-elkholy95/pythinker/pythinker-ai

# 2. Verify
pythinker-ai --version
which pythinker-ai       # -> /opt/homebrew/bin/pythinker-ai (Apple Silicon)
                         #    or /usr/local/bin/pythinker-ai (Intel)

Works on Apple Silicon and Intel โ€” brew picks the right Python build for you. The formula provisions a clean venv and installs pythinker-ai unpinned, so every fresh brew install resolves the newest release on PyPI; the tap also auto-republishes its url/sha256 block on every Pythinker release so brew info reflects the current version.

Upgrade: brew upgrade pythinker-ai works once the tap has refreshed for the new release. To pick up a PyPI point release immediately (between tap refreshes), brew reinstall pythinker-ai.

Uninstall: brew uninstall pythinker-ai && brew untap mohamed-elkholy95/pythinker.

The tap repo is mohamed-elkholy95/homebrew-pythinker โ€” auto-maintained, do not hand-edit.

๐Ÿง Linux โ€” system packages

Native .deb and .rpm packages for both x86_64 and aarch64 are attached to every GitHub Release.

# Debian / Ubuntu (x86_64)
sudo dpkg -i pythinker-ai_2.7.1_amd64.deb
sudo apt-get install -f       # only if dpkg reports missing deps

# Debian / Ubuntu (ARM64)
sudo dpkg -i pythinker-ai_2.7.1_arm64.deb

# Fedora / RHEL / openSUSE (x86_64)
sudo rpm -i pythinker-ai-2.7.1.x86_64.rpm
# or use the package manager (preferred โ€” handles deps):
sudo dnf install ./pythinker-ai-2.7.1.x86_64.rpm
sudo zypper install ./pythinker-ai-2.7.1.x86_64.rpm

# Fedora / RHEL (aarch64)
sudo rpm -i pythinker-ai-2.7.1.aarch64.rpm

Both packages drop a small /usr/bin/pythinker-ai launcher that execs the real binary under /usr/lib/pythinker/, so your $PATH stays tidy.

Verify before install:

sha256sum -c pythinker-ai_2.7.1_amd64.deb.sha256        # Debian/Ubuntu
sha256sum -c pythinker-ai-2.7.1.x86_64.rpm.sha256       # Fedora/RHEL

Upgrade: download the new .deb/.rpm from Releases and dpkg -i / dnf install over it. Or run pythinker-ai update from inside the running app โ€” it'll fetch the matching new package and prompt for sudo to install.

Uninstall:

sudo dpkg -r pythinker-ai                                # Debian/Ubuntu
sudo rpm -e pythinker-ai                                 # Fedora/RHEL

๐ŸŒ macOS / Linux โ€” curl-bash native installer

For containers, fresh VMs, or any host without a system package manager. The install-native.sh helper detects your OS + arch, downloads the matching PyInstaller-frozen tarball, verifies its SHA-256, and lands the single binary at ~/.local/bin/pythinker-ai.

# Latest release
curl -fsSL https://pythinker.com/ai | bash

# Pin a specific version
curl -fsSL https://pythinker.com/ai | bash -s -- --version 2.7.1

# Custom prefix (defaults to $HOME/.local)
curl -fsSL https://pythinker.com/ai | bash -s -- --prefix /opt/pythinker

Supported targets:

uname -s / -m Tarball asset
Linux / x86_64 pythinker-<version>-x86_64-unknown-linux-gnu.tar.gz
Linux / aarch64 pythinker-<version>-aarch64-unknown-linux-gnu.tar.gz
Darwin / arm64 pythinker-<version>-aarch64-apple-darwin.tar.gz

The script prints PATH guidance if ~/.local/bin isn't already on your $PATH. Intel macOS users โ€” use Homebrew or pip install pythinker-ai; no PyInstaller-built Intel Darwin binary is published.

Uninstall: rm ~/.local/bin/pythinker-ai.

๐Ÿ›  Power-user / legacy install paths

๐Ÿšง Deprecated. These paths still work, but the per-OS native installers above are the canonical install method for all new releases. The legacy options below remain for existing automation; new tooling, examples, and support docs target the native installers exclusively.

Legacy uv / pipx / pip / source paths
# uv (one-off run)
uvx pythinker-ai

# uv tool install (isolated env)
uv tool install pythinker-ai

# pipx (equivalent to uv tool install, slower):
pipx install pythinker-ai

# Plain pip (last resort โ€” you may need to add ~/.local/bin to PATH):
pip install --user pythinker-ai

# From source (contributors only):
git clone git@github.com:mohamed-elkholy95/Pythinker.git
cd Pythinker && uv sync --all-extras

If pythinker-ai isn't found after install, run pythinker-ai doctor (via python -m pythinker doctor if needed) for diagnostics.

The legacy scripts/install.sh and scripts/install.ps1 wrappers print a deprecation banner; set PYTHINKER_AI_INSTALL_QUIET_DEPRECATION=1 to silence it.

3. Optional extras

Pythinker ships with the Python browser automation library needed by the browser tool. Optional extras are for add-on channels and heavier document features:

uv tool install 'pythinker-ai[reports]'   # Markdown โ†’ PDF reports (research/report deliverables)
uv tool install 'pythinker-ai[matrix]'    # Matrix channel (E2E messaging)
uv tool install 'pythinker-ai[discord]'   # Discord channel
uv tool install 'pythinker-ai[msteams]'   # Microsoft Teams channel
uv tool install 'pythinker-ai[pdf]'       # Read PDF files (PyMuPDF)
uv tool install 'pythinker-ai[api]'       # OpenAI-compatible HTTP server
# Combine: uv tool install 'pythinker-ai[reports,discord,api]'

The historical pythinker-ai[browser] extra is still accepted as a compatibility alias, but it no longer adds packages. Enable the browser tool in config with tools.web.browser.enable=true; the managed Chromium binary is installed lazily on first browser use when allowed, or explicitly with python -m playwright install chromium.

4. Install / pin a specific version

pythinker-ai follows SemVer โ€” major-version upgrades are not auto-installed. To pin or to opt into a major bump, use the explicit pin form for your install method:

Goal Command
Pin exactly 2.0.0 (uv tool โ€” recommended) uv tool install --reinstall "pythinker-ai==2.0.0"
Pin exactly 2.0.0 (pipx) pipx install --force "pythinker-ai==2.0.0"
Pin exactly 2.0.0 (plain pip) python -m pip install --force-reinstall "pythinker-ai==2.0.0"
Stay at the latest stable release pythinker-ai upgrade
From inside pythinker, target a specific version pythinker-ai update --target 2.0.0 -y

pip install -U pythinker-ai==2.0.0 works too, but it's semantically noisy: the exact pin controls the version, not -U. pythinker upgrade will refuse to cross a major version (e.g. 1.x โ†’ 2.x) without an explicit pythinker-ai update --target opt-in.

๐Ÿš€ Quick Start

pythinker-ai onboard                           # write a config at ~/.pythinker-ai/config.json
pythinker-ai provider login openai-codex       # OAuth sign-in (the default provider)
pythinker-ai agent                             # interactive CLI chat
pythinker-ai tui                               # full-screen interactive chat (alias: chat)

pythinker-ai onboard ships a config preconfigured for OpenAI Codex via ChatGPT OAuth (no API key needed). To use a different provider/model, edit ~/.pythinker-ai/config.json โ€” see Configuration for the full catalog of 25+ providers.

Want several independent agents on one host? pythinker agents lays out per-agent configs under ~/.pythinker-ai/agents/<name>/ with isolated workspace, history, and memory; pass --agent <name> to any subcommand to target one.

  • Want different LLM providers, web search, MCP, security settings, or more config options? See Configuration.
  • Want to run Pythinker in chat apps like Telegram, Discord, Slack, WhatsApp, or Matrix? See Chat Apps.
  • Want Docker or Linux service deployment? See Deployment.
  • Want governed-execution (policy allow-lists, budgets, telemetry) for hardened deployments? See Architecture ยง5.X โ€” pythinker/runtime/. The layer is opt-in via runtime.policyEnabled in config.json.

๐Ÿง  Agent Runtime Controls

Pythinker can launch subagents for background coding, research, and maintenance work. The runtime now tracks those subagents as autonomous tasks instead of relying on chat text alone.

Command What it does
/tasks List active and recent autonomous tasks for the current session
/task-output <task_id> Show the latest bounded output tail for a task
/task-stop <task_id> Cancel a running subagent by id

Task output is written to .pythinker-ai/task-results/, so large results do not flood the conversation and recovered output can still be inspected after a process restart. In-memory records are session-scoped; restart-recovered orphan output is workspace-wide by design for Pythinker's single-user/local deployment model.

๐Ÿ–ฅ๏ธ TUI

pythinker-ai tui (alias pythinker-ai chat) opens a full-screen prompt_toolkit interface for interactive sessions โ€” a step up from pythinker-ai agent's line-by-line REPL.

pythinker-ai tui                               # opens with the default theme
pythinker-ai tui --theme monochrome            # high-contrast / accessibility-friendly
pythinker-ai tui --workspace ~/work/agent      # override per-session workspace
pythinker-ai tui --logs ~/.pythinker-ai/tui.log   # mirror loguru output to a file

Layout. A persistent chat pane (streamed assistant tokens render live with markdown swap-in once the turn ends), a status bar showing session/model/provider/iteration count, a hint footer for the current keymap, and a multiline editor with slash-command autocomplete.

Slash commands. Open in-app overlays for everything you'd normally configure on the CLI:

Command Opens
/help Built-in cheat sheet
/status Live snapshot โ€” session key, model, provider, message count, recent activity
/sessions Fuzzy-pick from past sessions and resume
/model Fuzzy-pick a model from the active provider
/provider Switch LLM provider
/theme Swap between default and monochrome themes (persisted to cli.tui.theme)
/mcp Show MCP status โ€” configured servers, connected servers, registered tools; /mcp reconnect reloads MCP config and reconnects
/login / /logout OAuth sign-in / sign-out for providers like OpenAI Codex and GitHub Copilot, with in-terminal prompts
/init Generate a tuned AGENTS.md for the current workspace from the bundled template
/clear Clear the chat pane (/clear --hard also wipes session memory)
/exit Quit

Pickers support fuzzy search โ€” start typing to filter, โ†‘/โ†“ to navigate, Enter to commit, Esc to dismiss.

Keymap.

Key Action
Enter Submit message
Ctrl+J Newline inside the editor
Ctrl+C Cancel the in-flight turn (or quit when idle)
Esc Close the active overlay / picker
โ†‘ / โ†“ Move cursor in pickers; PageUp / PageDown for 5-step jumps

Theming. Two themes ship by default. Set cli.tui.theme in ~/.pythinker-ai/config.json or pass --theme. Both themes provide separate prompt_toolkit chrome styles and Rich content styles so the chat panel and the surrounding UI stay visually consistent.

๐Ÿงช WebUI (Development)

[!NOTE] The WebUI development workflow currently requires a source checkout and is not yet shipped together with the official packaged release. See the WebUI README for full WebUI development docs and build steps.

1. Enable the WebSocket channel in ~/.pythinker-ai/config.json

{ "channels": { "websocket": { "enabled": true } } }

2. Start the gateway

pythinker-ai gateway

3. Start the WebUI dev server

cd webui
bun install
bun run dev

๐Ÿ—๏ธ Architecture

Pythinker architecture

๐Ÿค– Pythinker stays tiny by centering everything around a tiny agent loop: messages come in from chat apps, the LLM decides when tools are needed, and memory or skills are pulled in only as context instead of becoming a heavy orchestration layer. That keeps the core path readable and easy to extend, while still letting you add channels, tools, memory, and deployment options without turning the system into a monolith.

See docs/ARCHITECTURE.md for a forensic walkthrough of the runtime.

โœจ Features

๐Ÿ“ˆ 24/7 Real-Time Market Analysis

๐Ÿš€ Full-Stack Software Engineer

๐Ÿ“… Smart Daily Routine Manager

๐Ÿ“š Personal Knowledge Assistant

Discovery โ€ข Insights โ€ข Trends Develop โ€ข Deploy โ€ข Scale Schedule โ€ข Automate โ€ข Organize Learn โ€ข Memory โ€ข Reasoning

๐Ÿ“š Docs

Browse the repo docs for the current GitHub development version.

๐Ÿค Contribute & Roadmap

PRs welcome! The codebase is intentionally small and readable. ๐Ÿค—

Branching Strategy

Branch Purpose
main Stable releases โ€” bug fixes and minor improvements
dev Experimental features โ€” new features and breaking changes

Unsure which branch to target? See CONTRIBUTING.md for details.

Releases โ€” When publishing a new version, keep the README โ€œWhat's newโ€ callout and CHANGELOG.md section in sync with the exact release version.

Roadmap โ€” Pick an item and open a PR!

  • Multi-modal โ€” See and hear (images, voice, video)
  • Long-term memory โ€” Never forget important context
  • Better reasoning โ€” Multi-step planning and reflection
  • More integrations โ€” Calendar and more
  • Self-improvement โ€” Learn from feedback and mistakes

๐Ÿ” Security

Found a vulnerability? Please do not open a public issue. Follow the private disclosure process in SECURITY.md.

๐Ÿ“„ License

Pythinker is released under the MIT License. Third-party components redistributed with the project are listed in THIRD_PARTY_NOTICES.md.

Thanks for visiting โœจ Pythinker!

Visitors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythinker_ai-2.7.1.tar.gz (683.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pythinker_ai-2.7.1-py3-none-any.whl (801.9 kB view details)

Uploaded Python 3

File details

Details for the file pythinker_ai-2.7.1.tar.gz.

File metadata

  • Download URL: pythinker_ai-2.7.1.tar.gz
  • Upload date:
  • Size: 683.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pythinker_ai-2.7.1.tar.gz
Algorithm Hash digest
SHA256 123d282778c60870133ace40926b39c9222d44698273edb659fdab58fb98908a
MD5 e187a8ee790b6279cc8fba47e538ebcb
BLAKE2b-256 66b3eed6a6c2f5bc955d203e4febcf20572f048d51170a40061c8cfac91acfd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythinker_ai-2.7.1.tar.gz:

Publisher: publish.yml on mohamed-elkholy95/Pythinker-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pythinker_ai-2.7.1-py3-none-any.whl.

File metadata

  • Download URL: pythinker_ai-2.7.1-py3-none-any.whl
  • Upload date:
  • Size: 801.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pythinker_ai-2.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd8022d027d7141b860a6496e69344d0ddfe4635bb3e63242da4525edef748ab
MD5 1811418f1a9b279a64d2c671202b3203
BLAKE2b-256 4a5852b316d178dd6bdf84584bfb7016d8cfa43c247ae535970266e1d1932c69

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythinker_ai-2.7.1-py3-none-any.whl:

Publisher: publish.yml on mohamed-elkholy95/Pythinker-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page