The custom logic pattern provides the maximum flexibility in workflow design.1 You implement the orchestration logic yourself in code — conditional statements and the like — to build complex workflows with multiple branching paths.

Diagram
Open the interactive version here to pan and zoom.
The worked example
The source illustrates the pattern with a customer refund agent, and the example is worth following closely because it shows why the standard patterns weren’t enough:
- The user sends a query to the customer refund agent, which acts as a coordinator agent.
- The coordinator’s custom logic first invokes a parallel verifier agent, which simultaneously dispatches two subagents: a purchaser verifier agent and a refund eligibility agent.
- Once those results are gathered, the coordinator executes a tool to check
whether the request is eligible for a refund.
- If eligible, it routes to a refund processor agent, which calls the
process_refundtool. - If not eligible, it routes to a separate sequential flow, starting with a store credit agent and then a process credit decision agent.
- If eligible, it routes to a refund processor agent, which calls the
- The result from whichever path was taken goes to a final response agent, which formulates the answer for the user.
This workflow mixes patterns: it runs a parallel check, then executes a custom conditional branch that routes into two entirely different downstream processes — one of which is a sequential flow. Logic-level orchestration like this goes beyond what the structured patterns offer, and that mixture is the ideal use case for custom logic.
When to use it
Use it when you need fine-grained control over the agent’s execution, or when your workflow simply doesn’t fit any of the other patterns.
From the pattern-comparison guidance, the workload profile is:
- complex, branching logic that goes beyond a direct linear sequence,
- a need for maximum control to mix predefined rules with model reasoning,
- fine-grained process control for a workflow with no standard template.
Trade-offs
Total control, paid for in development and maintenance complexity. You are responsible for designing, implementing, and debugging the entire orchestration flow, which takes more effort and is more error-prone than using a predefined pattern supported by a framework such as the Agent Development Kit (ADK). ADK documents its own approach to this in Custom agents.
Treat it as the escape hatch, not the default — the value of the named patterns is that someone else has already debugged their control flow.
Footnotes
-
Samantha He, “Choose a design pattern for your agentic AI system”, Google Cloud Architecture Center, last reviewed 2026-05-28. Local copy:
references/google-cloud-agentic-design-patterns.md. ↩