adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Feature Request: Per-Agent RunConfig Support for Individual Sub-Agents and Coordinator Agents

Open wtberry opened this issue 1 year ago • 2 comments

Summary

Request support for configuring individual RunConfig settings for each sub-agent and coordinator agent in Google ADK, rather than the current shared configuration approach.

Background

Currently, Google ADK uses a shared RunConfig approach where:

  • RunConfig is passed to Runner.run_async() and stored in InvocationContext
  • All agents (coordinator and sub-agents) inherit the same configuration from the invocation context
  • This limits fine-grained control over individual agent behavior

Use Case

We are investigating latency issues in a multi-agent system where:

  • The coordinator agent should have a low LLM call limit (e.g., max_llm_calls=1) for quick routing decisions
  • Specialist sub-agents need higher limits (e.g., max_llm_calls=5) for complex processing
  • Different agents may require different streaming modes, timeout settings, or other configurations

Current Limitations

  1. Shared InvocationContext: The current architecture shares InvocationContext (including run_config) across all agents in a single invocation
  2. No Built-in Per-Agent Config: There's no native ADK feature for per-agent RunConfig
  3. LLM Call Counting: The max_llm_calls limit is enforced at the invocation level, not per agent
  4. Workarounds are Complex: Current solutions require custom agent implementations or runner modifications

Proposed Solution

Option 1: Agent-Level RunConfig Property

class LlmAgent(BaseAgent):
    agent_run_config: Optional[RunConfig] = None
    
    async def _run_async_impl(self, ctx: InvocationContext):
        # Use agent-specific config if available, otherwise fall back to context config
        effective_config = self.agent_run_config or ctx.run_config
        modified_ctx = ctx.model_copy(update={'run_config': effective_config})
        # ... rest of implementation

Option 2: RunConfig Override in Agent Constructor

coordinator = LlmAgent(
    name="Coordinator",
    run_config=RunConfig(max_llm_calls=1, streaming_mode=StreamingMode.NONE),
    # ... other params
)

specialist = LlmAgent(
    name="Specialist", 
    run_config=RunConfig(max_llm_calls=5, streaming_mode=StreamingMode.SSE),
    # ... other params
)

Option 3: Runner-Level Agent Configuration Map

runner = Runner(
    agent=root_agent,
    agent_configs={
        "Coordinator": RunConfig(max_llm_calls=1),
        "SpecialistAgent": RunConfig(max_llm_calls=5),
    }
)

Benefits

  1. Fine-grained Control: Different agents can have optimized configurations for their specific roles
  2. Performance Optimization: Coordinator agents can be limited to quick decisions while specialists can perform complex reasoning
  3. Resource Management: Better control over LLM usage and costs per agent type
  4. Flexibility: Supports diverse multi-agent architectures with varying requirements

Implementation Considerations

  • Backward compatibility with existing shared RunConfig approach
  • Clear precedence rules (agent-specific > invocation-level > default)
  • Documentation and examples for common use cases
  • Performance impact of per-agent configuration management

Related Files

  • google/adk/agents/run_config.py - RunConfig class definition
  • google/adk/agents/invocation_context.py - InvocationContext with shared run_config
  • google/adk/agents/base_agent.py - Base agent implementation
  • google/adk/runners.py - Runner implementation with run_config handling

Additional Context

This feature request emerged from a latency investigation where we needed to add comprehensive timing logs to identify performance bottlenecks in a multi-agent system. The ability to configure individual agents would significantly improve debugging and optimization capabilities.

wtberry avatar Jun 05 '25 01:06 wtberry

Hi @wtberry and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

klateefa avatar Oct 08 '25 05:10 klateefa

Still facing this on ADK 1.28.0. Our use case is a slightly different angle on the same underlying limitation:

Use case: app-level default RunConfig for adk api_server deployments

We run a production agent via adk api_server on Cloud Run. The server creates the Runner internally and calls Runner.run_async(run_config=...) per request, but there is no way to set a default RunConfig at the App level — so every invocation uses the library default (max_llm_calls=500), and we cannot tune it without forking the server.

We verified via introspection on 1.28.0:

>>> from google.adk.apps import App
>>> import inspect
>>> inspect.signature(App)
(*, name: str, root_agent: BaseAgent, plugins: list[BasePlugin] = <factory>,
   events_compaction_config: Optional[EventsCompactionConfig] = None,
   context_cache_config: Optional[ContextCacheConfig] = None,
   resumability_config: Optional[ResumabilityConfig] = None) -> None

No run_config parameter.

Current workaround

A custom before_tool_callback that counts tool calls in tool_context.state and sets tool_context.actions.skip_summarization = True when exceeded. This works but:

  1. It's a per-agent guard replicated everywhere instead of a framework-level limit.
  2. It only covers the tool-call dimension, not raw LLM calls.
  3. It duplicates logic that RunConfig.max_llm_calls already implements.

Proposed API

Complementary to the per-agent support originally requested in this issue:

App(
    name="my_agent",
    root_agent=...,
    plugins=...,
    default_run_config=RunConfig(max_llm_calls=300),  # used by adk api_server
)

With adk api_server honoring App.default_run_config when constructing the Runner. Per-agent overrides (the original request in this thread) would take precedence over the app-level default.

Summary

  • Per-agent RunConfig: needed for multi-agent systems (original request).
  • App-level default RunConfig: needed for single-agent production deployments via adk api_server (this comment).

Both are facets of the same underlying constraint. Could this be reopened?

roanny avatar Apr 05 '26 13:04 roanny