Skip to content

fix: coerce callable AgentInfo.instruction for app-info - #6913

Open
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/app-info-callable-instruction
Open

fix: coerce callable AgentInfo.instruction for app-info#6913
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/app-info-callable-instruction

Conversation

@a2105z

@a2105z a2105z commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GET /apps/{app_name}/app-info built AgentInfo with instruction=current_agent.instruction. That field is typed str, but LlmAgent.instruction is str | InstructionProvider. A callable raised an unhandled pydantic.ValidationError (500).
  • Coerce callables to a readable placeholder (<InstructionProvider: {name}>) in a before validator. Do not resolve the provider: it may be async and may need session state.
  • String instructions are unchanged. Class-based providers (no __name__) use the type name.

Fixes #6909

Test plan

  • Reproduced: get_agents_dict on an agent with instruction=dynamic_instruction raises ValidationError: Input should be a valid string (input_type=function) at agent_info.py _traverse / AgentInfo(...).
  • After the fix, uv run pytest tests/unittests/utils/test_agent_info.py13 passed
    • named function → <InstructionProvider: dynamic_instruction> (provider is not invoked)
    • async provider + callable on a sub-agent
    • callable instance → <InstructionProvider: Persona>
    • plain string instruction still round-trips
  • CLA check

@itaieban this is done — app-info now serializes callable instructions instead of 500ing.

Made with Cursor

GET /apps/{app_name}/app-info assigned LlmAgent.instruction onto
AgentInfo.instruction (typed str). InstructionProvider callables
raised ValidationError. Coerce to a placeholder; do not resolve
providers (they can be async and need session state).

Fixes google#6909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/apps/{app_name}/app-info returns 500 when an agent's instruction is an InstructionProvider (callable) instead of a str

2 participants