Klauso — terminal agentic coding harness (Anthropic Messages API, tools, MCP, teams)
Project description
Klauso
Klauso is a single-process, async Python terminal harness around the Anthropic Messages API: one lead agent with streaming, parallel tool execution, YAML permissions, an event bus, persisted sessions, context compaction, todos and a task graph, skills, background shell jobs, optional teammate threads and autonomous workers, git worktrees, MCP (stdio) tools, subagents, and cooperative interrupts.
Install from PyPI or from a checkout. Maintainer publishing steps: docs/PUBLISHING.md. Manual QA in another folder: docs/MANUAL_TESTING.md.
Quick start (pip / pipx)
| Step | Command / action |
|---|---|
| 1 | pipx install klauso or pip install klauso |
| 2 | cd your project (workspace) |
| 3 | Copy .env.example to .env in that directory and set ANTHROPIC_API_KEY |
| 4 | Run klauso |
Optional CLI flags (set before other imports; use for non-default layout):
| Flag | Effect |
|---|---|
--workspace DIR |
Sets KLAUSO_WORKSPACE (default: current directory). |
--config-dir DIR |
Sets KLAUSO_CONFIG_DIR for permissions.yaml and mcp_config.yaml. |
--skills-dir DIR |
Sets KLAUSO_SKILLS_DIR for list_skills / load_skill. |
If ./config/permissions.yaml (and mcp_config.yaml) are missing, Klauso seeds them from bundled defaults on first run. If ./skills/ is empty or missing, bundled skills under the package are used.
Quick start (from this repository)
| Step | Command / action |
|---|---|
| 1 | cd to repository root |
| 2 | python3 -m venv .venv && source .venv/bin/activate |
| 3 | pip install -e ".[dev]" |
| 4 | cp .env.example .env and set ANTHROPIC_API_KEY |
| 5 | klauso or python main.py or python -m klauso |
Environment variables are loaded from <workspace>/.env first, then process environment (see klauso.core.client).
Architecture at a glance
| Layer | Role |
|---|---|
klauso/cli.py |
Async REPL, session commands, MCP async context, workers/teammates, drives run_until_idle. |
klauso/core/ |
client (Anthropic + dotenv), settings (model, cache mode, feature flags, CONFIG_DIR, SKILLS_DIR). |
klauso/harness/ |
Agent loop, tool merge + dispatch, MCP lifespan, events, interrupts, sessions, cache, tasks/todos, background bash, teams, worktrees, sync dispatch. |
klauso/tools/ |
JSON tool schemas, permission checks, filesystem/shell builtins. |
klauso/memory/ |
History compression + .agent_memory.md. |
klauso/subagents/ |
spawn_subagent. |
klauso/utils/ |
Message serialization for saved sessions. |
config/ (in workspace) |
permissions.yaml, mcp_config.yaml — see config/README.md. Defaults ship in klauso/resources/. |
skills/ (optional) |
SKILL.md per folder; else bundled skills. |
Turn lifecycle
sequenceDiagram
participant U as Operator
participant O as Turn orchestrator
participant M as Model service
participant T as Tool gateway
U->>O: Conversation state + new input
O->>O: Apply queued interrupts
O->>M: Request streamed completion (tools + policy context)
M-->>O: Assistant output (text and/or tool requests)
alt No tools requested
O-->>U: End turn
else Tools requested
O->>O: Run tool batch concurrently
par Each tool in batch
T->>T: Before-tool observers
T->>T: Permission / policy check
T->>T: Invoke local or remote handler
T->>T: After-tool observers or error reporting
end
O->>O: Attach tool outcomes to conversation
O->>M: Request next completion
end
Repository layout (development)
| Path | Contents |
|---|---|
src/klauso/ |
Installable package (cli, core, harness, tools, …) |
src/klauso/resources/ |
Default permissions.yaml, mcp_config.yaml, bundled skills/ |
pyproject.toml |
PEP 621 metadata, klauso console script, dependencies |
main.py |
Dev shim: prepends src/ and runs klauso.cli:main |
config/ |
Reference copies for the repo workspace |
tests/ |
Pytest |
Tools exposed to the lead agent
Same as before: built-ins, todos, tasks, skills, background bash, teams (optional), worktrees, subagent, and dynamic mcp__<server>__<name> from mcp_config.yaml.
Default MCP servers in packaged defaults: filesystem (@modelcontextprotocol/server-filesystem) and GitHub (@modelcontextprotocol/server-github). Add more stdio entries under servers: in config/mcp_config.yaml. GitHub tools expect a suitable token in the environment (e.g. GITHUB_TOKEN).
Runtime artifacts
| Artifact | Purpose |
|---|---|
.sessions/*.json |
Persisted messages + metadata |
.agent_todo.json |
Todo list |
.agent_tasks.json |
Task board |
.mailboxes/*.jsonl |
Lead ↔ teammate messages |
.agent_events.log |
Hook logger output |
.agent_memory.md |
Compaction summaries |
Configuration
| Variable | Effect |
|---|---|
ANTHROPIC_API_KEY |
Required for API calls |
MODEL_ID |
Default claude-sonnet-4-5-20250929 |
ANTHROPIC_BASE_URL |
Optional gateway |
CACHE_MODE |
anthropic (default) or off |
ENABLE_TEAMS |
1 / 0 |
ENABLE_AUTONOMOUS_WORKERS |
1 / 0 |
HARNESS_DEBUG |
Extra logging |
KLAUSO_WORKSPACE |
Workspace root (optional; default .) |
KLAUSO_CONFIG_DIR |
Directory with permissions.yaml and mcp_config.yaml |
KLAUSO_SKILLS_DIR |
Skills root directory |
YAML details: config/README.md.
REPL commands
| Command | Behavior |
|---|---|
| (normal text) | User message; model runs; session saved after turn |
:sessions |
List saved sessions |
:resume <id> |
Load session |
:fork <id> |
Copy session to new id |
:title <text> |
Rename session |
:save |
Persist now |
q / exit / quit |
Save and exit |
| Ctrl+C during stream | Abort stream; interrupt may be injected |
| Ctrl+C during tools | Queue interrupt for after current step |
Optional LiteLLM gateway
- Optionally add
litellm[proxy]to your environment. - Run LiteLLM with your config.
- Point
.envatANTHROPIC_BASE_URLand alignMODEL_ID.
If the proxy rejects prompt caching, set CACHE_MODE=off.
Tests
python3 -m pip install -e ".[dev]"
python3 -m pytest tests/ -q
Publishing to PyPI
See docs/PUBLISHING.md for what credentials or PyPI settings are required. This repo includes .github/workflows/publish.yml for Trusted Publishing (OIDC) when you publish a GitHub Release; configure the pending publisher on PyPI for your repository and workflow name first.
ADR: Anthropic-native tool protocol
The harness uses the Anthropic Python SDK (tool_use / tool_result). Optional gateways may require CACHE_MODE=off.
Planned improvements
| Area | Goal |
|---|---|
| Parallel subagents | Concurrent subagents with bounded fan-out and cancellation. |
| Webhook-based tasks | HTTP hooks on task lifecycle for external schedulers. |
| Remote MCP | Transports beyond stdio (HTTP/SSE). |
The exportable package goal is addressed by this Klauso distribution (pip install klauso).
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 klauso-0.1.1.tar.gz.
File metadata
- Download URL: klauso-0.1.1.tar.gz
- Upload date:
- Size: 62.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84225501f330f2ea0f5438d31bb51999b43398668a904557394cda92ade1157d
|
|
| MD5 |
38291dae666c91dbf6890017e10df735
|
|
| BLAKE2b-256 |
51b35b81fe46c6f35e6fe1ae232e9ede3519a3045e44120572371f49c9f5952f
|
Provenance
The following attestation bundles were made for klauso-0.1.1.tar.gz:
Publisher:
publish.yml on Mecha-Aima/AI-coding-agent-harness
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klauso-0.1.1.tar.gz -
Subject digest:
84225501f330f2ea0f5438d31bb51999b43398668a904557394cda92ade1157d - Sigstore transparency entry: 1286797564
- Sigstore integration time:
-
Permalink:
Mecha-Aima/AI-coding-agent-harness@383340c820351d7ab5229f387809fce7891122e9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Mecha-Aima
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@383340c820351d7ab5229f387809fce7891122e9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file klauso-0.1.1-py3-none-any.whl.
File metadata
- Download URL: klauso-0.1.1-py3-none-any.whl
- Upload date:
- Size: 53.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99bc1cbf2a9bcfe94b43be1a8d0f34c400e4240cb8c4454bde26407ee0d68977
|
|
| MD5 |
db846755cd7707ce62ed28456b44fa7e
|
|
| BLAKE2b-256 |
5ae87eb8bcdd4299cbc3fee0916756b3b66cc86e223bcf3d405308e690257efe
|
Provenance
The following attestation bundles were made for klauso-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Mecha-Aima/AI-coding-agent-harness
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klauso-0.1.1-py3-none-any.whl -
Subject digest:
99bc1cbf2a9bcfe94b43be1a8d0f34c400e4240cb8c4454bde26407ee0d68977 - Sigstore transparency entry: 1286797711
- Sigstore integration time:
-
Permalink:
Mecha-Aima/AI-coding-agent-harness@383340c820351d7ab5229f387809fce7891122e9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Mecha-Aima
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@383340c820351d7ab5229f387809fce7891122e9 -
Trigger Event:
release
-
Statement type: