Skip to content

Remove restriction: output_schema should coexist with agent transfer configurations #3318

@Jacksunwei

Description

@Jacksunwei

Background

Since commit af63567 (August 2025), ADK supports using output_schema alongside regular tools by introducing a set_model_response tool mechanism. However, the restriction preventing output_schema from coexisting with agent transfer configurations remains in place.

Current Behavior

When an agent has output_schema set, the validation in llm_agent.py:750-771 forcibly disables agent transfers:

def __check_output_schema(self):
    if not self.output_schema:
      return

    if (
        not self.disallow_transfer_to_parent
        or not self.disallow_transfer_to_peers
    ):
      logger.warning(
          'Invalid config for agent %s: output_schema cannot co-exist with'
          ' agent transfer configurations. Setting'
          ' disallow_transfer_to_parent=True, disallow_transfer_to_peers=True',
          self.name,
      )
      self.disallow_transfer_to_parent = True
      self.disallow_transfer_to_peers = True

Why This Restriction Appears Outdated

  1. Agent transfers are implemented as tools (transfer_to_agent in transfer_to_agent_tool.py)
  2. The set_model_response mechanism works with any tools, including agent transfer tools
  3. Both processors can coexist architecturally:
    • _OutputSchemaRequestProcessor handles output_schema + tools
    • _AgentTransferLlmRequestProcessor adds the transfer_to_agent tool
    • Both are already registered in AutoFlow

There's no clear technical reason why agent transfers can't use the same workaround that regular tools use.

Valid Use Cases Being Blocked

From issue #1910:

  1. Structured output with post-processing: An agent with structured output and after_agent_callback that needs to transfer to another agent after user review
  2. Plugin-based transfers: Plugins that use tool_context.actions.transfer_to_agent based on structured output from an LlmAgent
  3. Sequential agents with formatting: A sequential workflow where one agent does work and another formats the output with a schema

Proposed Solution

Remove or relax the validation that prevents output_schema from coexisting with agent transfer configurations, allowing the existing set_model_response mechanism to handle both regular tools and transfer tools.

Related Issues

Technical Details

  • Restriction location: src/google/adk/agents/llm_agent.py:750-771
  • Related commit: af63567
  • Output schema processor: src/google/adk/flows/llm_flows/_output_schema_processor.py
  • Agent transfer processor: src/google/adk/flows/llm_flows/agent_transfer.py

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementation

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions