Overview
CodeAlive’s own chat is powered by an internal research agent that runs an LLM loop over the same tools exposed publicly as the Tool API and the MCP server. This guide shows how to build a similar agent yourself: which tools to give it, how to instruct it, and what a complete research loop looks like. The system prompt below is an adapted, self-contained version of the strategy CodeAlive uses in production. Copy it as a starting point and tune it for your stack.Architecture
A code research agent is a loop:- The user asks a question about a codebase.
- The LLM decides which tool to call and with what arguments.
- Your runtime executes the call against the CodeAlive Tool API (or through MCP) and appends the result to the conversation.
- Steps 2–3 repeat until the LLM has enough evidence, then it writes the final answer.
obj (structured JSON) and rendered (agent-friendly text). For an agent loop, request output_format: "agentic" and feed rendered straight into the model — it is compact and already carries follow-up hints.
Which tools to give the agent
Expose all eleven tools; each covers a distinct move in the research loop:
The generated API Reference documents parameters, request examples, and response shapes for each tool.
Example system prompt
This prompt distills the search strategy CodeAlive’s production agent uses. It assumes the eleven tools above are bound with their canonical names.system-prompt.md
The production prompt additionally handles multi-turn conversation state, workspace-scale scoping (up to ~1,000 repositories per workspace), and structured research-completion checkpoints. Those concerns are specific to CodeAlive’s harness — start with the version above and add orchestration rules as your agent grows.
Worked example
A typical run for “How does task execution work in agent-framework?”:1
Discover data sources
agent-framework as a ready repository — its name goes into every following call.2
Search by meaning
CodeAlive-AI/agent-framework::src/executor.py::TaskExecutor.run — a method artifact with a relevance score and a one-line description.3
Read the core
4
Find the entry point
Scheduler.tick in src/scheduler.py — the upstream trigger that drains the queue.5
Answer with evidence
The agent now has the full flow — entry point (
Scheduler.tick), mechanism core (TaskExecutor.run), and side effects — and answers with file paths and short snippets.Practical notes
- Rate of tool calls. Search tools are billed per call (see
x-codealive-billingin the OpenAPI spec); read and traversal tools (fetch_artifacts,get_artifact_relationships,read_file,get_file_tree) are not. Structure the loop to search once and read many. - Repairable errors. Invalid arguments come back as HTTP 200 with
obj.error = { code, message, retry, try }and a rendered<tool_error>block. Feed the error to the model — thetryhint is written so an LLM can repair the call and retry. - Stateless
chat. If you do exposechat, remember every call is independent: prior findings and identifiers must be repeated insidequestion.
Related resources
API Reference
Parameters and response examples for every tool
Instructing Coding Agents
Make off-the-shelf agents prefer CodeAlive tools
MCP Overview
Use the same tools through MCP instead of raw HTTP
Semantic Search
How CodeAlive’s search works under the hood