SWAAG: a selfhosted working autonomous agent for a local llama.cpp server
Project description
SWAAG
(S)elfhosted (W)orking (A)utonomous (AG)ent
SWAAG is a local-first autonomous agent core for a direct llama.cpp server.
It is built to stay inspectable, replayable, and reproducible on one machine.
Core properties:
- strict context-budget control on every model call
- append-only canonical history with replayable state rebuild
- explicit runtime loop with planning, tools, verification, and recovery
- self-hosted operation against a local
llama.cppHTTP server - session persistence, control messages, checkpoints, and benchmark plumbing
What is in this repo
This repository contains the full working agent project, including:
- the main
swaagpackage undersrc/swaag - CLI entrypoints for agent use, devcheck, lanes, benchmarks, and final proof
- benchmark fixtures and local benchmark wrappers
- full repo-level test suite under
tests/ - additional package-level smoke tests under
src/swaag/tests - detailed documentation under
doc/
Install
Clone the repo and install it in editable mode:
cd /data/src/github/swaag
python3 -m pip install -e .[test]
Optional benchmark dependencies:
python3 -m pip install -e .[official-benchmarks]
Optional packaging/publish tooling:
python3 -m pip install -e .[publish]
If your current Python environment is not writable for publish extras, use a throwaway build venv instead:
python3 -m venv /tmp/swaag-build
/tmp/swaag-build/bin/python -m pip install build twine
/tmp/swaag-build/bin/python -m build
Once the package is published, the intended install command is:
pip install swaag
Local llama.cpp server setup
SWAAG expects a local llama.cpp server that exposes at least:
/health/tokenize/completion
Official llama.cpp repository:
A solid general-purpose example model for local testing:
- Qwen2.5-7B-Instruct-GGUF
- https://huggingface.co/Qwen/Qwen2.5-7B-Instruct-GGUF
Example server launch:
llama-server \
-m /absolute/path/to/Qwen2.5-7B-Instruct-Q5_K_M.gguf \
--host 127.0.0.1 \
--port 14829 \
-c 2048
Default SWAAG config expects the server here:
[model]
base_url = "http://127.0.0.1:14829"
context_limit = 2048
If your server lives elsewhere, override it with either config/local.toml or env vars:
export SWAAG__MODEL__BASE_URL=http://127.0.0.1:14829
export SWAAG__MODEL__CONTEXT_LIMIT=2048
Quickstart
Basic checks:
cd /data/src/github/swaag
python3 -m swaag doctor --json
python3 -m swaag tools
Single-turn ask:
python3 -m swaag ask "Use the calculator tool to compute 6 * 7. Reply with the numeric result only."
Interactive chat:
python3 -m swaag chat
Useful session commands:
python3 -m swaag sessions
python3 -m swaag rename latest my-session
python3 -m swaag control "Keep the current task running, but also answer with plain digits." --session latest
python3 -m swaag checkpoint create --session latest --label before-edit
python3 -m swaag checkpoint restore --session latest
python3 -m swaag history detail latest "What exact command copied src.txt to dst.txt?"
Config
Main defaults:
src/swaag/assets/defaults.toml
Example local override:
config/local.example.toml
Environment override prefix:
SWAAG__...
Config path override:
SWAAG_CONFIG=/path/to/file.toml
Examples:
export SWAAG__MODEL__BASE_URL=http://127.0.0.1:14829
export SWAAG__SESSIONS__ROOT=/tmp/swaag-sessions
export SWAAG__TOOLS__READ_ROOTS='["/safe/root"]'
export SWAAG__TOOLS__ALLOW_SIDE_EFFECT_TOOLS=true
Testing
Installed-package smoke test:
python3 -m swaag.tests
Full repo test suite:
cd /data/src/github/swaag
python3 run_tests.py
pytest -q
Changed-area developer loop:
python3 -m swaag.devcheck
Fast lane:
python3 -m swaag.testlane fast
System lane:
python3 -m swaag.testlane system
Integration lane:
python3 -m swaag.testlane integration
Live lane against a real local server:
SWAAG_RUN_LIVE=1 python3 -m swaag.testlane live
Final proof loop:
python3 -m swaag.finalproof
Build and publish
Build a source distribution and wheel:
python3 -m build
Or use the provided helper:
./build.sh
The helper builds the package, uploads it with twine, and cleans local build artifacts.
Benchmarks
Main benchmark entrypoints:
python3 -m swaag.benchmark external list
python3 -m swaag.benchmark external smoke --all --output /tmp/swaag-external-smoke --json
python3 -m swaag.benchmark system --all --output /tmp/swaag-system-bench --json
Reproducible bounded SWE-bench fixtures live in:
src/swaag/benchmark/fixtures/swebench/
Local Terminal-Bench task fixtures live in:
src/swaag/benchmark/terminal_tasks/
Documentation
Start here:
doc/installation.mddoc/testing.mddoc/architecture.mddoc/runtime_loop.mddoc/context_budgeting.mddoc/history_and_projections.mddoc/memory_and_editing.mddoc/live_runtime_profiles.md
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 swaag-0.1.0.tar.gz.
File metadata
- Download URL: swaag-0.1.0.tar.gz
- Upload date:
- Size: 370.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6d27daadd7620bae851b62ca952f20f6009e6973c676c397cfc828c92c6bfbb
|
|
| MD5 |
5fb14b39c4ca63a0129e2391641a1b83
|
|
| BLAKE2b-256 |
85d1a1149f1867b633a26c4eafd999f07bc26645d50290e1338e0ecb0d90bdc2
|
File details
Details for the file swaag-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swaag-0.1.0-py3-none-any.whl
- Upload date:
- Size: 300.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8138715f0711051c6b8fd0fbb79325b710deccee912c272951b38dad33cf25d
|
|
| MD5 |
806abef44b69ac4b0c68c3586f2fd469
|
|
| BLAKE2b-256 |
91567b903084271a6c925ca079b58ef8829f7e078101ef2e38a2929368c401c0
|