Short version: Real agent systems rarely use one pattern. They chain several: route the request, fan out a search, then run a critic before replying. Google calls the mix a composite pattern, and gives you a custom logic pattern when even that is not enough. Anthropic frames the same idea as combining and customizing the building blocks.
What are composite patterns?
Composite patterns combine the basic patterns to build production-grade applications (Google Developers). Anthropic makes the same point about its building blocks: they are not prescriptive, they are common patterns you shape and combine to fit your use case (Anthropic).
Google's worked example is a customer support system: a coordinator routes the request, a technical issue triggers a parallel search of documentation and user history, and the final answer passes through a generator-critic loop to keep the tone consistent before it reaches the user (Google Developers).
When one pattern is not enough: custom logic
Sometimes the mix needs real branching that no single pattern provides. Google's custom logic pattern gives you maximum flexibility by letting you implement orchestration in code, using constructs like conditional statements to create workflows with multiple branching paths (Google Cloud).
The example is a refund agent. A coordinator runs a parallel verifier that checks the purchaser and refund eligibility at once. It then calls a tool to decide eligibility. If the user is eligible, it routes to a refund processor. If not, it routes to a separate sequential flow for store credit. Whichever path runs, a final agent writes the answer (Google Cloud). That mix of a parallel check plus a conditional branch to two different downstream processes is the textbook case for custom logic.
When to use composite and custom logic
Use a composite pattern when a single task naturally spans several shapes: a decision, then concurrent work, then a quality check. Most production systems land here, because real requests are not uniform.
Use the custom logic pattern specifically when you need fine-grained control or your workflow does not fit any standard pattern (Google Cloud). It is the right tool for complex, branching logic that mixes predefined rules with model reasoning.
When not to use it
Do not combine patterns before a single one has failed you. Google's own advice is to start simple, get a sequential chain working, debug it, and only then add complexity (Google Developers). A composite system built on day one is a debugging nightmare with no baseline to compare against.
And do not jump to custom logic when a supported pattern already fits. Hand-rolled orchestration is the most work to maintain, so use it only when the standard shapes genuinely cannot express your flow.
Known problems
The cost of custom logic is ownership. Google is explicit: this approach increases development and maintenance complexity, because you are responsible for designing, implementing, and debugging the entire orchestration flow, which is more error-prone than a predefined pattern supported by a tool like ADK (Google Cloud).
Composite systems also inherit every failure mode of their parts. A composite that includes a loop can loop forever, one that includes parallel work can hit race conditions, and one that routes can misroute. The more patterns you stack, the more places there are to fail, which is why the discipline of adding one at a time matters so much.
Three pro tips before you combine patterns
Google closes its guide with three that apply directly here (Google Developers):
- Treat state as your whiteboard. Use descriptive keys when one agent writes output, so downstream agents know exactly what they are reading.
- Write precise descriptions. In any routing step, a sub-agent's description is the documentation the model uses to decide. Be exact.
- Start simple. Do not build a nested loop system on day one. Get a chain working, then add complexity in measured steps.
FAQ
What is a composite agent pattern?
A composite pattern combines basic patterns, such as routing, parallelization, and a critic loop, into one system. Most production agents are composites.
When should I use custom logic instead of a standard pattern?
When your workflow needs branching that no single pattern expresses, or when you need fine-grained control that mixes coded rules with model reasoning.
Why not just start with a composite system?
Because you lose the ability to debug. Start with one pattern, prove it, then add the next. A day-one composite has no baseline and hides its bugs.
Do composites cost more?
Usually, since they run more patterns and more model calls. They also inherit the failure modes of every pattern they include, so plan safeguards for each.
Sources
- Google Developers Blog, Developer's guide to multi-agent patterns in ADK: https://developers.googleblog.com/developers-guide-to-multi-agent-patterns-in-adk/
- Google Cloud Architecture Center, Choose a design pattern for your agentic AI system: https://docs.cloud.google.com/architecture/choose-design-pattern-agentic-ai-system
- Anthropic, Building Effective Agents: https://www.anthropic.com/engineering/building-effective-agents

Top comments (0)