# Hosting agents built with the Claude Agent SDK
Let's say you want an agent that can answer questions about a codebase, or write release notes from its Git history. It needs to find the relevant files, read the code, and follow references until it has enough information to complete the task.
Claude Code is a popular tool for that kind of work, and the [Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/overview) gives a Python or TypeScript application a programmatic interface to Claude Code, including its agent loop, built-in tools, and context management. Hosting that agent means providing somewhere for its tools to run and deciding what happens to its conversation and working files when a task finishes.
To explore and demonstrate hosting such an agent, I created an example [Git Repository Agent](https://github.com/WilliamDenniss/claude-sdk-repository-agent) that can answer code questions and write documentation. This example uses Agent Runtime for hosting and Claude on Vertex AI for model calls. In this simple configuration, each request starts a fresh investigation, but there are options to preserve state between turns, discussed below.
## The Claude Agent SDK, the model, and the runtime
There are a few pieces involved in running this agent:
- **The hosting environment** runs the application and CLI, with compute and a filesystem for tool execution. Here, a FastAPI service accepts requests forwarded by Agent Runtime.
- **The Claude Agent SDK** connects the application to the CLI loop. In Python, it starts and manages a separate CLI subprocess, passes options and prompts to it, and parses its output into Python messages.
- **The Claude Code CLI** runs the agent loop: it calls the model, executes tools locally, and sends their results back for the next decision. It also manages the conversation context as the investigation grows.
- **The Claude model** decides what to investigate, requests tools, and produces the answer. In this example, model calls go to Claude on Vertex AI, outside the agent's container.
Anthropic's [Hosting the Agent SDK guide](https://code.claude.com/docs/en/agent-sdk/hosting) describes this subprocess model. The model runs remotely, but searching the checkout, reading files, and writing documents happen in the container.
One question to the agent can require many model and tool calls. Answering a question about option parsing, for example, might mean searching for the parser, reading it, then following references into the code that configures it. All of that happens within one HTTP request, with the Claude Agent SDK providing access to the [agent loop and its tools](https://code.claude.com/docs/en/agent-sdk/agent-loop). Calling the model API directly would leave the application to implement or supply those parts.
| Public runtime API | Container route | Response |
|---|---|---|
:query |
/api/reasoning_engine |
JSON when the task finishes |
:streamQuery |
/api/stream_reasoning_engine |
Newline-delimited JSON events |