OpenCrabs

repository·main·Indexed 21 days ago

https://github.com/adolfousier/opencrabs

A high-performance, privacy-focused autonomous AI agent delivered as a single Rust binary. OpenCrabs runs locally, managing its own memory, tools, and brain files while communicating directly with LLM providers like Anthropic, OpenAI, and GitHub Copilot. It features a zero-telemetry architecture, a three-tier memory system, multi-agent orchestration, and multimodal support for images, video, and PDFs. It also includes integrated STT/TTS capabilities and a real-time usage dashboard for monitoring token consumption and costs.

Tokens
101K
Snippets
226
Records
468
Agent score
74%

What's inside opencrabs

  1. Overview of OpenCrabs

    main
    OpenCrabs is an autonomous, self-improving AI agent delivered as a single Rust binary. It is designed to run locally on your terminal without requiring a server, gateway, or complex infrastructure. It makes direct HTTPS calls to LLM providers (like Anthropic, OpenAI, or GitHub Copilot) from your machine, ensuring that your data, tools, and memory stay local.
  2. Overview of OpenCrabs Built-in Tools

    main

    OpenCrabs provides over 40 built-in tools that the AI agent can use during a conversation. These tools are categorized into several functional groups:

    • File & Code: Tools for reading, writing, and editing files (including hashline_edit for precise, hash-anchored editing), executing shell commands via bash, and parsing various document formats.
    • Search & Web: Tools for web searching (web_search, exa_search, brave_search), making HTTP requests, and native URL-to-markdown scraping via web_scrape.
    • Image & Video: Tools for generating images (generate_image), analyzing images via vision models, and analyzing video files via multimodal APIs.
    • Channel Tools: Tools for interacting with communication platforms like Telegram, Discord, Slack, and Trello, including searching message history.
    • Agent & System: Tools for managing the agent's own lifecycle, such as plan (for structured work), config_manager, cron_manage (scheduling), and evolve (self-updating).
    • Browser Automation: A suite of tools for controlling Chromium-based browsers (Chrome, Brave, Edge, etc.) to navigate, click, type, and screenshot web pages.
  3. Supported media and file types by channel

    main

    OpenCrabs automatically processes incoming files, images, and documents across various channels.

    • Images: Passed to the active model's vision pipeline or the analyze_image tool (Google Gemini vision).
    • Text Files: .txt, .md, .json, .csv, and source code are extracted as UTF-8 and included inline (up to 8,000 characters). In the TUI, users can paste or type the file path.
    • Videos: Files like mp4, m4v, mov, webm, mkv, avi, 3gp, and flv are routed to analyze_video if image.vision.enabled = true and a Gemini API key is provided.

    Channel Capabilities Matrix:

    ChannelImagesText FilesDocumentsAudio (In)Audio (Out)Image Gen
    TelegramVisionInline/ PDFSTTTTS (send_voice)Native
    WhatsAppVisionInline/ PDFSTTTTS (audio_message)Native
    DiscordVisionInline/ PDFSTTTTS (response.ogg)Attachment
    SlackVisionInline/ PDFSTTTTS (Upload)Upload
    TrelloVisionInlineAttachment
    TUIPath $\to$ VisionPath $\to$ InlineSTT[IMG: name]
  4. Understand the OpenCrabs System Architecture

    main

    OpenCrabs is an agentic system composed of several interacting layers designed for autonomy, self-healing, and recursive improvement.

    Key components include:

    • AgentService: The core engine managing the tool loop, sub-agents, and provider interactions.
    • Self Healing Engine: Monitors context management, detects errors (like phantom tools or gaslighting), and manages provider recovery.
    • RSI (Recursive Self Improvement) Engine: Analyzes a feedback ledger to identify opportunities for improvement and updates system 'Brain Files'.
    • Provider System: A fallback-capable layer that manages multiple LLM providers (Anthropic, Qwen, Gemini, OpenAI, etc.) and handles rate limits via a fallback chain.
    • Data Layer: Uses SQLite for structured data (sessions, messages, feedback) and a Memory Store (Vector Embeddings + FTS5) for semantic retrieval.
    • Channel Manager: Integrates with external platforms like Telegram, Discord, Slack, WhatsApp, and Trello.
    • A2A Protocol: An Axum-based HTTP server allowing remote agents to communicate via JSON RPC (methods: message send, tasks get, tasks cancel).
  5. Telegram Plan Mode UI Behavior and Constraints

    main

    The Telegram interface for Plan Mode follows specific UI patterns to maintain a smooth user experience during the 1.5s edit loop:

    • Flow Message Integration: Plan sections (title, checklist progress, goals) are part of the single live flow message (open_group_msg_id).
    • Refresh Policy: The system uses a 1.5s refresh_flow loop to update the live duration and activity. Because Telegram clients may reset the 'expand/collapse' state of a message upon every edit, the UI is designed to keep critical information (plan title, checklist progress like 2/7, and active goal one-liner) in the always-visible chrome (header or summary).
    • Expandable Content: Full plan prose, detailed checklist lines, and goal criteria are kept in expandable bodies that may re-collapse during duration ticks.
    • Keyboard Availability: Plan-related keyboards (Approve/Discard) only attach to the flow message after plan init has succeeded. During the 'Editing' phase, Approve and Discard appear on the latest flow message, but Approve is refused if a turn is currently running.
  6. How OpenCrabs manages memory and auto-saves

    main

    OpenCrabs uses a structured memory system located in ~/.opencrabs/memory/ to maintain context across sessions. It distinguishes between daily logs and long-term distilled knowledge.

    Daily Memory (memory/YYYY-MM-DD.md)

    Automatically triggered by:

    • New integrations or server/infrastructure changes.
    • Bug discoveries (symptoms + fixes).
    • New tool installations or credential rotations.
    • Architectural decisions.
    • User instructions to "remember this".
    • Debugging sessions lasting >5 minutes.

    Long-term Memory (MEMORY.md)

    Updated when high-level information changes:

    • New integrations go live.
    • New troubleshooting patterns or lessons learned are discovered.
    • User or company information changes.
    • Security policies change.

    Memory Rules

    • Write BEFORE responding: Append to memory first, then reply to the user to ensure context is never lost.
    • No permission needed: Write to memory as events occur; do not wait until the end of a session.
    • Format: Use one-liner rules rather than paragraphs (e.g., - NEVER push without explicit approval).
    • Exclusions: Do NOT store commit hashes, file lists, release notes, architecture docs, or sensitive data (credentials/tokens).
  7. Orchestrate Multi-Agent Tasks

    main

    You can spawn typed child agents to execute tasks in parallel. Available agent types include General, Explore, Plan, Code, and Research. Each type has a specific system prompt and a filtered set of tools.

    Agent Control Tools:

    • spawn_agent: Create a new child agent.
    • wait_agent: Wait for an agent to complete.
    • send_input: Provide input to an agent.
    • close_agent: Terminate an agent session.
    • resume_agent: Resume a paused agent.

    Child agents run in isolated sessions with auto-approval and do not support recursive spawning.

  8. Manage 3-Tier Memory Systems

    main

    OpenCrabs uses a three-tier memory architecture to maintain context and long-term knowledge:

    1. Brain (MEMORY.md): User-curated durable memory loaded on demand into the main session.
    2. Daily Logs: Automatic compaction summaries stored at ~/.opencrabs/memory/YYYY-MM-DD.md.
    3. Hybrid Memory Search: Combines FTS5 keyword search with vector embeddings using Reciprocal Rank Fusion.

    Memory Search Modes:

    • Local: Uses embeddinggemma-300M (768-dim). Works offline with no API key. Automatically disabled in VPS environments.
    • API: Uses any OpenAI-compatible /v1/embeddings endpoint (e.g., OpenAI, Ollama, Jina).
    • FTS5-only: Keyword search only; no embeddings. Ideal for VPS with low RAM overhead.
  9. Use OpenCrabs Long-Term Memory (MEMORY.md)

    main

    The MEMORY.md file serves as the dedicated storage for an agent's long-term memory. It is used to store user-specific facts, corrections, preferences, and lessons learned during interactions to prevent repeated mistakes.

    Key Distinctions:

    • What to include: User preferences, specific corrections, and unique facts about the user or their environment.
    • What NOT to include: Git-loggable data (like commit logs or release notes) or generic agent personality/behavioral instructions (which belong in SOUL.md).

    Structure of the Memory File:

    • Rules & Preferences: A list of one-liner rules or behavioral constraints learned from the user.
    • Integrations: A registry of connected services, data locations, and relevant contacts.
    • Project Context: Specific technical context and references related to the user's current projects.
  10. Use the offline and live evaluation harness

    main

    The evaluation harness (src/eval/) is used to measure context engineering and memory recall quality. It is gated behind the eval feature and cfg(test).

    Offline Evaluation: Uses a fixture replay provider to drive the agent loop from scripted responses without network access. It checks context manifests, compaction fidelity, and recall metrics (precision@k, recall@k, etc.).

    Live Evaluation: Uses a chain of providers to act as a majority-vote judge panel. You can configure this in your configuration file:

    [agent]
    # Ordered chain of provider names; each judge uses that provider's own default_model.
    eval_providers = ["anthropic", "openrouter", "zhipu"]
    [agent]
    eval_providers = ["anthropic", "openrouter", "zhipu"]
  11. Use the Plan Mode Umbrella Plan as the Source of Truth

    main

    When implementing Plan Mode, the Umbrella Plan (src/docs/reference/plans/plan-mode/umbrella.md) is the Single Source of Truth (SSOT) for the full product narrative and locked decisions.

    While individual ADRs (Clusters A-D) serve as execution slices, if a product question or lifecycle edge case conflicts between an ADR and the Umbrella Plan, always trust the Umbrella Plan.