AI Chatbot CLI with advanced sandboxed text and file system interaction
pip install chatty-agent==0.5.4 Copy PIP instructions
An advanced AI Chatbot CLI with a rich terminal interface, sandboxed file system tools, multi-provider LLM support (Ollama, OpenRouter, and custom providers via LiteLLM), syntax verification, dynamic skills, and cost/token optimization.
Chatty provides a local terminal loop that allows an LLM agent to interact with your codebase and system tools in a safe, sandboxed directory. It utilizes rich and prompt_toolkit to deliver a premium user experience, complete with formatting, status indicators, and autocompletion.
pip install chatty-agent Alternatively, install from the local repository directory:
pip install . Developer Mode (Editable Install) To develop or modify the codebase and have changes immediately visible without reinstalling:
pip install -e . CLI Usage & Arguments Once installed, invoke the chatbot using the chatty command or via Python:
chatty [options] # OR python3 -m chatty [options] Full List of CLI Arguments Parameter Short Type Default Description --provider -p string ollama Backend provider to use (e.g., ollama, openrouter, anthropic, chatty, etc.). If omitted and --url is set, resolves automatically to the domain of the URL. --model -m string Auto-resolved Model identifier(s) to load. Can be specified multiple times or as comma-separated values. The first becomes the active model. Ollama: auto-detects first local model (falls back to qwen2.5-coder:7b). OpenRouter: dynamically defaults to the most popular free model (falls back to google/gemini-2.5-flash:free). Custom: required (no fallback). --oracle-model None string None Model identifier to use as the oracle. No default is assumed (the oracle tool is only active if an oracle model is explicitly configured). --context-size -c integer 8192 Target context window length constraint in tokens. --sandbox -s string ./sandbox Path to the sandboxed folder. All writes and runs are jailed inside this directory. If neither Docker nor Landlock is available and --sandbox is specified, Chatty aborts to prevent un-sandboxed execution unless --backend none is passed. --skills-path -k string None Custom directory paths to scan for static/dynamic Skills (can be specified multiple times). --ondemand-skills-path -o string None Custom directory paths to scan for on-demand Skills (can be specified multiple times). --whitelist -w string None Add an out-of-sandbox path to the initial whitelist. Can end with :ro or :rw to set mode (defaults to ro). Can be specified multiple times. --static-skills None flag Auto Load all skills statically into system instructions (defaults to True for OpenRouter, False for Ollama). --prompt-caching None flag False Explicitly enable prompt caching for compatible models (adds cache_control tagging). --max-loops -l integer 20 Maximum sequential tool executions allowed in a single user turn. --config-prompt -f string None Path to a YAML or plain text file containing custom system prompt guidelines. --prompt-mode -d string replace How to apply custom system prompt configuration (replace default prompt, or integrate/append to it). --api-key -a string None Client API Key. Overrides OPENROUTER_API_KEY, CUSTOM_API_KEY, or OPENAI_API_KEY environment variables depending on the provider. --url -u string None Custom Base URL override (required for custom providers; automatically resolves the provider name to the domain of the URL if --provider is not specified). --max-read-chars None integer 40000 Maximum character limit when reading a text file to prevent context explosion. --max-grep-results None integer 100 Limit on matching results returned from the regular expression search tool. --max-command-chars None integer 16000 Maximum characters returned from stdout/stderr of executing commands. --max-history-tool-chars None integer 1000 Token saving limit: compresses old/historical tool output messages to this size. --history-keep-messages None integer 4 Number of recent messages to keep fully raw and uncompressed. --max-url-chars None integer 24000 Limit on fetched website character outputs. --max-dir-items None integer 200 Maximum number of directory items listed by directory explorer tool. --log-file None string chatty.log File path where execution statements are logged. Set to "" to disable. --log-level None string info Logging verbosity (debug, info, warning, error). --headless None flag False Run the chatbot in headless mode (no console printing or terminal interactive loop; implicitly enables --auto-approve). --auto-approve None flag False Automatically approve file changes without interactive diff confirmation prompts. --max-thinking-chars None integer 12000 Maximum internal thinking characters before prompting the user. --max-thinking-leeway-chars None integer 2000 Leeway in characters beyond the maximum before hard-aborting or prompting. --api-delay None float 2.5 Minimum delay in seconds between consecutive API requests. --api-timeout None float 60.0 Timeout in seconds for API requests and streams. --repo-map / --no-repo-map None flag True Include a Tree-Sitter / PageRank repository map in the system prompt. --repo-map-tokens None integer 1024 Target token budget for the repository map. --discovery-model None string Auto-resolved Model identifier for the discovery/scout agent (dynamically selects a fast, low-cost coding model on OpenRouter, a local coder model on Ollama, or falls back to the active model). --discovery-loops None integer 50 Maximum tool execution loops allowed for the discovery agent. --backend -B string auto Execution backend for shell commands: auto (default: Docker if available, else Landlock on Linux, else fails if --sandbox specified), docker (companion container), landlock (Linux Landlock LSM), or none (direct host execution). --docker-image None string chatty-sandbox: Docker image tag to use for the companion container. --dockerfile None string None Path to a custom Dockerfile to build and use for the companion container. --docker-build None flag False Force building or rebuilding the Docker companion image on startup. --docker-reset None flag False Reset (recreate) the Docker companion container for the current workspace. --docker-ephemeral None flag False Run the companion container as ephemeral (destroy on session exit). --docker-host None string None Custom Docker host endpoint (e.g. tcp://127.0.0.1:2375 or unix:///run/user/1000/docker.sock). Overrides DOCKER_HOST. --mcp-config None string None Path to an MCP (Model Context Protocol) JSON configuration file. --mcp / --no-mcp None flag True Enable or disable Model Context Protocol (MCP) server integration. Custom OpenAI-Compatible & Multi-Provider Support Chatty uses LiteLLM under the hood, meaning you can connect to any third-party cloud provider (like Anthropic or Chatty) or any OpenAI-compatible custom endpoint.
To connect to custom endpoints (like DeepSeek, Groq, Together AI, or local vLLM servers), specify --url and --model (along with --api-key if required). The provider name will automatically be resolved to the domain name of your URL:
# Run using DeepSeek V3 (automatically sets provider to 'api.deepseek.com') chatty --url https://api.deepseek.com/v1 --api-key YOUR_DEEPSEEK_KEY --model deepseek-chat # Run using Groq (automatically sets provider to 'api.groq.com') chatty --url https://api.groq.com/openai/v1 --api-key YOUR_GROQ_KEY --model llama-3.3-70b-versatile # Run using Together AI (automatically sets provider to 'api.together.xyz') chatty --url https://api.together.xyz/v1 --api-key YOUR_TOGETHER_KEY --model Qwen/Qwen2.5-Coder-32B-Instruct 2. Native Multi-Provider Support via LiteLLM You can also call other native providers supported by LiteLLM (such as Anthropic or Google Chatty) directly by specifying their provider name and model:
# Run using Anthropic Claude 3.5 Sonnet (expects ANTHROPIC_API_KEY env variable) chatty --provider anthropic --model claude-3-5-sonnet # Run using Google Chatty Pro (expects CHATTY_API_KEY env variable) chatty --provider chatty --model chatty-2.5-pro Interactive Interface & Slash Commands During a session, you can input direct queries to the model, or use Slash Commands to inspect/adjust configurations on the fly:
When using OpenRouter or Ollama, you can discover, inspect, and filter available models:
# List available models /models available [--refresh] # Inspect detailed model specs /models info # Multi-constraint search with AND logic /models search cost =1M ... qwen The /models search command supports combining multiple conditions (all AND-ed together):
Chatty features an integrated Scout Agent Engine powered by a secondary, fast model (--discovery-model) that runs multi-turn investigation loops in an isolated, ephemeral context. This prevents exploratory tool calls, voluminous file dumps, and raw web pages from littering the main conversation history:
Explores the workspace using read-only tools to gather precise context, target files, exact line ranges, symbol definitions, and architectural dependencies before code modifications begin:
Autonomously searches the web, inspects documentation pages and GitHub issues, and extracts verified answers without bloating the main model's context window:
The chatbot uses function-calling to interface with the sandbox workspace. Directly invoking command-line file manipulation programs (e.g. cat, grep, find) in run_command is blocked by safety filters in validate_command_safety. The agent is required to use the appropriate structured tools:
Chatty provides human-in-the-loop review before files are modified on disk (write_file and patch_file):
Chatty natively supports the Model Context Protocol (MCP) standard over stdio, allowing you to connect external tool servers (databases, web scrapers, APIs, custom scripts) directly to Chatty:
Chatty automatically detects MCP server definitions from any of the following standard locations:
The configuration syntax follows the standard mcpServers format:
{ "mcpServers": { "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..." } }, "postgres": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] } } } 2. Automatic Tool Discovery & Execution Dynamic Tool Schema: On session startup, Chatty initializes each server, retrieves its exposed tools, and registers them directly into the LLM's function schema with a server identifier tag ([MCP: server_name]). Conflict-Free Namespacing: If tool names are unique across servers, the LLM can call them directly by name (e.g. get_issue). If multiple servers provide a tool with the same name, Chatty provides namespaced routing (mcp__ __ ). Seamless Execution: When the LLM decides to call an MCP tool, Chatty dispatches the JSON-RPC request to the server process over stdio, collects the resulting text or image content, and feeds it back to the conversation. 3. In-Session Inspection (/mcp) /mcp or /mcp list: Displays a formatted status table of all connected MCP servers, commands, connection health, and registered tools. /mcp reload: Hot-reloads configuration files and restarts MCP server subprocesses without restarting Chatty. --no-mcp: Disable MCP server discovery and execution for lightweight sessions. Scratchpad & Workspace Cleanliness (.chatty/scratch/) Chatty instructs the agent to store all temporary test scripts, one-off execution snippets, scratchpad notes, and intermediate debug files inside .chatty/scratch/ (relative to the sandbox root) to prevent workspace clutter and avoid polluting git status. When exiting Chatty, if any files exist in .chatty/scratch/, the CLI interactively prompts whether you want to clean them up or preserve them.
Chatty implements a layered security approach to execute commands safely, isolate file operations, and protect the host system.
Every command sent to run_command is statically parsed and verified by validate_command_safety. It blocks common shell commands (such as cat, grep, find, cp, mv, rm, ls, etc.) to force the LLM to use structured sandbox API tools rather than arbitrary shell execution.
Additionally, Python script executions (either run inline with python -c or loaded from .py files) are parsed into an Abstract Syntax Tree (AST) to extract their structural signature. If direct filesystem operations (like open, write, os.remove, etc.) are detected, the execution is blocked, and the chatbot prompts the user interactively to allow or deny the script, or whitelist its signature.
Chatty supports multiple execution backends to run commands generated by the LLM:
When the Docker backend is active, Chatty manages the entire lifecycle of an isolated companion container:
chatty --docker-host tcp://127.0.0.1:2375 chatty --docker-host unix:///run/user/1000/docker.sock Tip (Bridging into unprivileged containers or sandboxes with socat): If Chatty is running inside an isolated sandbox or container that shares the host network but does not have /var/run/docker.sock mounted (such as a Bubblewrap sandbox), you can forward the Docker socket to localhost on the host machine:
# Run on host: socat TCP-LISTEN:2375,bind=127.0.0.1,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock & Then connect Chatty from inside the sandbox using:
chatty --docker-host tcp://127.0.0.1:2375 Host Path Translation (HOST_PATH_MAP): When Chatty runs inside an outer container or sandbox namespace (such as Bubblewrap) and connects to a Docker daemon running on the host, volume mount sources must be specified using the host's physical paths rather than sandbox-internal paths. Set the HOST_PATH_MAP (or CHATTY_HOST_PATH_MAP) environment variable to translate prefixes: export HOST_PATH_MAP="/sandbox/path=/host/path:/other/sandbox=/other/host" Multiple mappings can be delimited by colons (:), semicolons (;), or commas (,). Longer and more specific prefixes automatically take precedence over parent paths. Container Lifecycle & Pruning: Ephemeral containers are tagged with chatty.ephemeral=true and pruned automatically on startup, while persistent workspace containers are retained until explicitly reset. 4. Kernel-Level Linux Landlock Sandboxing On Linux (kernel version 5.13+), Chatty provides transparent, compile-on-demand process isolation using the Linux Landlock LSM (Linux Security Module).
When a chatbot session is initialized (see ChatbotSession), Chatty checks if:
If these conditions are met, compile_landlock_binary builds the C-based wrapper helper landlock_exec.c into an executable binary landlock_exec. The binary is cached in the package directory or under the user's cache folder (~/.cache/chatty/) to avoid compilation overhead on subsequent startup.
When executing a shell command via run_command, the execution argument is wrapped using wrap_command_with_landlock, transforming it into:
landlock_exec --ro / --rw --rw -- /bin/sh -c " " The landlock_exec binary interacts with the Linux kernel to apply rules before spawning the target process:
To allow the chatbot to access files or directories outside the sandboxed folder:
chatty -w /usr/include:ro -w /home/user/project Paths default to Read-Only (ro) unless suffixed with :rw (Read-Write). Whitelisted paths are mounted into Docker companion containers or passed to Landlock accordingly. Interactive Whitelisting: If the agent attempts to read or write a file outside the sandbox that is not whitelisted, Chatty will prompt you interactively: [y]es: Allow access for this operation once. [n]o: Deny access. [a]lways: Whitelist the specific file for the rest of the session. [p]arents: Show a menu to select and recursively whitelist a parent directory. Session Management: Use the /whitelist (or /permissions) slash command to inspect or manage whitelisted paths on the fly. Extending Chatty with Skills Skills are modular system prompt extensions and runbooks that give the LLM custom domain knowledge. Under the standard, a skill is structured as a directory containing a required SKILL.md file (for example, see skills/greetings/SKILL.md) and optional helper subfolders:
skills/database_guidelines/ ├── SKILL.md # Required: Main instruction file with YAML frontmatter ├── scripts/ # Optional: Helper scripts and utilities ├── examples/ # Optional: Reference implementations ├── resources/ # Optional: Additional assets or templates └── references/ # Optional: Detailed documentation or manuals SKILL.md Structure The SKILL.md must start with YAML frontmatter containing the name and description fields:
--- name: database-operations description: Instructions for SQL query formatting and schemas. --- Always format queries in uppercase... (Rest of system guidelines) Discovery Locations Chatty automatically discovers skills and plugins by searching recursive and machine-local customization roots:
To conserve LLM context window size, Chatty uses progressive disclosure:
To operate efficiently over long conversations, Chatty implements two main context optimization mechanisms:
Before sending messages to the LLM, the prune_history method limits the total context:
When --prompt-caching is explicitly enabled or when using static skills with OpenRouter, Chatty injects cache_control: {"type": "ephemeral"} metadata parameters:
Chatty records session activity in a log file (default: chatty.log). The logging mechanism (configured in setup_logging) uses the GlogFormatter to output in standard Google logging syntax:
Lyyyymmdd hh:mm:ss.uuuuuu process file:line] message
To disable file logging, run with --log-file "".
Chatty comes with a comprehensive unittest suite located in tests/. You can execute tests from the project root:
pytest # OR python3 -m unittest discover tests Project links Homepage Issues Repository Key dates PyPI data Data sourced directly from PyPI's database. Released: Oct 19, 2026 Latest release 1 maintainer PyPI data Data sourced directly from PyPI's database. davidel License expression Apache-2.0 View SPDX License List
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.




