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

output_schema cannot co-exist with agent transfer configurations

Open sumitg opened this issue 1 year ago • 7 comments

I just upgraded to ADK 1.6.1 and now see this error:

[MainThread] - Invalid config for agent tool_agent: output_schema cannot co-exist with agent transfer configurations. Setting disallow_transfer_to_parent=True, disallow_transfer_to_peers=True (llm_agent.py:477)

I have a main agent calling another agent as a tool and it has an output schema defined. That used to work, does it not work now?

sumitg avatar Jul 11 '25 20:07 sumitg

If the schema is set to the main agent with defined tools, then no, it is not possible.

PaveLuchkov avatar Jul 17 '25 11:07 PaveLuchkov

Experiencing a similar issue. I have a Sequential Agent that is composed of 2 sub_agents. First agent does some metric extractions from files, and then the second agent has a structured output.

I get the same error message: Invalid config for agent answer_formatter_agent: output_schema cannot co-exist with agent transfer configurations. Setting disallow_transfer_to_parent=True, disallow_transfer_to_peers=True

Code:

        self.metric_classification_agent = Agent(
            name="metric_classification_agent",
            model=get_settings().GEMINI_MODEL,
            description=METRIC_CLASSIFICATION_AGENT_DESCRIPTION,
            instruction=METRIC_CLASSIFICATION_AGENT_INSTRUCTION,
            # sub_agents=[
            #     self.file_management_agent,
            #     self.bigquery_agent,
            # ],
            tools=[
                AgentTool(self.file_management_agent),
                AgentTool(self.bigquery_agent),
            ],
            planner=PlanReActPlanner(),
            generate_content_config=GenerateContentConfig(temperature=self.temperature),
            output_key="extracted_metric_answer",
        )
        self.answer_formatter_agent = Agent(
            name="answer_formatter_agent",
            model=get_settings().GEMINI_MODEL,
            description=ANSWER_FORMATTER_AGENT_DESCRIPTION,
            instruction=ANSWER_FORMATTER_AGENT_INSTRUCTION,
            generate_content_config=GenerateContentConfig(temperature=self.temperature),
            output_schema=self.task.metric_answer_schema,
            output_key="structured_answer",
        )

        self.root_agent = SequentialAgent(
            name="root_agent",
            description=ROOT_AGENT_DESCRIPTION,
            sub_agents=[
                self.metric_classification_agent,
                self.answer_formatter_agent,
            ],
        )

santiago-gilion avatar Jul 24 '25 09:07 santiago-gilion

I'm observing the same error, when running the agent locally via a runner. In my case, this is simply an LlmAgent and despite the error, the agent can generate the output correctly 🤔 (it's not clear from the logs locally, if this is a warning or an error actually)

gmyrianthous avatar Jul 29 '25 08:07 gmyrianthous

Just as the log says, set those flags to the mentioned agent:

answer_formatter_agent = Agent(
            name="answer_formatter_agent",
            model=get_settings().GEMINI_MODEL,
            description=ANSWER_FORMATTER_AGENT_DESCRIPTION,
            instruction=ANSWER_FORMATTER_AGENT_INSTRUCTION,
            generate_content_config=GenerateContentConfig(temperature=self.temperature),
            output_schema=self.task.metric_answer_schema,
            output_key="structured_answer",
            disallow_transfer_to_parent=True, # <---- here 
            disallow_transfer_to_peers=True, # <---- here 
        )

output_schema cannot co-exist with other function tools. By default, all Agent has transfer capability, which is a function tool transfer_to_agent.

Jacksunwei avatar Aug 12 '25 04:08 Jacksunwei

@Jacksunwei my understanding is now that output_schema is supported alongside tool calls, this limitation no longer makes sense. Am I missing something?

We also have a case where we would want to transfer to another agent in a plugin (using tool_context.actions.transfer_to_agent) based on the structured output from an LlmAgent. Is there another way to accomplish this?

crw2998 avatar Aug 29 '25 12:08 crw2998

I have the same question as @crw2998 . Given that now output_schema is supported with tool calls, can this be fixed? At least the issue should be kept open. It's a perfectly valid use case - I have an agent that outputs structured output with an after_agent_callback to render the output, and for which I want to transfer to another agent after the user has reviewed the output and is happy with it.

arturmatos avatar Oct 21 '25 00:10 arturmatos

The restriction preventing output_schema from coexisting with agent transfer configurations now appears outdated since the August 2025 changes that enabled output_schema + tools support.

I've created #3318 to track removing this limitation. Please follow up there for updates.

Jacksunwei avatar Oct 28 '25 17:10 Jacksunwei