Skip to content
Blog

Orchestrating Diverse LLM Models Across Different Sub-Agent Roles

Assign the right model to each sub-agent role in Google ADK using string IDs, LiteLlm connectors, planners, and per-agent generation config.

Published on • November 30, 2026

AI Assistant

“Use the biggest model everywhere” is the multi-agent equivalent of buying a truck to carry groceries. It works, and it quietly triples your bill while adding latency to the tasks that needed none — a FAQ lookup, a JSON formatter, and a full root-cause analysis all paying frontier-model prices for the same token count.

The real insight behind multi-agent architecture is that roles have different cognitive profiles. A router needs speed and instruction-following; an analyst needs depth and long context; a writer needs tone; a classifier needs cheap throughput. Google ADK treats the model as a per-agent decision, so a single Runner can carry sub-agents that each run a different LLM — Gemini, Claude, or anything LiteLLM can reach.

This tutorial shows how to assign models by role, how ADK resolves which model an agent actually uses, how to tune sampling and planners per agent, and how to add failover when a provider goes down.


1. How ADK Resolves the Model for Each Agent

Three mechanisms, in the order ADK applies them:

            Agent(sub_agents=[...])
                     │
     ┌───────────────┼──────────────────────────┐
     ▼               ▼                          ▼
 1. Explicit      2. Ancestor              3. Built-in
    `model=`        inheritance              default
     │               │                          │
     └── wins ───────┴── nearest LlmAgent ──────┘
                      ancestor that set one
  1. Explicit model= on the agent. Either a string resolved through ADK’s internal registry (Gemini via AI Studio or Agent Platform, Claude models, Agent Platform endpoints) or a model connector instance such as LiteLlm(model="openai/gpt-4o") for anything outside the Google ecosystem.
  2. Inheritance. If you omit model, the agent inherits from its nearest LlmAgent ancestor, skipping non-LLM parents such as SequentialAgent, ParallelAgent, or a custom BaseAgent.
  3. Built-in default. Failing that, ADK’s default model applies. You can also set a fleet-wide default with LlmAgent.set_default_model("gemini-flash-latest") and override per role.

The practical consequence: sub-agents inherit whatever the coordinator declared unless you say otherwise. Role-based orchestration starts by deliberately breaking that inheritance.


2. Defining the Role–Model Matrix

Before writing agents, write the matrix. Ours for a research-and-drafting pipeline:

RoleJobModel classWhy
orchestratorPlan, delegate, summarizeBalanced mid-sizeFrequent, must be cheap enough to run often
fact_researcherWeb/KB retrieval + synthesisStrong reasoning, long contextDepth matters, runs few times
policy_checkerRegex-like compliance rulesSmall fast modelDeterministic-ish, high volume
draft_writerLong-form proseStrong writer, high token budgetOutput quality is the product
json_formatterWrap final answer in a schemaSmallest availableStructured output, no reasoning needed

Keep this table in the repo next to the agent definitions — it is the contract you will evaluate against.


3. Building the Multi-Model Fleet

Here is the fleet in Python. Gemini is referenced by string; non-Google models go through the LiteLlm connector, which takes a standard provider/model string and the matching API key in the environment:

from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

# Cheap + fast: classification and structured formatting
format_agent = LlmAgent(
    name="json_formatter",
    model="gemini-flash-latest",
    instruction="Convert the final answer into the exact JSON schema requested.",
    include_contents="none",
)

# Balanced: day-to-day orchestration — see the wired-up tree below.

# Deep reasoning via a connector model (requires ANTHROPIC_API_KEY)
researcher = LlmAgent(
    name="fact_researcher",
    model=LiteLlm(model="anthropic/claude-sonnet-4"),
    instruction="Research the topic. Cite sources. Flag anything uncertain.",
    tools=[search_knowledge_base],
    description="Deep multi-source research with citation tracking.",
)

# Long-form writing on a separate provider (requires OPENAI_API_KEY)
writer = LlmAgent(
    name="draft_writer",
    model=LiteLlm(model="openai/gpt-4o"),
    instruction="Write the deliverable in the house style: short sentences, "
                "concrete nouns, no hedging.",
    description="Turns researched notes into publication-ready prose.",
)

# Wire the tree
orchestrator = LlmAgent(
    name="orchestrator",
    model="gemini-flash-latest",
    instruction="Delegate research to `fact_researcher`, then drafting to "
                "`draft_writer`. Never draft before research returns.",
    sub_agents=[researcher, writer],
)

Because each sub-agent declares its own model, the single Runner dispatches every model call through the correct backend while the session, events, and state stay unified:

