From c068992ca5ff7db02c84fcf09f4c9d999990a2e0 Mon Sep 17 00:00:00 2001 From: Auz Date: Mon, 15 Jun 2026 10:52:41 +1000 Subject: [PATCH] Fix Paper output schema compatibility with OpenAI Agents Co-authored-by: Cursor --- quantmind/flows/paper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/quantmind/flows/paper.py b/quantmind/flows/paper.py index 5b8373b..2633250 100644 --- a/quantmind/flows/paper.py +++ b/quantmind/flows/paper.py @@ -13,7 +13,7 @@ from typing import Any, TypeVar -from agents import Agent, RunHooks, Tool +from agents import Agent, AgentOutputSchema, RunHooks, Tool from quantmind.configs import PaperFlowCfg from quantmind.configs.paper import ( @@ -86,6 +86,11 @@ async def paper_flow( """ cfg = cfg or PaperFlowCfg() out_type: type[Paper] = output_type or Paper # type: ignore[assignment] + resolved_output_type: Any = ( + AgentOutputSchema(Paper, strict_json_schema=False) + if out_type is Paper + else out_type + ) raw_md, source_meta = await _fetch_and_format(input) @@ -98,7 +103,7 @@ async def paper_flow( ), "model": cfg.model, "tools": list(extra_tools or []), - "output_type": out_type, + "output_type": resolved_output_type, "input_guardrails": list(extra_input_guardrails or []), "output_guardrails": list(extra_output_guardrails or []), }