From "Using" Agents to "Building" Them
Using ready-made agents like Claude Cowork or Manus is the entrance. To build an agent fitted to your work, you need to know design patterns. This article organizes 3 basic patterns: Tool Use, Sub-agent, control flow.
Pattern 1: Tool Use
Give the LLM, from outside, info it doesn't know or operations it can't do, as "tools (functions)." The AI calls and uses them itself.
Example: An AI That Answers Weather
tools: [
{
name: "get_weather",
description: "Today's weather for a specified city",
input: { city: "string" },
},
{
name: "send_slack",
description: "Send a message to Slack",
input: { channel: "string", text: "string" },
},
]
Asked "post Tokyo's weather to Slack," the AI calls in order get_weather → send_slack itself.
Design Tips
- Make tool name/description concrete so the AI understands "what for, what"
- Strictly define the input schema (JSON Schema). Vague, and the AI passes weird values
- Make failure error text readable too. The AI can recover
Pattern 2: Sub-agent
Split one big task into multiple specialist agents. Divide by role like "researcher," "writer," "proofreader."
Example: Article-Writing Agent
main agent ├ research-agent (research, gather citations) ├ writer-agent (write the body) └ editor-agent (proofread, SEO)
The main agent manages overall progress, passing roles to each Sub-agent.
Design Tips
- Separate contexts so each Sub-agent can run independently
- Pass info between Sub-agents in structured (JSON) form
- Each Sub-agent has its own system prompt and tool set
Pattern 3: Control Flow
A method controlling the agent's movement explicitly in code. Frameworks like LangGraph / Vercel Workflow / Inngest apply.
Judgment / Branching
if (analysisResult.score > 0.8) {
await sendToHuman(result);
} else {
await retryWithBetterPrompt(input);
}
Parallel Execution
const [a, b, c] = await Promise.all([
fetchTask("A"),
fetchTask("B"),
fetchTask("C"),
]);
const summary = await llm.summarize([a, b, c]);
Approval Flow (Human-in-the-loop)
const draft = await llm.draft(input); await sendForApproval(draft); const approval = await waitForApproval(); // human judgment if (approval) await llm.execute(draft);
Selective Use of the 3 Patterns
| Pattern | Suited use |
|---|---|
| Tool Use | External-system integration, data fetch + action |
| Sub-agent | Complex tasks, clearer when split by role |
| Control flow | Conditional branching/approval/work needing certainty |
In practice you combine the 3.
Implementation Techniques to Reduce Failure
1. Cap One Loop
Limit "up to 5 tool calls." Prevents infinite loops.
2. Log All Intermediate Results
Save all Sub-agent exchanges and Tool Use calls. "Why did this happen?" is traceable later.
3. Approval for Certain Operations
Always human-approve delete/transfer/send/publish. Agent-judgment + prompt-injection defense.
4. Test Behavior
Prepare "malicious input" and "unexpected" test cases. Guarantee quality with Eval.
Cautions
- Over-design: Sub-agent unneeded if a single LLM suffices
- Cost: more Sub-agents sharply increases token use. Estimate cost at design
- Hard to debug: many layers make root-cause hard when broken. Grow from minimal
Next Step
This chapter's following articles "Intro to MCP," "Multi-Agent Design," "Browser-Use / Computer-Use" go into implementation.



