Fix Google ADK agents with output_schema - #1887
Open
devjoinedthechat wants to merge 1 commit into
Open
devjoinedthechat wants to merge 1 commit into
devjoinedthechat wants to merge 1 commit into
Conversation
ADK stores an agent's output_schema on the LlmRequest as a Python type, which the payload converter cannot serialize, so every workflow task failed when scheduling the model activity. Send the type's JSON schema instead; google-genai and LiteLlm derive the same schema from the type.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
TemporalModelnow replaces a type-valuedresponse_schemaon theLlmRequestwith its JSON schema (TypeAdapter(schema).json_schema()) before schedulinginvoke_model/invoke_model_streaming. Dicts andtypes.Schemapass through unchanged. The conversion runs on a copy aftersummary_fn, so the request ADK and callbacks see is not modified.Why?
An
LlmAgentwithoutput_schemacan't run under the plugin today. ADK's basic request processor callsllm_request.set_output_schema(agent.output_schema), which stores the Pydantic class itself inconfig.response_schema, and the activity input then fails to serialize:That fails the workflow task, so it retries until the workflow times out. Reproduced with google-adk 2.4.0 (the locked version) and 2.9.2; ADK main still stores the type.
Sending the JSON schema doesn't change what the model receives. google-genai converts a model class through its JSON schema anyway: I compared the generated
responseSchemafor the Gemini API and Vertex with flat, nested, enum and recursive models and they're identical. Forlist[Model]the only difference is atitle: "Placeholder"that google-genai adds for the generic alias. ADK'sLiteLlmbuilds the sameresponse_formatfrom the dict.If you'd rather handle this in
_AdkPayloadConverter, I'm happy to move it there.Checklist
Closes: no existing issue (small bug fix)
How was this tested:
test_agent_with_output_schemaruns anLlmAgent(output_schema=..., output_key=...)in a workflow with a local test model and checks the parsed result in session state. Without the change it fails with the error above until the workflow times out.list[Model], dict passthrough) through the plugin's payload converter.pytest tests/contrib/google_adk_agents: 55 passed, 5 skipped.Any docs updates needed? No. Added a changelog entry under Fixed.