In Task 1 you built a CLI that calls an LLM, but it still cannot look at your actual code or read your documentation. That is the difference between a chatbot and an agent: an agent has tools — functions it can call to interact with the real world, then reason about the results. We'll start by giving your agent two tools (read_file, list_files) to navigate the project wiki.
An agentic loop: your code sends the question to the LLM, the LLM decides which tool to call, your code executes it, feeds the result back, and the LLM decides what to do next — call another tool or give the final answer.
Question ──▶ LLM ──▶ tool call? ──yes──▶ execute tool ──▶ back to LLM
│
no
│
▼
JSON output
- Send the user's question + tool definitions to the LLM.
- If the LLM responds with
tool_calls→ execute each tool, append results astoolrole messages, go to step 1. - If the LLM responds with a text message (no tool calls) → that's the final answer. Extract the answer and source, output JSON and exit.
- If you hit 10 tool calls → stop looping, use whatever answer you have.
Your system prompt should tell the LLM to use list_files to discover wiki files, then read_file to find the answer, and include the source reference (file path + section anchor).
Same rules as Task 1. Two additions: source field and populated tool_calls.
uv run agent.py "How do you resolve a merge conflict?"{
"answer": "Edit the conflicting file, choose which changes to keep, then stage and commit.",
"source": "wiki/git-workflow.md#resolving-merge-conflicts",
"tool_calls": [
{"tool": "list_files", "args": {"path": "wiki"}, "result": "git-workflow.md\n..."},
{"tool": "read_file", "args": {"path": "wiki/git-workflow.md"}, "result": "..."}
]
}source(string, required) — the wiki section reference (e.g.,wiki/git-workflow.md#resolving-merge-conflicts).tool_calls(array, required) — all tool calls made. Each entry hastool,args, andresult.- Maximum 10 tool calls per question.
Implement two tools and register them as function-calling schemas in your LLM request.
Read a file from the project repository.
- Parameters:
path(string) — relative path from project root. - Returns: file contents as a string, or an error message if the file doesn't exist.
- Security: must not read files outside the project directory (no
../traversal).
List files and directories at a given path.
- Parameters:
path(string) — relative directory path from project root. - Returns: newline-separated listing of entries.
- Security: must not list directories outside the project directory.
Before writing code, create plans/task-2.md. Describe how you will define tool schemas, implement the agentic loop, and handle path security.
Update agent.py to define read_file and list_files as function-calling schemas, implement the agentic loop, and return JSON with answer, source, and tool_calls fields.
Update AGENT.md to document the tools, the agentic loop, and your system prompt strategy.
Add 2 regression tests for the documentation agent. Example questions:
"How do you resolve a merge conflict?"→ expectsread_filein tool_calls,wiki/git-workflow.mdin source."What files are in the wiki?"→ expectslist_filesin tool_calls.
-
plans/task-2.mdexists with the implementation plan (committed before code). -
agent.pydefinesread_fileandlist_filesas tool schemas. - The agentic loop executes tool calls and feeds results back to the LLM.
-
tool_callsin the output is populated when tools are used. - The
sourcefield correctly identifies the wiki section that answers the question. - Tools do not access files outside the project directory.
-
AGENT.mddocuments the tools and agentic loop. - 2 tool-calling regression tests exist and pass.
- Git workflow: issue
[Task] The Documentation Agent, branch, PR withCloses #..., partner approval, merge.