Skip to content

Fix paper_flow compatibility with OpenAI Agents SDK v0.17+#87

Open
SecretPoets wants to merge 1 commit into
LLMQuant:masterfrom
SecretPoets:fix/paper-flow-openai-agents-compat
Open

Fix paper_flow compatibility with OpenAI Agents SDK v0.17+#87
SecretPoets wants to merge 1 commit into
LLMQuant:masterfrom
SecretPoets:fix/paper-flow-openai-agents-compat

Conversation

@SecretPoets

Copy link
Copy Markdown

Summary

  • Wrap output_type in AgentOutputSchema(strict_json_schema=False) to fix strict JSON schema rejection when using nested Pydantic models with extra="forbid" and additionalProperties
  • Add explicit UUID4 format instructions to the agent prompt so the LLM generates valid UUIDs for TreeKnowledge node IDs instead of human-readable strings like "root" or "introduction"
  • Import AgentOutputSchema from the agents package

Context

paper_flow fails at runtime with OpenAI Agents SDK v0.17.x due to two independent issues:

  1. Schema error: The SDK's strict mode requires all object types to omit additionalProperties, but QuantMind's BaseKnowledge and related models use ConfigDict(extra="forbid") which sets additionalProperties: false. The SDK rejects this at agent construction time.

  2. UUID validation error: With strict mode disabled, the LLM returns the correct tree structure but uses descriptive strings as node IDs. Pydantic then rejects the response because TreeNode.node_id, TreeKnowledge.root_node_id, and related fields are typed as UUID.

Both fixes are minimal and localised to paper.py.

Test plan

  • Verified paper_flow runs end-to-end on arXiv paper 2310.10688 (TimesFM) with gpt-4o-mini
  • Confirmed the extracted Paper object passes Pydantic validation with proper UUID node IDs
  • Run existing test suite (pytest)

🤖 Generated with Claude Code

Two issues prevented paper_flow from running against current OpenAI
Agents SDK:

1. Strict JSON schema mode rejects nested Pydantic models that use
   extra="forbid" with additionalProperties. Wrap the output_type in
   AgentOutputSchema(strict_json_schema=False) so the SDK does not
   enforce strict mode on the response schema.

2. The LLM generates human-readable node IDs ("root", "introduction")
   instead of valid UUID4 strings, causing Pydantic validation failures
   on TreeKnowledge's UUID-typed fields. Add explicit UUID4 format
   instructions to the agent prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@keli-wen keli-wen added type: bug Existing behavior violates its contract or documented expectation area: flows Public operation implementations under quantmind/flows/ labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: flows Public operation implementations under quantmind/flows/ type: bug Existing behavior violates its contract or documented expectation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants