Chapter 10: Real-World Patterns: Research, Automation, and Support
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- bun, typescript
- Ambito
- ai, documentation
Direzione di ricerca
Start with chapters 6, 3, 4, and 9, then inspect the requirements for chapters/10-real-world.md and the six files under examples/10-real-world/. Run the first sample with bun run and verify each sample is runnable and importable as specified. Done means the chapter and all agents, approval gate, eval harness, and unified Telegram entry point meet the line, build, routing, and README/sidebar checks.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Part of the Build Your Own Coding Agent tutorial. One issue = one chapter (chapters/10-real-world.md) plus its examples/10-real-world/ samples.
Goal (1 sentence): Apply everything to three agent archetypes (research, automation, support) plus human-in-the-loop gates and a small eval harness, all wired into Telegram.
After this chapter you can
- Compose the Chapter 6 runner with domain tool sets to build research, automation, and support agents that each carry their own
messageshistory and share a single Telegram bot client. - Implement a human-in-the-loop approval gate that intercepts a
tool_useblock, emits a Telegram inline-keyboard prompt, and resumes or cancels the tool cycle based on the reply. - Integrate RAG retrieval as a tool call for the support agent, using a
retrieve_docstool that fetches top-k chunks and acache_controlblock on the static knowledge-base system prompt to cut cost across repeated queries. - Build a minimal eval harness that replays fixture conversations through
client.messages.create, extracts structured assertions from the finaltextblock, and logs pass/fail withusagemetrics to track cost per eval. - Wire all three agents into one Telegram bot, routing
/research,/automate, and/supportcommands to separate agent instances.
What to cover (ONE paragraph, not a list)
This chapter wires the Chapter 6 runner into three production archetypes. The research agent defines a web_search tool with input_schema, chains multiple tool_use -> tool_result turns, and controls depth with a step counter checked on each stop_reason === "tool_use" guard. The automation agent is triggered from a cron or webhook handler, passes task context through the system prompt, and forces an action on the first turn with tool_choice: { type: "any" }, then resets to auto on later turns so the loop can reach end_turn - because forced tool_choice blocks a final text reply. The support agent adds a retrieve_docs tool for top-k RAG retrieval, an escalate_to_human tool that fires a Telegram notification, and a cache_control block on the static knowledge-base system prompt to cut latency and cost across repeated queries. Safety checks inspect tool_use.name and tool_use.input before execution and short-circuit with an explanatory tool_result when a call looks destructive; token budgeting reads usage.input_tokens and usage.output_tokens after each turn and trims oldest non-system messages when the running total nears the context limit. The chapter closes by routing /research, /automate, and /support Telegram commands to their respective agent instances and measuring quality with the eval harness.
Going deeper (optional asides - keep OFF the main line)
- None
Out of scope (defer - do NOT preview)
- None
Code samples - examples/10-real-world/
-
research-agent.ts- bounded multi-step web-search + synthesis. -
automation-agent.ts- cron-triggered; forced first action thenauto. -
support-agent.ts-retrieve_docs+escalate_to_human+ cached KB prompt. -
approval-gate.ts- intercept destructivetool_use; Telegram confirm; resume/cancel. -
eval-harness.ts- fixture replay scoring tool selection + answer quality. -
telegram-all-agents.ts- route/research/automate/supportto the three agents.
Must-keep for a beginner (floor - never cut for brevity)
- The run command for the first sample.
- "Never hardcode your key; it comes from the environment" (once, in prose).
- Anything a beginner cannot infer from the code (e.g. Bun auto-loads
.env, no loader needed). - The one genuinely non-obvious gotcha:
tool_choice: { type: "any" }prevents a finalend_turntext reply - reset toautoon subsequent turns or the loop never terminates.
Friendliness floor (never cut - terse is not friendly)
- The chapter addresses the reader as "you", never "the user" or "one".
- The intro AND at least one section open with a warm, second-person sentence.
Key APIs (flat list, reference only - NOT a coverage checklist)
client.messages.create, client.messages.stream, stop_reason, tool_use, tool_result, tool_choice (auto/any/tool), input_schema, usage.input_tokens, usage.output_tokens, cache_control, system, tools, human-in-the-loop gate, eval harness
Prerequisites
Chapters 6 (reusable runner), 3 (Telegram raw fetch), 4 (conversation history), 9 (RAG/retrieval); a vector store for retrieve_docs.
Definition of done
- Chapter at
chapters/10-real-world.md, <=120 lines, <=4 main-line H2s plus an optional "What's next" closer (pastewc -lANDgrep -c '^## 'in the PR). - Every sample runnable with
bun run, imported via<<< @/examples/10-real-world/file.ts, <=35 lines, comment:code <=0.30. - One-home rule held: no prose sentence restates an inline code comment.
- Friendliness floor held: reader addressed as "you"; intro + >=1 section open warm.
- Samples use only real
@anthropic-ai/sdksurface; ASCII punctuation only. - Optional material lives in Going-deeper asides, not main-line H2s.
- All three agents + gate + eval harness implemented and runnable with
bun run. - Unified Telegram entry point routes all three archetypes.
- Linked from
README.mdand the.vitepress/config.tssidebar;bun x vitepress buildpasses.
- Lingua principale
- TypeScript
- Stelle
- 0
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di yagop/coding-agents-tutorial
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
documentation
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
-
documentation
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
yagop/coding-agents-tutorial#8 · 1 commento ·
Tutte le issue di yagop/coding-agents-tutorial
Issue simili
-
Browser Waiting for: Product Owner
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
getsentry/sentry-javascript#24577 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
agilepathway/label-checker#640 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
copse-dev/agent-pane#2953 ·
-
[aw] Upgrade available Apertaagentic-workflows
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
githubnext/rig#534 ·
-
automation missing-model model-sync provider:pioneer
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
anomalyco/models.dev#7701 ·