Skip to content

[26.0] Standardize agent API schemas and response metadata#21692

Draft
dannon wants to merge 12 commits intogalaxyproject:release_26.0from
dannon:agent-response-standardization
Draft

[26.0] Standardize agent API schemas and response metadata#21692
dannon wants to merge 12 commits intogalaxyproject:release_26.0from
dannon:agent-response-standardization

Conversation

@dannon
Copy link
Member

@dannon dannon commented Jan 29, 2026

Followup to #21580 — final cleanup/standardization pass on the agent system before release.

Goals: make agent responses consistent across all agents, fix schema issues causing data loss, and tighten suggestion validation.

  • Fixed metadata (exchange_id, token usage, model name) getting lost when delegated agents pass back through the router
  • Added _build_metadata() / _build_response() helpers so all agents produce consistent responses
  • Typed ChatResponse.agent_response as Optional[AgentResponse] instead of dict[str, Any]
  • Added processing_time, regenerate, save_exchange fields to relevant schemas
  • Deprecated /api/ai/agents/query (duplicates /api/chat), removed dead routing_info/stream fields
  • Added model_validator on ActionSuggestion enforcing required params per action type
  • TOOL_RUN suggestions validated against toolbox, removed unused REFINE_QUERY action type
  • ConfidenceLevel enum used consistently everywhere instead of raw strings
  • Removed unused HandoffInfo schema model and preemptive CONTACT_SUPPORT suggestions

How to test the changes?

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 29, 2026

Did you want to target 26.0 ?

@dannon dannon force-pushed the agent-response-standardization branch from b52bf0b to 1e7078a Compare January 29, 2026 16:24
@dannon dannon changed the base branch from dev to release_26.0 January 29, 2026 16:25
@github-actions github-actions bot changed the title Standardize agent API schemas and response metadata [26.0] Standardize agent API schemas and response metadata Jan 29, 2026
@dannon dannon force-pushed the agent-response-standardization branch 2 times, most recently from ac09883 to abdc3cb Compare January 30, 2026 12:59
dannon added 12 commits February 4, 2026 13:34
Added helper methods (_build_metadata, _build_response) to the base
agent class so all agents produce consistent metadata with model name,
token usage, and method tracking. The router now properly serializes
handoff responses to preserve the delegated agent's metadata through the
routing layer.

Fixed ChatResponse schema - agent_response and exchange_id fields were
being silently dropped by Pydantic, which is why suggestions weren't
showing in the UI. Also removed the `as any` casts in ChatGXY.vue now
that types are correct.
Updated ChatResponse to use typed AgentResponse instead of untyped dict,
and added processing_time field. ChatPayload now supports a regenerate
flag to bypass cached responses for job-based queries.

Deprecated /api/ai/agents/query (duplicates /api/chat), removed dead
code (routing_info, stream fields that were never used). Added
save_exchange parameter to error-analysis and custom-tool endpoints
for opt-in feedback tracking.
Fields with non-None defaults still generate as required in TypeScript.
Changed to default=None and handle None as False in the API handler.
ActionSuggestions now validate required parameters based on action type at
creation time, catching invalid suggestions before they reach the frontend.

- TOOL_RUN requires tool_id
- SAVE_TOOL requires tool_yaml
- VIEW_EXTERNAL requires url
- DOCUMENTATION, CONTACT_SUPPORT, REFINE_QUERY have no required params

Also fixed error_analysis agent to use REFINE_QUERY instead of TOOL_RUN
for solution guidance since these aren't specific tool invocations.
Extended mocked integration and unit tests to verify that agent
responses include valid suggestions:

- custom_tool: verify SAVE_TOOL suggestion has tool_yaml and tool_id
- error_analysis: verify suggestions have action_type, description, confidence
- Added unit tests for _create_suggestions validating ActionSuggestion params
ActionSuggestions should only be for concrete actions the frontend can execute,
not general guidance. Error analysis now only emits CONTACT_SUPPORT when admin
intervention is needed, with a pre-filled message containing error context.

Removed REFINE_QUERY suggestions - if the agent needs clarification it should
ask conversationally, not via an action button.
- base.py: removed keyword-matching heuristics that created invalid TOOL_RUN
  suggestions without tool_id
- tools.py: validate tool exists in toolbox before creating TOOL_RUN suggestion
  in simple response parsing path
- error_analysis: returns empty suggestions for now (CONTACT_SUPPORT not wired up)
Agents should ask clarifying questions conversationally, not via action buttons.
VIEW_EXTERNAL and DOCUMENTATION kept as placeholders for future use.
Replace raw string confidence values with ConfidenceLevel enum
everywhere — base validation response, error_analysis structured
and simple paths, router handoff deserialization, and tool
recommendation's verbose if/elif chains. The internal AgentResponse
constructor already normalized strings, but callers should be
explicit about types.
The simple text parsing path was always returning a CONTACT_SUPPORT
suggestion regardless of the error, while the structured output path
correctly returned empty suggestions. Aligned both paths to return
empty suggestions -- support contact should only be suggested when
it's actually the right course of action, not as a default fallback.
Converted all four direct AgentResponse constructions in tools.py to
use _build_response(), so they get consistent metadata (model name,
token usage, query_length). Added reasoning parameter to
_build_response() to support it.
HandoffInfo was defined but never populated -- handoff data flows
through metadata["handoff_info"] as a plain dict, which the frontend
already reads. No reason to have a typed schema field that's always
None.
@dannon dannon force-pushed the agent-response-standardization branch from abdc3cb to f7a75d3 Compare February 4, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants