Repository navigation
fix: preserve Responses message output text - #269
Chen Yufeiyang (feiiiiii5) wants to merge 2 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55ea14fdd8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| } | ||
| ) | ||
| client_class = AsyncOpenAI if is_async else OpenAI | ||
| client = client_class(api_key="test-api-key", max_retries=0) |
There was a problem hiding this comment.
Pin the Python test clients to the mocked base URL
When OPENAI_BASE_URL points to a custom endpoint, both SDK constructors inherit that endpoint, but the Respx route above only matches https://api.openai.com/v1/responses. This affects the pytest environment configured in .github/workflows/python.yaml:35-39 whenever its endpoint secret selects a gateway: all ten parametrized cases fail on unmatched requests before exercising conversion. Pass base_url="https://api.openai.com/v1" to client_class so these mocked tests remain independent of the supported custom-endpoint configuration.
AGENTS.md reference: AGENTS.md:L100-L100
Useful? React with 👍 / 👎.
The Responses API returns ordinary text under
output[].message.content[].output_text. Both adapters only inspect top-leveloutput_text/textitems, so standard message output becomeschoices[0].message.content = None/null, including responses containing both text and function calls.Read message content blocks and append their text in output order, matching the SDK's
output_textbehavior. The existing top-level text compatibility and tool conversion branches remain unchanged. Python sync and async clients share the converter; the JavaScript path receives the same fix.Validation with frozen dependency locks, Python 3.12.8 / OpenAI 2.41.0 and Node 26.13.0 / pnpm 10.33.0:
oai.test.ts19 passed; full offline JS selection 75 passed / 8 live cases skipped.OPENAI_BASE_URL=https://gateway.invalid/v1; the test clients explicitly use the mocked endpoint. Before that fixture correction, all ten cases failed on unmatched gateway requests.pnpm buildand the configured pre-commit hooks on all four changed files pass.git diff --checkpasses; dependency locks are unchanged.tsc --noEmitreports TS2345 in the unchangedjs/render-messages.test.ts:227. Substituting the exact base TypeScript files through an in-memory compiler host produces the same single diagnostic.The regressions cover multiple messages/blocks, mixed function calls, tool-only output and both legacy top-level formats. Python uses OpenAI/AsyncOpenAI with mocked HTTP; JS uses the SDK with MSW. No live model calls were made. The modern Python SDK emits four serialization warnings for the intentionally retained legacy top-level format controls.
Test commands and scope
pytest -q py/autoevals/test_responses_conversion.pypnpm exec vitest run js/oai.test.tspnpm buildpre-commit run --files py/autoevals/oai.py py/autoevals/test_responses_conversion.py js/oai.ts js/oai.test.tsThe full offline selections omit only the identified live-provider cases: 16 Python parameter instances and 8 JS cases. Mocked RAGAS tests remain selected. Tool-call regressions use the function-call format.