# Agent Instructions: `host/agent0`

> **Scope:** These instructions apply to files under `host/agent0/`.

> **Maintenance rule:** NOT a changelog; if something stops being true, overwrite it.

## Purpose

host/agent0

## What it is

The host: an MCP client + LLM agent loop. Connects to gateway_mcps, exposes
the aggregated tools/resources to the LLM, and drives the interactive session
with the user. This is the entrypoint of the whole system.

## Files

- client.py         — entrypoint. Builds the agent (OpenHands SDK: LLM + Agent +
```text
                  Conversation) and runs the interactive REPL loop.
```

- mcp_agent0.py     — an in-process MCP server ("agent0-manager") run as an asyncio
```text
                  task inside client.py, sharing memory with it. Lets tools
                  affect the client directly. Exposes `autenter` (auto-approve
                  tool calls on/off) + code_updater (readCode/updateCode).
```

- system_prompt.j2  — Jinja2 system prompt template.
- visualizer.py     — DarkTerminalVisualizer for terminal output.
- run.sh            — creates .venv, pip install -r requirements.txt, runs client.py.
- requirements.txt  — openhands-sdk.
- tests/            — tests.
- next.txt          — STALE dev-log from an earlier layout (/root/claude/ paths,
```text
                  pre-openhands client). Do not trust its structure; kept for
                  history only.
```

## Config

Read from conf/agent0.json at repo-parent level (../../conf/agent0.json):
- providers.anthropic.{api_key, model}
- gateway_url (default http://127.0.0.1:8000/mcp/)

## Gotchas

- No env var for the key — must live in conf/agent0.json (client hard-exits if the
  api_key is missing or still the sk-... placeholder).
- Uses its own .venv (run.sh); do not use the system python.