async def main():
    session_service = InMemorySessionService()
    runner = Runner(
        agent=orchestrator,
        app_name="content_studio",
        session_service=session_service,
    )
    session = await session_service.create_session(
        app_name="content_studio", user_id="u_7"
    )
    async for event in runner.run_async(
        user_id="u_7",
        session_id=session.id,
        new_message=types.Content(
            role="user",
            parts=[types.Part(text="Draft a 600-word explainer on vector databases.")],
        ),
    ):
        print(f"[{event.author}] final={event.is_final_response()}")

Watch event.author in the output: each model’s contributions are attributed to its agent, so cost attribution per provider falls out of the event log for free.


4. Tuning Each Role: Sampling, Tokens, Planners

Different roles deserve different generation settings. generate_content_config takes a google.genai.types.GenerateContentConfig per agent:

from google.genai import types

researcher = LlmAgent(
    name="fact_researcher",
    model=LiteLlm(model="anthropic/claude-sonnet-4"),
    instruction="...",
    generate_content_config=types.GenerateContentConfig(
        temperature=0.2,           # stick to evidence
        max_output_tokens=4096,
    ),
)

writer = LlmAgent(
    name="draft_writer",
    model=LiteLlm(model="openai/gpt-4o"),
    instruction="...",
    generate_content_config=types.GenerateContentConfig(
        temperature=0.9,           # voice and variation
        max_output_tokens=8192,
    ),
)

Planners are per-agent too, and this is where model diversity pays off twice. Models with native reasoning (Gemini’s thinking mode) use BuiltInPlanner; models without it get PlanReActPlanner, which forces an explicit plan → action → final-answer structure in the prompt:

from google.adk.planners import PlanReActPlanner

policy_checker = LlmAgent(
    name="policy_checker",
    model=LiteLlm(model="openai/gpt-4o-mini"),
    instruction="Verify the draft against the compliance rules.",
    planner=PlanReActPlanner(),   # structured steps for a non-thinking model
)

That is the honest version of “orchestration”: you are not just picking models, you are compensating for what each model lacks with the scaffolding ADK provides.


5. Failure Modes and Failover

Multi-model fleets multiply the number of things that can break: rate limits, expired keys, regional outages. Two patterns cover most of it.

Connector boundaries. Anything going through LiteLlm fails at the connector, not deep inside agent logic, so catching a provider outage means watching one seam. Keep API keys in environment variables per provider (OPENAI_API_KEY, ANTHROPIC_API_KEY) so rotation does not require a code change.

Routing with fallback. ADK supports dynamic model selection at runtime — a router function picks a model per invocation and, on error, is re-invoked with error context so it can select a fallback rather than surface the exception. The same idea applies at the agent level: if your fact_researcher provider is degraded, a router can point that role at a Gemini-backed twin for the session.

def model_for(role: str):
    """Returns the configured model for a role, with a Gemini fallback."""
    primary = {"researcher": LiteLlm(model="anthropic/claude-sonnet-4"),
               "writer":     LiteLlm(model="openai/gpt-4o")}.get(role)
    return primary if provider_healthy(role) else "gemini-flash-latest"

Wire this at process start (or in an async router callback) rather than inside every agent: model choice is configuration, and configuration belongs in one place.

For deeper control — rewriting the outgoing LlmRequest (contents, config, tool declarations) before it reaches a specific backend — ADK’s model layer is extensible: you can subclass the base Llm class and mutate the request for one provider. Use it for adapter quirks (a provider that rejects parallel tool calls, a gateway that needs a custom header), not for business logic.


6. Evaluating the Fleet

A multi-model fleet needs per-role evaluation, not one global score. In practice:

  1. Log event.author alongside latency and token counts. You now have per-role cost automatically.
  2. Give each role its own golden set. Research answers get factuality checks; formatting gets schema-validity checks. ADK’s evaluation tooling works on session recordings, so one recorded session can score five roles independently.
  3. Re-run the matrix quarterly. Cheaper models improve fast; a role pinned to last year’s frontier model is usually overpaying today.
  4. Keep a canary prompt per role that fails loudly if a model silently degrades (a bad fallback, a throttled key returning short answers).

7. Checklist

  • Role–model matrix written down before agent code exists.
  • Every sub-agent sets model= explicitly — never rely on inherited defaults for role definition.
  • Non-Google models go through LiteLlm (or another connector) with per-provider env keys.
  • Sampling config matches the role: low temperature for checks, high for prose.
  • Planners assigned per model capability (BuiltInPlanner vs PlanReActPlanner).
  • Stateless helpers use include_contents="none" to cut tokens and leakage.
  • Failover strategy defined per provider seam, with a Gemini-class fallback.
  • Cost and latency attributed per event.author in production dashboards.

Sources