Skip to content

fix(agent): hoist structured output defs to root#1181

Open
Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Alexxigang:fix/structured-output-def-hoisting
Open

fix(agent): hoist structured output defs to root#1181
Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Alexxigang:fix/structured-output-def-hoisting

Conversation

@Alexxigang
Copy link
Copy Markdown
Contributor

Summary

  • hoist nested $defs / definitions to the root when wrapping structured-output schemas under the temporary generate_response tool
  • keep the wrapped
    esponse schema focused on its object body so #//... references resolve correctly during tool parameter validation
  • add regression tests for reused nested objects both at the schema-validation layer and through an actual ReActAgent structured-output flow

Why this fix

Issue #1176 happens because StructuredOutputCapableAgent wraps the generated output schema under a
esponse property, but leaves shared definitions nested inside that property. The generated $ref values still point to #//..., which means validation fails once the schema is wrapped and the definitions are no longer located at the document root.

This change mirrors the same def-hoisting strategy already used in tool parameter schema generation, so reusable nested objects continue to work after the structured-output schema is wrapped for generate_response.

Validation

  • mvn -pl agentscope-core spotless:apply
  • mvn -pl agentscope-core '-Dtest=StructuredOutputSchemaWrappingTest' test
  • mvn -pl agentscope-core '-Dtest=ReActAgentStructuredOutputTest,ToolkitTest,ToolValidatorTest,JsonSchemaUtilsTest' test

Notes

AI Assistance

  • Drafted with AI assistance and validated locally before submission.

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.

1 participant