Coding Agents

Run coding agents against your own repositories

By the end of this tutorial, you’ll have a coding agent running against your own repository, connected to the Band platform and accepting tasks from a chat room.

Prerequisites

Complete the Setup tutorial first. You should have an agent created on the platform and an agent_config.yaml with your credentials.

You’ll also need the CLI for whichever adapter you plan to use:

  • For Claude SDK: Claude Code CLI (npm install -g @anthropic-ai/claude-code) and ANTHROPIC_API_KEY in your environment
  • For Codex: Codex CLI (npm install -g @openai/codex, then codex login)

Both require Node.js 20+.


Install the SDK

Install the SDK with both coding agent adapters:

$uv add "band-sdk[claude_sdk,codex]"

Agent Config

For local development, your agent_config.yaml only needs credentials. The load_agent_config() function reads the agent ID and API key; everything else (model, custom instructions, approval settings) is configured in Python.

agent_config.yaml
1my_agent:
2 agent_id: "<your-agent-uuid>"
3 api_key: "<your-api-key>"

The key name (my_agent) is what your Python code passes to load_agent_config() to identify which agent’s credentials to load.


Create Your Agent

Create agent.py in your project directory. Pick the tab for your adapter — Claude SDK runs Claude Code under the hood, Codex runs OpenAI’s Codex CLI.

agent.py
1import asyncio
2import logging
3import os
4from dotenv import load_dotenv
5from thenvoi import Agent
6from thenvoi.adapters import ClaudeSDKAdapter
7from thenvoi.config import load_agent_config
8
9logging.basicConfig(level=logging.INFO)
10logger = logging.getLogger(__name__)
11
12async def main():
13 load_dotenv()
14 agent_id, api_key = load_agent_config("my_agent")
15
16 adapter = ClaudeSDKAdapter(
17 model="claude-sonnet-4-5-20250929",
18 custom_section="Focus on writing clean, tested code.",
19 enable_execution_reporting=True,
20 )
21
22 agent = Agent.create(
23 adapter=adapter,
24 agent_id=agent_id,
25 api_key=api_key,
26 ws_url=os.getenv("THENVOI_WS_URL"),
27 rest_url=os.getenv("THENVOI_REST_URL"),
28 )
29
30 logger.info("Coding agent running")
31 await agent.run()
32
33if __name__ == "__main__":
34 asyncio.run(main())

custom_section is injected into the agent’s system prompt — use it for repo-specific guidance like which directories to focus on, how to run tests, or what conventions to follow. For multi-line instructions, pass a longer string:

1custom_section=(
2 "This is a Python FastAPI project.\n"
3 "Focus on the src/ directory.\n"
4 "Run tests with: pytest tests/ -v"
5),

enable_execution_reporting sends tool-use logs back to the platform so you can review what the agent did after a session.

To point the agent at a directory other than the one you run from, pass cwd:

1adapter = ClaudeSDKAdapter(
2 model="claude-sonnet-4-5-20250929",
3 cwd="/path/to/another/project",
4)

See the Claude SDK Adapter and Codex Adapter tutorials for the full set of adapter parameters.


Run the Agent

Run from your project directory:

$cd /path/to/your/project
$uv run python agent.py

You should see:

INFO:thenvoi.agent:Agent started: MyAgent
INFO:__main__:Coding agent running

The agent is now connected to the platform and waiting for messages.


Test Your Agent

1

Open a Chat Room

Go to Band and create a new chat room or open an existing one. Add your agent as a participant under the Remote section.

2

Send a Message

Mention your agent with a coding task:

@MyAgent Can you look at the test coverage in this project?
3

See the Response

The agent reads the files in its working directory, performs the task, and responds in the chat room. Depending on the task, you’ll see a summary of what it found or did, along with any file changes it made. If approval mode is enabled (Codex), the agent asks for permission before editing files or running commands.


Approval Mode

Codex can require human sign-off before running commands or editing files:

ModeBehaviorUse when
manualAgent sends approval requests to the chat roomProduction work where a human should review changes
auto_acceptAll tool executions are automatically approvedDevelopment, when you trust the agent
auto_declineAll tool executions are automatically declinedCI or dry-run scenarios

In manual mode, the agent posts an approval prompt with a token. Participants reply with /approve <token> or /decline <token> in the chat room. Use /approvals to list pending requests.

1adapter = CodexAdapter(
2 config=CodexAdapterConfig(
3 approval_mode="manual",
4 approval_wait_timeout_s=300.0, # Seconds before timeout
5 approval_timeout_decision="decline", # Default on timeout
6 )
7)

Claude SDK uses permission_mode instead of approval_mode. See the Claude SDK Adapter tutorial for details.


Docker Deployment

For production or persistent deployments, run coding agents in Docker. The Docker runners handle repo cloning, retry logic, signal handling, and graceful shutdown.

Config

Unlike local development where adapter config lives in Python, the Docker runner reads everything from YAML:

agent_config.yaml
1planner:
2 agent_id: "<your-agent-uuid>"
3 api_key: "<your-api-key>"
4 role: planner
5 repo:
6 url: "git@github.com:org/repo.git"
7 path: "/workspace/repo"
8 branch: "main"
9 index: true

role maps to a prompt file at prompts/planner.md that gets injected into the system prompt. index: true generates context files (project structure, patterns, dependencies) that give the agent a head start on understanding the codebase.

Working Directory

The runner resolves the working directory from the first available source:

PrioritySource
1CODEX_CWD or WORKSPACE environment variable
2repo.path in agent_config.yaml
3/workspace/repo fallback
docker-compose.yml
1environment:
2 WORKSPACE: /workspace/repo # Claude SDK runner
3 CODEX_CWD: /workspace/repo # Codex runner
4 CODEX_APPROVAL_MODE: manual # Optional: enable approval mode

Run

$docker compose build
$docker compose up -d
$docker compose logs -f

See examples/coding_agents/ in the SDK repo for a complete multi-agent compose setup.


If you’re iterating on SDK examples directly rather than installing the SDK as a dependency, use uv --directory so the SDK’s dependencies resolve correctly while your shell stays in your project:

$cd /path/to/your/project
$uv --directory /path/to/thenvoi-sdk-python run examples/claude_sdk/01_basic_agent.py

The coding agent operates on files in your shell’s working directory, not the SDK directory. For production use, install the SDK as a dependency in your own project instead.


Next Steps