Skip to main content

Sage - Simplified AI agent definition and deployment via configuration

Project description

Sage Agent

Yes, I shamelessly named it after me ;)

Inspired by the recent sprawl of OpenClaw, PicoBot, ZeroClaw, and whatever else popped up last Tuesday — I decided to write my own. Written from the ground up in Python.

Sage doesn't aspire to be the next Claude Code. Instead, it's intentionally designed to be a clean slate out of the box, so that you can make it more intelligent. No opinions. No bloat. Just a solid foundation you can build on top of.

See also: Sage Evaluator — a companion app for evaluating and benchmarking your agents.

Key Features

Agents

The core unit. Define an agent in a Markdown file with YAML frontmatter — name, model, system prompt — and you're running. No boilerplate classes, no framework ceremony. Just config and go.

---
name: assistant
model: gpt-4o
---
You are a helpful AI assistant.

Subagents & Delegation

Agents can have subagents. When they do, they automatically get a delegate tool — the LLM decides when and how to hand off work. It's orchestration without the orchestration code.

Tools via @tool Decorator

Write a Python function. Decorate it with @tool. Sage auto-generates the JSON schema from your type hints. That's it. No manual schema wrangling.

@tool
def word_count(text: str) -> str:
    """Count the number of words in the given text."""
    return str(len(text.split()))

Built-in tools included — or load them all at once with sage.tools.builtins:

Category Tools
Core shell, file_read, file_write, http_request
Memory memory_store, memory_recall
File ops file_edit, glob_find, grep_search
Git git_status, git_diff, git_commit, git_log, git_checkout, git_pr_create
Web web_fetch, web_search

Skills

Reusable capabilities defined as Markdown files. Drop them in a directory, and agents can load them. Flat files or directory-per-skill — both work. Skills are just knowledge and instructions, cleanly separated from tools.

Orchestration

Four flavors:

  • Pipeline (>>) — chain agents sequentially. Output of one feeds the next.
  • Parallel — run multiple agents concurrently via Orchestrator.run_parallel().
  • Race — first agent to complete wins via Orchestrator.run_race().
  • Autonomous delegation — an orchestrator agent with subagents decides who does what, on its own.

100+ LLM Providers

Powered by litellm. OpenAI, Azure, Anthropic, Ollama, and basically everything else. One model string, any provider.

Provider Model String
OpenAI gpt-4o, gpt-4o-mini
Azure azure/gpt-4o
Anthropic anthropic/claude-sonnet-4-20250514
Ollama ollama/llama3

MCP Support

Connect to MCP servers (stdio or SSE) or expose your tools as an MCP server. Both directions work.

Semantic Memory

SQLite-backed with litellm embeddings. Zero-config persistent recall across sessions. Compaction built in so context doesn't bloat forever.

Permissions

Control what tools can do. Set a default policy (allow, deny, or ask), then add per-tool rules with pattern matching for dangerous operations. Interactive prompts in the TUI when the policy is ask.

Context Management

Token-aware context window management. Automatic compaction when approaching the model's limit, configurable reserve tokens, and optional pruning of large tool outputs.

TUI

A full interactive terminal UI built with Textual. Split-screen layout — chat on the left, live tool-call feed on the right, status bar at the bottom. It's actually nice to use.

sage tui --agent-config AGENTS.md

Protocol-Based Architecture

ProviderProtocol, MemoryProtocol, EmbeddingProtocol — swap out any layer. Don't like the SQLite memory backend? Write your own. Don't want litellm? Implement the protocol. Everything is async-first.

Quick Start

pip install sage-agent
# or
uv tool install sage-agent
export OPENAI_API_KEY=sk-...
sage agent run AGENTS.md --input "What is the capital of France?"

Code API

import asyncio
from sage import Agent

agent = Agent(
    name="assistant",
    model="gpt-4o",
    body="You are a helpful assistant.",
)

result = asyncio.run(agent.run("What is 2 + 2?"))
print(result)

Or load from config:

agent = Agent.from_config("AGENTS.md")
result = asyncio.run(agent.run("Hello"))

Pipelines

pipeline = researcher >> summarizer
result = asyncio.run(pipeline.run("Explain quantum computing"))

Parallel Execution

from sage import Orchestrator

results = asyncio.run(Orchestrator.run_parallel(agents, "Analyze this topic"))

Race Execution

winner = asyncio.run(Orchestrator.run_race(agents, "Solve this problem"))

Autonomous Orchestration

---
name: orchestrator
model: gpt-4o
subagents:
  - research_agent
  - summarize_agent
---
You are an orchestrator. Use the delegate tool to assign tasks to your subagents.
sage agent run orchestrator/AGENTS.md --input "Research and summarize quantum computing"

CLI

sage agent run AGENTS.md --input "Hello" [--stream]   # Run an agent
sage agent validate AGENTS.md                          # Validate config
sage agent list [directory]                            # List agent configs
sage agent orchestrate AGENTS.md --input "text"        # Run subagents in parallel
sage tool list AGENTS.md                               # List available tools
sage init [--name my-agent] [--model gpt-4o]           # Scaffold a new project
sage tui --agent-config AGENTS.md                      # Launch interactive TUI

Configuration Reference

Agent Config (Markdown Frontmatter)

---
name: my-agent
model: gpt-4o
description: "A helpful assistant"   # Display only, NOT sent to model
max_turns: 10

tools:
  - shell
  - file_read
  - file_write
  - file_edit
  - glob_find
  - grep_search
  - http_request
  - memory_store
  - memory_recall
  - git_status
  - git_diff
  - git_commit
  - git_log
  - git_checkout
  - git_pr_create
  - web_fetch
  - web_search
  - sage.tools.builtins              # All built-in tools at once
  - myapp.tools:search               # Your own tools (module:name)

memory:
  backend: sqlite
  path: memory.db
  embedding: text-embedding-3-large
  compaction_threshold: 50

subagents:
  - research_agent                   # Directory containing AGENTS.md
  - config: helper.md                # Reference another .md file
  - name: inline-helper              # Or define inline
    model: gpt-4o-mini

mcp_servers:
  - transport: stdio
    command: npx
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
  - transport: sse
    url: http://localhost:8080/sse

permissions:
  default: ask                       # ask | allow | deny
  rules:
    - tool: shell
      action: ask
      patterns:
        dangerous: '\brm\s+'
      destructive: true

context:
  compaction_threshold: 0.75         # Compact at 75% of context window
  reserve_tokens: 4096
  prune_tool_outputs: true
  tool_output_max_chars: 5000

model_params:
  temperature: 0.7
  max_tokens: 2048
---

You are a helpful AI assistant.

Main Config (TOML)

Sage supports a global TOML config file for defaults and per-agent overrides. It's auto-discovered at ./config.toml or ~/.config/sage/config.toml, or set via SAGE_CONFIG_PATH.

[defaults]
model = "gpt-4o"
max_turns = 15

[agents.my-agent]
model = "gpt-4o-mini"
max_turns = 5

Override priority: main config defaults < per-agent overrides < frontmatter.

Architecture

sage/
  agent.py          # Core Agent class (run loop, delegation)
  config.py         # Markdown frontmatter loading (Pydantic)
  models.py         # Message, ToolCall, ToolSchema, Usage, etc.
  exceptions.py     # SageError, ConfigError, ProviderError, ToolError
  frontmatter.py    # YAML frontmatter parser
  main_config.py    # TOML main config support
  providers/        # ProviderProtocol + LiteLLMProvider
  tools/            # @tool decorator, ToolRegistry, builtins, file/git/web tools
  skills/           # Skill loader (markdown-based reusable capabilities)
  orchestrator/     # Orchestrator (parallel, race) + Pipeline (>>)
  memory/           # MemoryProtocol, SQLiteMemory, embeddings, compaction
  mcp/              # MCPClient + MCPServer
  permissions/      # PermissionProtocol, policy rules, interactive prompts
  context/          # Token-aware context budget and compaction
  git/              # GitSnapshot (snapshot/restore capability)
  cli/              # Click CLI + Textual TUI

Examples

Requirements

  • Python 3.10+
  • See pyproject.toml for full dependency list

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

sage_agent-1.0.0.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

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

sage_agent-1.0.0-py3-none-any.whl (67.3 kB view details)

Uploaded Python 3

File details

Details for the file sage_agent-1.0.0.tar.gz.

File metadata

  • Download URL: sage_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sage_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 25ce227ed0d1202087839b25ea1fc575baa23eee7c237594fce6ad73312f8e82
MD5 1da1b2584a23056802cad0bf22b76639
BLAKE2b-256 3fe69721758a6acf084d22755c28f31e74072462a973c6709084fadba8fef336

See more details on using hashes here.

Provenance

The following attestation bundles were made for sage_agent-1.0.0.tar.gz:

Publisher: release.yml on sagebynature/sage-agent

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

File details

Details for the file sage_agent-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sage_agent-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 67.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sage_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e771131fdc3989a15169f6218c3a68a39a2bca997536faa19b81752493ee93fd
MD5 0eeccbaec9c9125fcb4c230e474d99ec
BLAKE2b-256 4e10262180b4fd101b09e73c08cdce0720980da27be44035c41843bb286b42f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sage_agent-1.0.0-py3-none-any.whl:

Publisher: release.yml on sagebynature/sage-agent

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