Module 32: Agent-Client Agent
From chatbot to agent. The chatbot in Module 25 answers from the model’s head with one completion call. This agent’s prompt handler hands the user’s goal to an agent loop that reads and edits files and runs tools in the open project, for as many turns as the goal needs, then reports back.Prerequisites
- Completed Module 25: AI Chatbot Agent
- The Claude CLI (Claude Code) installed and logged in. Run
claudeonce to confirm it opens without asking for a key - Java 17+
What You’ll Learn
- Putting a tool-using agent loop behind an ACP
@Prompthandler - Using the session’s working directory as the directory the agent acts in
- How Agent Client (
AgentClient) wraps a CLI agent as a reusable model
The Code
The ACP skeleton is identical to the chatbot.@NewSession additionally remembers the working directory the client opened, and the body of @Prompt runs an agent instead of a completion:
main is the same AcpAgentSupport bootstrap as Module 25.
Chatbot vs Agent
The three ACP handlers are unchanged. That is the jump from chatbot to agent.
Swapping the Provider
agent-claude has siblings for other CLI agents, such as agent-gemini and agent-codex. Build a different AgentModel and the rest of the handler, and the ACP wire protocol, stay the same.
Using It in Your IDE
Plug it in like the other agents (Module 29), but launch it through a wrapper script that unsetsANTHROPIC_API_KEY and then runs its arguments:
Source Code
View on GitHubRunning the Example
haiku.txt containing a haiku about AI agents. It then reads the file back from disk to show the agent wrote it.