How quantumwake/kas works
K.A.S combines a terminal agent with a local model server. A user enters a task in the TUI or CLI; the agent streams model responses, runs requested tools, returns tool results for further turns, and saves resumable session state. The server translates Messages API requests into model prompts and streams parsed events from interchangeable MLX or llama.cpp backends. Additional documented capabilities include subagents, compaction and local recall, model management, and optional audio, vision, image, video, web, and workspace tools. Some feature links are based on README claims and tree paths; unsampled wiring is omitted.
Main entry points: loop.py Agent turn loop · pipeline.py Generation pipeline · app.py Interactive TUI · registry.py Model registry
Components 24
Agent interface
- Interactive TUI
agent/tui/app.py - Agent CLI
agent/cli.py
Agent runtime
- Agent turn loop
agent/core/loop.py - Prompts and toolspecs
agent/core/prompts.py - Compaction
agent/core/compaction.py - Subagent delegation
agent/core/subagent.py
Model server
- Messages API
server/app.py - Generation pipeline
server/core/pipeline.py - Prompt translation
server/prompting/translate.py - Stream parser
server/prompting/parser.py - Model registry
server/registry.py - KV continuation
server/core/kvpersist.py
Inference backends
- MLX backend
server/backends/mlx.py - llama.cpp backend
server/backends/llama_cpp.py
Agent capabilities
- Tool runner
agent/adapters/tools/executor.py - Tools
agent/adapters/tools - Local recall
agent/adapters/retrieval - Embedding adapters
agent/adapters/embeddings - Session storage
agent/adapters/storage/filesystem.py - Audio features
agent/adapters/audio - Image and video
agent/adapters/tools
Other components
- User
- Local model files
- Anthropic-compatible endpoint
Connections 28
- User → Interactive TUI: enters task
- User → Agent CLI: starts task
- Interactive TUI → Agent turn loop: drives turns
- Agent CLI → Agent turn loop: starts turns
- Agent turn loop → Prompts and toolspecs: uses guidance
- Agent turn loop → Anthropic-compatible endpoint: sends messages
- Anthropic-compatible endpoint → Agent turn loop: streams response
- Agent turn loop → Tool runner: runs tools
- Tool runner → Tools: dispatches calls
- Agent turn loop → Subagent delegation: delegates tasks
- Subagent delegation → Agent turn loop: runs nested turns
- Agent turn loop → Compaction: compacts transcript
- Agent turn loop → Session storage: saves session
- Compaction → Session storage: archives transcript
- Tools → Local recall: exposes recall
- Local recall → Embedding adapters: embeds queries
- Interactive TUI → Audio features: offers voice commands
- Tools → Image and video: provides media tools
- Messages API → Generation pipeline: dispatches generation
- Generation pipeline → Prompt translation: renders request
- Generation pipeline → Stream parser: parses output
- Generation pipeline → Model registry: selects engine
- Generation pipeline → KV continuation: updates continuation
- Model registry → MLX backend: loads backend
- Model registry → llama.cpp backend: loads backend
- MLX backend → Local model files: loads model
- llama.cpp backend → Local model files: loads model
- Anthropic-compatible endpoint → Messages API: serves requests