Self-learning local code agent runtime
Project description
sagex
Self-learning local code agent that watches your codebase, acts autonomously, and gets smarter with every cycle.
The agent that learns your codebase so you don't have to explain it twice.
What it does
Sagex runs alongside your project. It watches for file changes, reasons about what matters, takes action via LLM agents, and reflects on outcomes — storing lessons in a local SQLite knowledge base that improves every cycle.
File change detected
↓
Triage agent → is this worth acting on?
↓
Task agent → plan and apply edits
↓
Meta agent → what did we learn?
↓
Rules DB → store lesson for next time
Install
Python (PyPI)
pip install sagex
Node (npx — no Python setup needed)
npx sagex-runtime serve --port 8765
# After install, the CLI is exposed as `sagex` (not `sagex-runtime`):
sagex --version
Choose a provider (v0.2.0+)
Sagex talks to four LLM providers behind the same interface. Pick one in
.agents/config.yaml under agent.provider::
| Provider | Auth | Cost | Best for |
|---|---|---|---|
anthropic_api (default) |
ANTHROPIC_API_KEY env |
Pay-per-token (Anthropic) | Teams, predictable spend |
claude_code |
Local claude login |
$0 (Claude Pro/Max subscription) | Solo devs already paying for Claude Max |
openai_api |
OPENAI_API_KEY env |
Pay-per-token (OpenAI) | OpenAI customers / GPT-5 preference |
ollama |
None | $0 (local hardware) | Privacy, offline, hobbyists |
For a one-off run without editing the config, override with
SAGEX_PROVIDER=ollama sagex serve .... See docs/PROVIDERS.md for
quality expectations, hardware guidance, and known caveats per provider.
Quick start
# Set your Anthropic API key
export ANTHROPIC_API_KEY=sk-ant-...
# Start the runtime
sagex serve --port 8765
# In your project repo (separate terminal)
sagex init .
sagex register .agents/config.yaml
# Check status
sagex status my-project
# Review token spend
sagex usage my-project --last 24h
# Dry-run a manual cycle (safe to test)
sagex trigger my-project --dry-run
Configuration
sagex init . creates .agents/config.yaml in your project:
project:
name: my-project
watch_paths: ["src/", "tests/"]
test_command: "pytest tests/ -q"
agents:
triage:
model: claude-haiku-4-5
severity_threshold: medium
task:
model: claude-sonnet-4-5
max_tokens: 4096
meta:
model: claude-sonnet-4-5
security:
model: claude-sonnet-4-5
auto_remediate: false
budget:
hourly_token_limit: 50000
daily_token_limit: 500000
alert_threshold: 0.8
Requirements
- Python 3.11+
ANTHROPIC_API_KEYenvironment variable- SQLite (bundled with Python)
Publishing
See PUBLISHING.md for instructions on releasing to PyPI and npm.
License
MIT — 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 sagex-0.2.1.tar.gz.
File metadata
- Download URL: sagex-0.2.1.tar.gz
- Upload date:
- Size: 100.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24d36e79ea55aa86bf9472a1441ddd9bffc7441505746cf83e4cd858eecb0a89
|
|
| MD5 |
3ff00560fabbfe57cd91e8641778f135
|
|
| BLAKE2b-256 |
e156869be3ffa8dd46abc6aca97cb9a9d0cda874a6b66e3f319cee4f4edc579f
|
File details
Details for the file sagex-0.2.1-py3-none-any.whl.
File metadata
- Download URL: sagex-0.2.1-py3-none-any.whl
- Upload date:
- Size: 71.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5852f5cd946a94c541d9be898191fd9078a1322ea950cd4ce6355189d272c9c9
|
|
| MD5 |
9a5edac1952aeaaf8fc1bc7a9b7baa62
|
|
| BLAKE2b-256 |
3512a8523cbd38d21ceeff9a00e196296d74bcdcd3034d3708224759081c3715
|