CrabAgent - AI Agent Platform with dual-mode (CLI + Serve)
Project description
๐ฆ CrabAgent
AI Team Command Center โ Build a team of specialized AI agents that learn and improve over time. Delegate, parallelize, and watch them work in real-time from terminal or browser.
CrabAgent is a local-first AI agent platform. Run it from any project directory via CLI or browser. Your data stays local, your API keys are encrypted, and you pick any LLM provider.
Why CrabAgent
Unlike other agent platforms where agents are "temporary workers who forget everything," CrabAgent's agents learn and evolve:
| Capability | What it means |
|---|---|
| ๐ง Self-Evolving Agents | Agents auto-extract lessons from every task โ rule engine catches patterns, LLM reflection analyzes strategies. The more you use them, the smarter they get. |
| ๐ค AI Team | Custom agent profiles with per-agent tool whitelists and model overrides. Delegate, parallelize, or run multi-step pipelines. |
| ๐ Agent Growth Tracking | View each agent's stats: task count, success rate, lessons learned, common task categories. ctrl+space agent_stats |
| โฑ Scheduled + Real-time | Agents run on cron schedules or react to @mentions. Real-time streaming of every agent's output. |
| ๐ฆ Snapshots | Auto-snapshot files before changes. Roll back anytime without Git. |
| ๐ Local-first | All data stays on your machine. API keys encrypted at rest. No telemetry. |
Quick Start
pip install 'crabagent[serve]'
crabagent init
# TUI โ interactive REPL with slash commands
crabagent
# TUI (legacy single-panel)
crabagent --old
# Web UI
crabagent --serve # โ http://localhost:5210
# Default login: admin / xcl1989
# Single-query CLI
crabagent "organize this directory"
crabagent -p deepseek -m deepseek-chat "write a Python script"
Self-Evolving Agents
This is CrabAgent's core differentiator. Agents don't just execute tasks โ they learn from every execution.
How it works
Sub-agent completes task
โ
โโ Rule Engine (instant)
โ โโ High iterations (>80% max) โ "Decompose complex tasks, use fewer tools per step"
โ
โโ LLM Reflection (~1-3s)
โโ Extracts concrete, actionable insights:
โ "When searching Chinese news, use English keywords on DuckDuckGo for better results"
โ "For error-prone sites, prefer web_scrape with direct URLs over web_search"
โโ Auto-filters generic/noise responses ("completed in X steps")
โโ Also learns from failures: captures what went wrong and how to avoid it
โโ Source: llm
Knowledge persistence
- Team Knowledge: Tech stack, architecture decisions, user preferences โ auto-injected into every session
- Agent Lessons: Per-agent concrete insights grouped by category (Pitfalls / What Worked) โ loaded before similar tasks
- Task Records: Every execution logged (success, elapsed time, tokens, iterations)
Tracking growth
# TUI
/agent_stats coder
# โ ๆปไปปๅก: 23 ๆๅ็: 91% ๅนณๅ่ๆถ: 14s
# โ lessons: 18 (่งๅ: 3, LLM: 15)
# Web UI
# โ Agent Team โ Learning Stats: click agent name to see stats + all lessons
---
## AI Team
### Built-in agents
| Agent | Role | Best For |
|-------|------|----------|
| ๐ Researcher | Web research | Search, browse, data collection |
| ๐ Analyst | Data analysis | Comparison, pattern detection, reports |
| ๐ป Coder | Code expert | Write, review, debug, refactor |
| ๐ Writer | Content writer | Write, edit, translate, format |
### Delegation
- `@researcher find competitor pricing` โ @mention auto-delegates
- Click an agent from the toolbar to insert a mention
- `/delegate` command for interactive agent selection
- `delegate_parallel` runs multiple agents simultaneously
- `run_pipeline` chains agents with dependencies
### Session Agent Switching
Switch your current agent identity mid-session without losing conversation history:
```bash
# TUI
/agent # Popup menu: select from 5 agents
/agent researcher # Direct switch
/agent default # Back to all tools
# Web API
POST /api/sessions/{id}/agent {"agent": "researcher"}
- Each agent has different tool sets (researcher gets web tools, coder gets bash+edit, etc.)
- System prompt stays unchanged โ LLM KV cache preserved across switches
- All messages are tagged with agent info for history tracking
- Model auto-switches if the agent profile specifies one
- Status bar shows current agent:
[deepseek/chat โ researcher] Msgs:5 Tok:1234
Real-time monitoring
- ๐ฃ Running โ live step count and timer
- ๐ข Done โ elapsed time, tokens, iterations
- ๐ด Error โ error summary
- Web: right-side Task Board with split-pane result comparison
More Features
๐ผ๏ธ Multimodal
Paste, upload, or drag images. Auto-detects vision models.
๐ Browser Automation
pip install 'crabagent[browser]' + playwright install chromium
> Open https://news.ycombinator.com and show top 5 stories
> Search "Python async" on Google
๐ MCP Client
Connect external MCP servers (stdio + HTTP). Tools auto-discover.
๐ Scheduled Tasks
> Remind me every day at 11:00 to drink water
> Check product page every 30 minutes, notify if price drops
๐ฆ Snapshots
Auto-snapshot before file changes. Roll back with /molt rollback <id>.
๐ง Custom Plugins
Drop a .py file in .crabagent/tools/:
name = "hello"
description = "Say hello"
parameters = {"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}
requires_permission = False
def run(name: str) -> str:
return f"Hello, {name}!"
Or let agents create tools themselves โ Your agent can write and register custom tools during a session. Tell it what you need and it will generate, validate, and save the tool:
> Create a tool that parses CSV files and extracts a column
> Create a tool to fetch weather for a city
Tools are saved to .crabagent/tools/, auto-registered, and persist across sessions. The agent remembers its created tools via team memory.
CLI / TUI Commands
| Command | Description |
|---|---|
/exit, /quit |
Exit |
/help |
Show help |
/clear |
Clear context |
/model [name] |
Switch model |
/models |
List models |
/provider [cmd] |
Manage providers |
/sessions / /session [id] |
List / load sessions |
/new |
New conversation |
/agents [cmd] |
Agent team management |
/agent [name] |
Switch current agent |
/agent_stats <name> |
Agent growth stats |
/delegate [@agent] [task] |
Delegate task |
/memory [list|search|clear] |
Team memory |
/skills / /skill <name> |
List / show skills |
/molt [cmd] |
Snapshots |
/todo [cmd] |
Task list |
/export |
Export to Markdown |
/image <path> [msg] |
Send image |
/runs [agent] |
View agent run history |
/abort |
Abort current agent (Ctrl+C) |
Configuration
| Variable | Default | Description |
|---|---|---|
CRAB_DB_URL |
sqlite+aiosqlite:///./crabagent.db |
Database URL |
CRAB_JWT_SECRET |
Auto-generated | JWT signing key |
CRAB_SERVE_HOST |
0.0.0.0 |
Serve host |
CRAB_SERVE_PORT |
5210 |
Serve port |
CRAB_MAX_ITERATIONS |
50 |
Max agent iterations |
CRAB_MAX_TOKENS |
4096 |
Max response tokens |
CRAB_BROWSER_HEADLESS |
true |
Browser headless mode |
CRAB_WEB_PROXY |
(empty) | HTTP proxy for web_search & web_scrape |
v0.8.0 Highlights
- ๐จ Complete Web UI Redesign โ Brand-new CrabAgent ocean-teal design system with full light/dark theme support (auto-detects system preference). Every component rebuilt on a token-based design foundation โ no more hardcoded hex values.
- ๐ Light + Dark Theme โ Toggle between warm-cream light and warm-dark themes via the navbar. Persisted in
localStoragewithprefers-color-schemefallback. Every component theme-aware, including charts. - ๐งฉ Reusable UI Library โ New
components/ui/library: Button, Input, Modal, ConfirmDialog, Toast (sonner), Tooltip (Radix), EmptyState, LoadingState, Skeleton, CodeBlock with copy + syntax highlighting. All components use design tokens. - ๐ Theme-Aware Charts โ AgentGrowthChart now uses
useThemeColors()hook for recharts SVG strokes. Colors automatically follow the active theme. - ๐ฑ Mobile Responsive โ SessionList becomes a slide-in drawer on
<mdviewports. Hamburger menu button in the ChatPage toolbar (mobile only). Esc-to-close and tap-overlay-to-close. - ๐ AgentsPage: Modal โ Inline Page โ Agent Team panel is now a dedicated inline page at
/agents(was a modal overlay). Better information density. ChatPage still uses modal mode for quick access. - ๐ฆ Bundle Optimization โ Vite
manualChunkssplits vendor code into 4 chunks (react / charts / markdown / ui). Largest single chunk: 380 kB (was 1.22 MB monolith). - ๐ฏ Dashboard Refactor โ DashboardPage replaces 44 inline styles and
AGENT_THEMEhardcoded hex gradients with theme-awareagentColor()helper +--agent-*CSS vars. Lucide icons replace ASCII glyphs. Empty state for "no pipelines". - ๐ Small Component Cleanup โ TodoWidget, McpStatusBar, FileBrowser, TaskBoard all refactored to use design tokens and Lucide icons.
v0.7.4 Highlights
- ๐ Session Agent Switching โ Switch agent identity mid-session with
/agent(TUI) orPOST /api/sessions/{id}/agent(API). Each agent has different tool sets, and messages are tagged with agent info for history tracking. - ๐ ๏ธ Agent-Created Custom Tools โ Agents can now write and register their own reusable tools via
create_tool/update_tool/delete_tool. Code is validated, saved to.crabagent/tools/, registered immediately, and auto-loads across sessions. - ๐ TUI Queue & History Fixes โ Fixed race condition where queued inputs were sent before previous rendering completed. Fixed message ordering in DB when loading sessions with queued messages via persistence flush improvements.
- ๐ค TUI CJK & Thinking Fixes โ Fixed CJK character rendering freeze in dual-panel TUI. Fixed thinking text display bugs (off-by-one, cache miss on content update, prefix loss on flush).
v0.7.2 Highlights
- ๐ฅ๏ธ Dual-Panel TUI โ New prompt_toolkit-based full-screen TUI: scrollable output panel (mouse wheel + PageUp/Down/Home/End), persistent input area that auto-grows with content, and real-time status bar. Default mode (
crabagent), use--oldfor legacy TUI. - ๐ฑ๏ธ Mouse Text Selection โ Hold Shift + mouse drag to select text in the output area. Ctrl+C copies to clipboard (macOS pbcopy / Linux xclip).
- ๐ฌ Interactive Popup Menus โ
/model,/sessions,/providernow show scrolling selection popups with arrow key navigation, instead of printing long lists. - ๐ง Streaming Thinking โ Agent reasoning (
THINKING_DELTA) streams in real-time to the output panel, dim italic style. - ๐ก Completions Menu โ Slash command autocomplete appears as a floating completions menu above the input area.
v0.7.1 Highlights
- ๐ Pipeline Dashboard โ Real-time pipeline visualization: see active pipelines with step progress, agent cards with running counts, and growth charts. History pipelines auto-collapsed.
- ๐ AgentRun Persistence โ New
agent_runstable tracks every agent/pipeline execution with full metadata (tool calls, elapsed time, tokens, iterations). API endpoints for run history and per-agent growth stats. - ๐ Streaming Fix โ
TEXT_DELTAandTHINKING_DELTAevents are no longer throttled/dropped by SSE forwarder.TEXT_DONEhandler now uses full text from backend to ensure complete message display. - ๐ Tool Display Fix โ
delegate_parallelarguments with nested objects no longer show[object Object]in the UI. - ๐ก RunRecorder โ EventBus subscriber that creates
agent_runsrecords for pipeline, main, and sub-agent executions in real-time.
v0.7.0 Highlights
- ๐ง Learning quality overhaul โ LLM reflection now extracts actionable insights (tool tricks, pitfalls, domain tips), no more "completed in X steps" noise. Failure learning added โ agents learn from mistakes too.
- ๐ Web proxy support โ
CRAB_WEB_PROXY=http://127.0.0.1:7890for web_search/web_scrape (critical for users behind firewalls). - ๐ Learning Dashboard โ View each agent's task stats and past lessons directly in the Web UI Agent Team panel.
- ๐ก Sub-agent persistence โ Completed sub-agents stay visible in the Dashboard for 30 minutes after finishing.
Installation
pip install 'crabagent[serve]' # Web UI + API
pip install 'crabagent[browser]' # Browser automation
pip install 'crabagent[dev]' # Testing + linting
# Development
make install # Build frontend + install (editable)
ruff check src/ tests/ # Lint
ruff format src/ tests/ # Format
pytest # Run tests
Project Structure
CrabAgent/
โโโ src/crabagent/
โ โโโ cli/ # CLI entrypoint + TUI
โ โโโ core/agent/ # Agent loop, tools, compression, agents
โ โโโ core/mcp/ # MCP client manager
โ โโโ serve/ # FastAPI + API + scheduler
โโโ frontend/ # React SPA
โโโ crabagent.db # SQLite database
License
GNU Affero General Public License v3 (AGPLv3) for non-commercial use. Commercial use requires a separate license. Contact the author.
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crabagent-0.8.0.tar.gz.
File metadata
- Download URL: crabagent-0.8.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a10690d8c53528f76daf6275170eb3c80bf7ebacd218825b4b1a8321a4f95af2
|
|
| MD5 |
3a1389a02e3298b73c443b2bb494dbc1
|
|
| BLAKE2b-256 |
89db624877d7ff7ea8b7c941a862bba4df24679b12bfad6f2c96e18120ad93bb
|
File details
Details for the file crabagent-0.8.0-py3-none-any.whl.
File metadata
- Download URL: crabagent-0.8.0-py3-none-any.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7f3079491c1dd96b12df33ada8aec60cd434fb900d77a9dcedaec5a9010d6e1
|
|
| MD5 |
ff10c77a538a42f631a4e102919eb342
|
|
| BLAKE2b-256 |
439e0483252bc3408ff031d6837e69312eab2bc70bea0acd2cc262dcba8ebc95
|