Overview

11 Tips for building agentic systems

This chapter shifts from theory to practical building advice for production agentic systems, using the five agent layers as a framework for design. The main message is that strong agents come from disciplined choices at every layer: keep the persona sharply defined, make tools focused and reliable, control reasoning loops, ground answers in retrieval, and instrument everything so the system can be evaluated and improved over time.

For the core persona, the chapter emphasizes treating instructions like an API contract: set clear role boundaries, keep the scope narrow, prefer structured outputs, and inject runtime facts only when they matter. For tools and actions, it recommends single-purpose tools with clear schemas, using function-based tools when possible, constraining when tools can run, relying on trusted prebuilt capabilities where appropriate, and designing for failure with retries and graceful fallbacks. Across both areas, the recurring theme is to reduce ambiguity, token bloat, and unintended behavior.

The later sections apply those principles to common agent patterns. For reasoning and planning, the chapter favors explicit plan-then-execute loops, ReAct-style iteration, turn limits, and self-review, while warning against uncontrolled reasoning in simple tasks. For knowledge and memory, it frames retrieval as the foundation of useful context, advocating RAG-first designs, selective long-term memory, hybrid search, careful chunking, and strict grounding. For evaluation and feedback, it stresses tracing, automated tests, human feedback, guardrails, and DevOps-style iteration. These ideas are then adapted to customer support, RAG workflows, and deep research systems, where modular agents, escalation paths, grounding discipline, and critic/writer-style oversight help deliver answers that are safe, accurate, and useful.

Highlights the five agent layers and for each layer the internal boxes represent the patterns that can help improve development of the respective layer.
shows an agent deployment wrapped with a best practices evaluation and feedback system
demonstrates an entire customer support agentic system workflow.
demonstrates a more advanced RAG agent system that can query from multiple different context sources to answer a question/search.
illustrates the implementation of the deep research agent system.

Summary

  • Treat agent design as five stacked layers: persona, tools/actions, reasoning & planning, knowledge & memory, and evaluation & feedback. Optimize each layer independently, then integrate.
  • Write the persona as an API contract, not prose: clear role, boundaries, and an explicit “I don’t know” off‑ramp.
  • Keep scope narrow (single responsibility) for higher accuracy and easier testing/cost control.
  • Prefer structured, typed outputs (Pydantic/dataclass JSON) to eliminate parsing brittleness.
  • Use dynamic instructions (inject date/org/user) at run time to avoid stale facts.
  • Build single‑responsibility tools with crisp names, docstrings, and typed params; the model learns tool use from these schemas.
  • Control when tools run (e.g., tool_choice, parallel tool calls); stop early when one call suffices.
  • Leverage pre-built/hosted tools where sensible, but be selective.
  • Plan for failures: timeouts, retries, graceful error payloads, and fallbacks.
  • Adopt ReAct (reason → act → observe) or Chain‑of‑Thought patterns for non-trivial tasks.
  • Plan then execute draft a short checklist before acting; consider a lightweight “thinking” server/step.
  • Cap iterations to prevent runaway loops; signal needs_followup on budget/turn limits.
  • Add a quick self-review pass before finalizing to catch obvious mistakes.
  • Treat RAG as first‑class: use a retrieval tool over a KB instead of stuffing docs into prompts.
  • Separate session memory (short-term thread context) from long-term memory (vector/DB); prune aggressively.
  • Optimize retrieval: ANN indexes, shard by domain, filter with metadata, consider domain/multilingual embeddings.
  • Use hybrid search (semantic + keyword + hierarchical/graph) for recall/precision.
  • Chunk semantically, ground answers strictly in the retrieved context, and be comfortable saying “don’t know.”
  • Keep data fresh and partitioned by role/tenant to enforce access boundaries.
  • Trace everything: prompts, tool calls, token counts, latency, outcomes; wire to your observability stack.
  • Automate evaluations (LLM‑as‑judge + curated test sets) on each prompt/model change.
  • Incorporate HITL: collect user feedback, review complex cases.
  • Add guardrails & moderation at inputs, tool calls, and outputs; validate schemas.
  • Practice AIOps: measure → observe → iterate, including downstream systems (indexes/APIs) your agents depend on.
  • Narrow the charter (orders, returns, status) first; expand gradually.
  • Ground every answer via RAG; add a dedicated grounding agent if needed.
  • Provide HITL escalation (escalate_to_human) and capture user feedback.
  • Enforce identity & least‑privilege access before revealing account data or invoking business APIs.
  • Engineer resilience (retries, fallbacks, timeouts) and cache popular answers; apply rate limits.
  • Maintain transparent traces per conversation for auditability.
  • Real‑world “support agent” = multiple cooperating agents (triage → retrieval → grounding → action/guardrail → answer).
  • Use an agentic orchestrator only when needed; if one-shot RAG suffices, keep it simple.
  • Prefer modular roles: router/triage → retriever → answerer; optionally a Critic (CRAG) for corrective retrieval.
  • Optimize retrieval (ANN, filters, rerankers, HyDE) and enforce grounding with citations.
  • Instrument recall, accuracy, and “should have said I don’t know” cases; close the loop with evals.
  • For advanced systems, support multiple corpora, ranking/refinement loops, and bounded retries.
  • Use two-tier orchestration: a Planner (brain) delegates to stateless Workers (hands) for web search, extraction, analysis, and writing.
  • Enforce tool‑use policies: no claims without cited sources; facts must come from retrieval/doc tools.
  • Add self-critique/fact‑check before the final report (Critic pass).
  • Provide a streaming UX to surface partial findings and outlines as they emerge.
  • Manage caching & budgets: dedupe repeated queries, cap tokens/calls, and clear caches periodically to avoid staleness.
  • Production-ready agentic systems emerge from tight personas, well-scoped tools, guided reasoning, disciplined retrieval, and relentless measurement—assembled into modular, auditable workflows with clear escalation paths and grounded outputs.

