|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Build and Run |
| 8 | +```bash |
| 9 | +# Build and push multi-platform image (requires hydrobuild builder) |
| 10 | +make build-adk-image |
| 11 | +``` |
| 12 | + |
| 13 | +### Development Tools |
| 14 | +```bash |
| 15 | +# Type checking |
| 16 | +pyright |
| 17 | + |
| 18 | +# Code formatting and linting |
| 19 | +ruff check |
| 20 | +ruff format |
| 21 | +``` |
| 22 | + |
| 23 | +### Testing and Development |
| 24 | +- Access the web interface at `http://localhost:8080` after running `docker compose up --build` |
| 25 | +- Use Google Cloud Run deployment with `compose.gcloudrun.yaml` for cloud deployment |
| 26 | + |
| 27 | +## Architecture Overview |
| 28 | + |
| 29 | +This is an **ADK (Agent Development Kit) multi-agent fact-checking system** with three coordinated agents: |
| 30 | + |
| 31 | +### Agent Hierarchy |
| 32 | +- **Root Agent**: `llm_auditor` (SequentialAgent) at `agents/agent.py:22` |
| 33 | + - Orchestrates the entire fact-checking workflow |
| 34 | + - Coordinates between Critic and Reviser agents sequentially |
| 35 | + |
| 36 | +- **Critic Agent**: `agents/sub_agents/critic/agent.py:27` |
| 37 | + - Has access to DuckDuckGo search via MCP (Model Context Protocol) |
| 38 | + - Gathers external evidence to support or refute claims |
| 39 | + - Uses `mcp/duckduckgo:search` toolset |
| 40 | + |
| 41 | +- **Reviser Agent**: `agents/sub_agents/reviser/agent.py:97` |
| 42 | + - No external tools - pure reasoning agent |
| 43 | + - Refines conclusions based on Critic's findings |
| 44 | + - Uses content processing callbacks for model compatibility |
| 45 | + |
| 46 | +### Agent Communication Pattern |
| 47 | +1. User submits question → Auditor |
| 48 | +2. Auditor → Critic (with search tools) |
| 49 | +3. Critic gathers evidence → Auditor |
| 50 | +4. Auditor → Reviser (reasoning only) |
| 51 | +5. Reviser refines conclusion → Auditor |
| 52 | +6. Auditor delivers final answer |
| 53 | + |
| 54 | +### Special Implementation Notes |
| 55 | +- Reviser agent uses content preprocessing callbacks (`force_string_content`, `_remove_end_of_edit_mark`) for model compatibility |
| 56 | +- MCP tools are configured via `create_mcp_toolsets()` in critic agent |
| 57 | +- All agents use LiteLLM for model abstraction with OpenAI format |
| 58 | + |
| 59 | +### Generating a compose.yaml file |
| 60 | + |
| 61 | +* To add models and gateways to an existing compose.yaml file, you should figure out which model you want to use, and which mcp servers are needed. |
| 62 | +* Create a service entry like the following |
| 63 | + ``` |
| 64 | + mcp-gateway: |
| 65 | + image: docker/mcp-gateway:latest |
| 66 | + use_api_socket: true |
| 67 | + command: |
| 68 | + - --transport=sse |
| 69 | + - --servers=server1,server2,server3 |
| 70 | + - --config=/mcp_config |
| 71 | + - --secrets=docker-desktop:/run/secrets/mcp_secret |
| 72 | + secrets: |
| 73 | + - mcp_secret |
| 74 | + ``` |
| 75 | + but replace the servers value with a comma-separate list of the MCP servers that you want to use. |
| 76 | +* Also, if there is no top-level `secrets` entry with a `mcp_secret` entry then add one. It should look like: |
| 77 | + ``` |
| 78 | + secrets: |
| 79 | + mcp_secret: |
| 80 | + file: ./.mcp.env |
| 81 | + ``` |
| 82 | + and remind that the user that Docker offload will require secrets to be stored in a local file named .mcp.env |
| 83 | +* Whenever a model is needed, add a toplevel entry in the compose.yaml file with the name of the model. It should look like: |
| 84 | + ``` |
| 85 | + models: |
| 86 | + <model_name>: |
| 87 | + model: <model_image_ref> |
| 88 | + ``` |
| 89 | + but replace the <model_name> with whatever model the user wants to use. |
| 90 | + If the user wnts the model_name qwen3 then the model_image_ref should be ai/qwen3:14B-Q6_K |
| 91 | + * whenever a model is added, the user must specify what service needs the model. |
| 92 | + Add a new entry to that service's definition with the following content. |
| 93 | +
|
| 94 | + ``` |
| 95 | + models: |
| 96 | + <model_name>: |
| 97 | + endpoint_var: MODEL_RUNNER_URL |
| 98 | + model_var: MODEL_RUNNER_MODEL |
| 99 | + ``` |
| 100 | + If it's unclear which service needs this definition then ask. Always add the model to just the service definition that needs it. |
0 commit comments