Skip to content

Sagent

A coding-agent CLI and strongly-typed Python library -- self-mutating, hot-swapping, multi-provider, with async tool calls and bidirectional recursive spawn.

Install: git clone https://github.com/rekursiv-ai/sagent

Works with Claude Code, Codex, Gemini CLI · 82 GitHub stars

Install

$git clone https://github.com/rekursiv-ai/sagent

Install command taken from the project's README or registry entry. Always review code before running it.

sagent🪄

A coding-agent CLI and strongly-typed Python library -- self-mutating, hot-swapping, multi-provider, with async tool calls and bidirectional recursive spawn.

Tutorial · Concepts · Providers · Tools · CLI · Sessions · Security · Architecture · API · Streaming · Compaction · Slack · Self-hosted · Showcase · Examples

Quick Start

# Mac:
#   # Required for quick install.
#   brew install uv
#   # Optional for improved performance.
#   brew install ripgrep fd

# Ubuntu/Debian:
#   # Required for quick install.
#   sudo apt-get install -y curl
#   curl -LsSf https://astral.sh/uv/install.sh | sh
#   # Optional for improved performance.
#   sudo apt-get install -y ripgrep fd-find

uv tool install sagent

sagent

Better CLI

Things Claude Code, Codex CLI, and Gemini CLI don't do:

  • Async REPL. Chat with agents about jobs while those jobs run. No ctrl+b, no manual juggling.
  • Hot self-mutation. Switch provider, model, or thinking effort mid-session in plain English. No restart.
  • One CLI, every provider. Anthropic, OpenAI, Google, Moonshot, DashScope, MiniMax, OpenAI-compatible endpoints, self-hosted HuggingFace models, and a managed llama.cpp server, all behind one binary.
  • Unified cost tracking. One USD total across every provider in a session; sub-agent costs roll up to the root. --max-budget-usd N caps the whole tree.
  • Self-directing agent fleets. Agents retune their own runtime -- provider, model, thinking, context -- mid-task. A coordinator can do it to its workers over AgentSend: "switch to o1, crank thinking, recompact and drop the file reads."
  • Recursive agent messaging. Any spawned agent can spawn and AgentSend to any peer, so coordination is a tree, not a star. Claude Code's experimental Agent Teams is flat (one lead, no nesting); Codex and Gemini have no peer messaging.
  • Interruptible, detachable tasks. Tell a stuck task to stop, or detach one and let it keep running.
  • Richer built-in tools. PaperSearch/PaperFetch walk citation graphs and fetch PDFs, multi-backend WebSearch, WebFetch with markdown extraction, atomic read/write tracking on file tools.
  • Unix-aligned and pipeable. stdin, stdout, exit codes, and --output-format json are first-class. Pipe through jq, drop into ipython (same prompt_toolkit underneath).

Uniquely also an API

  • One runtime, every surface. The same Agent class powers the CLI, your application code, and recursive sub-agents.
  • Typed Python objects. Agent, Tool, Model, Provider, and Message are protocols and dataclasses you import, compose, and unit-test.
  • Peer-to-peer agent messaging. Any spawned agent can AgentSend to any other named peer -- not just its parent. Like user input, peer messages preempt the receiving agent's tool calls, so no agent blocks waiting on a stuck child.

Use it as a library:

from sagent import tools
from sagent.agent import Agent
from sagent.lib.codec import immutable
from sagent.providers import Google

agent = Agent(
    model=Google.from_env().model("gemini-pro-3.1"),
    system="You are a scientist.",
    tools=[tools.Read(), tools.Glob(), tools.Grep()],
)
result = await agent.run(immutable({"prompt": "analyze the CSV in ./data/"}))
print(result.content)

Install

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

PluginDev tools+6,803 this week

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…

Explore related