FAQ

What are the five agentic layers discussed in the chapter?The chapter organizes agent design into five layers: persona, tools and actions, reasoning and planning, knowledge and memory, and evaluation and feedback. Each layer has practical tips that help improve agent behavior, reliability, and usefulness.
Why should an agent’s persona be treated like an API contract?The persona shapes downstream choices such as tool use, memory, and planning. Treating it like an API contract means defining clear role boundaries, expected behavior, and what the agent must not do, which reduces drift and makes the agent more consistent.
Why is it better to keep an agent’s scope narrow?Specialized agents with a single responsibility are easier to test, cheaper to optimize, and usually perform better than broad “do-everything” bots. A narrow scope also makes behavior more predictable and easier to control.
What makes a good tool for an agent?A good tool should be single-purpose, have a clear name and docstring, and use typed parameters so the model can understand when and how to use it. The chapter also recommends using function tools where possible, controlling when tools run, and planning for failures with retries or fallbacks.
How should reasoning and planning be handled in multi-step agent tasks?Use structured reasoning patterns such as ReAct for non-trivial tasks and plan-then-execute for larger goals. The chapter also advises limiting iterations to prevent loops and adding a self-review step before final output.
Why is retrieval the starting point for knowledge and memory design?Retrieval is the foundation because knowledge and memory depend on finding relevant information quickly. Instead of stuffing documents into prompts, the chapter recommends building retrieval as a first-class capability with vector search, metadata filters, and selective memory storage.
What evaluation and feedback practices are most important for production agents?At minimum, you should trace prompts, tool calls, latency, token counts, and outcomes; automate evaluations on test sets; and include human feedback loops. Guardrails and moderation are also recommended to enforce policy and schema validation.
What are the key design tips for a customer support agent?Keep the charter narrow, ground every answer in policies or manuals, and support escalation to humans for unclear, angry, or high-risk cases. The chapter also emphasizes identity checks, least-privilege tool access, resilience, caching, rate limits, and transparent traces.
When should you build a RAG agent system with multiple agents?Use multiple agents when routing, critique, corrective retrieval, or actions are needed beyond a simple one-shot RAG call. A modular pattern like triage → retriever → answerer, optionally with a critic, helps keep the workflow clear and scalable.
What is the recommended structure for a deep research agent system?The chapter recommends a two-tier setup: a Research Planner as the brain and stateless worker agents for web search, extraction, analysis, and summarization. It also recommends source-based tool policy controls, self-critique, streaming results, and caching with budget limits.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free