Skip to main content

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.cpp HTTP 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 swaag package under src/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:

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.md
  • doc/testing.md
  • doc/architecture.md
  • doc/runtime_loop.md
  • doc/context_budgeting.md
  • doc/history_and_projections.md
  • doc/memory_and_editing.md
  • doc/live_runtime_profiles.md

License

MIT. See LICENSE.

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

swaag-0.1.0.tar.gz (370.6 kB view details)

Uploaded Source

Built Distribution

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

swaag-0.1.0-py3-none-any.whl (300.1 kB view details)

Uploaded Python 3

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

Hashes for swaag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a6d27daadd7620bae851b62ca952f20f6009e6973c676c397cfc828c92c6bfbb
MD5 5fb14b39c4ca63a0129e2391641a1b83
BLAKE2b-256 85d1a1149f1867b633a26c4eafd999f07bc26645d50290e1338e0ecb0d90bdc2

See more details on using hashes here.

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

Hashes for swaag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8138715f0711051c6b8fd0fbb79325b710deccee912c272951b38dad33cf25d
MD5 806abef44b69ac4b0c68c3586f2fd469
BLAKE2b-256 91567b903084271a6c925ca079b58ef8829f7e078101ef2e38a2929368c401c0

See more details on using hashes here.

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