This document lives in the repo as CLAUDE.md. Claude Code reads it automatically. For ChatGPT or other tools, paste it as your first message before asking for code help. Last updated March 2026.

Repo location: arkos/CLAUDE.md


Project at a Glance

ARKOS is a Python async agent framework. FastAPI backend, PostgreSQL + mem0 memory, MCP tool compatibility, YAML-based state graphs with Pydantic-enforced transitions.

Module What it owns
agent_module/ Agent loop, step(), step_stream(), choose_transition()
state_module/ State base class, state registry, state graph YAML, all state implementations
tool_module/ MCP client, tool registry, per-user auth (token_store)
base_module/ FastAPI app, endpoints, auth router
logging_module/ Structured JSON lines logger (LogEvent, emit_log)

Stack: Python 3.11+, FastAPI, PostgreSQL, Pydantic v2, asyncio, ruff, pytest.


Architecture Contracts

These are load-bearing rules. Violating them silently breaks the agent loop.

1. Every state.run() must return StateOutput, never a raw AIMessage.

completion_signal must be one of: complete, incomplete, error, needs_input.

2. Every new state must be registered.

Decorate with @register_state. Add to state_graph.yaml with max_iterations and failure_state.


Adding a New State

  1. Create state_module/states/state_{name}.py
  2. Inherit from State, set type = "{name}", decorate with @register_state
  3. run() returns StateOutput — never AIMessage
  4. check_transition_ready() reads completion_signal only