Repository navigation
fix: preserve optional tool parameters across Responses and Codex tra… - #4069
Closed
felixfoertsch wants to merge 1 commit into
Closed
felixfoertsch wants to merge 1 commit into
felixfoertsch wants to merge 1 commit into
Conversation
…nslation Default translated Chat Completions function tools to strict:false without rewriting their parameters or required arrays. Preserve strict through Codex tool normalization, which previously discarded even explicit values. Keep native Responses defaults and explicit strict:true requests intact. Add 26 regression cases for optional sessionID, absent/empty/nested required, strict handling, normalization idempotence, and streamed/replayed arguments. Live OpenCode subagent acceptance remains to be verified.
paopaonyapi-creator
pushed a commit
to paopaonyapi-creator/9router
that referenced
this pull request
Sep 14, 2026
Port five still-open decolua PRs onto v0.5.75: drop Claude <think> tags from OpenAI content (decolua#4063), keep Responses tool-output images as images (decolua#4058), preserve optional tool params / Chat strict:false (decolua#4069), skip account cooldown on request-scoped 4xx (decolua#4059), and declare Cline Solar Pro/LongCat before the o-series globs (decolua#4064). Also pin in-range patch deps (next 16.3.5, jose, marked, undici, …) and drop the stale 20127 comment in CLAUDE.md. Targeted suite 55/55; regression gate still clean (22 known fails).
Primexz
added a commit
to Primexz/9router
that referenced
this pull request
Sep 15, 2026
Merge upstream pull request decolua#4069 so optional function-tool parameters remain optional across Responses-to-Chat and Codex translation paths. The change defaults translated Chat Completions tools to strict false without rewriting schemas, preserves explicit strict values through Codex normalization, and keeps native Responses behavior intact. It also adds focused regression coverage for required fields, nested schemas, normalization, and streamed or replayed arguments. Verification performed: 39 related Vitest assertions passed across the new optional-parameter suite and existing Codex normalization and Responses custom-tool suites, npm run build completed successfully with Next.js 16.3.5, and git diff --check completed successfully.
|
Hi, just following up on this PR. I’m experiencing the same issue, and I’ve tested this PR locally — the fix works for me. Tested this patch on 9router v0.5.86 with OpenCode v2.0.15 via the Codex/Responses route. Before the patch, creating a subagent failed with Subagent session not found: ses_invalid; after rebuilding and running the patched image, creating a new subagent succeeds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve Chat Completions function-tool optionality when routing through Responses, including Codex (
cx/*). This targets the OpenCode v2subagent.sessionIDfailure: omitting the argument creates a child, while supplying it requests a resume.Two concrete defects found in 0.5.75
open-sse/translator/request/openai-responses.jsalready preservesparameters.required, but forwards an omittedfunction.strictasundefined. JSON serialization removes that field. Chat Completions is non-strict by default, whereas Responses can normalize omitted strictness into strict mode, making optional fields required.open-sse/executors/codex.js::normalizeCodexToolsrebuilds each function declaration and discardsstrict, including explicitfalseandtrue. A translator-only fix is therefore insufficient forcx/*.OpenAI documentation: https://developers.openai.com/api/docs/guides/function-calling#strict-mode
The user-reported direct-versus-routed OpenCode result is consistent with these defects. This PR does not claim a live reproduction of model behavior or OpenCode child creation.
Changes
strict: tool.function.strict ?? falsewhen translating Chat Completions function declarations.requiredarrays unchanged; do not derive required fields from property names or silently repair explicitly strict schemas.sessionIDin returned arguments. Legitimate resume IDs remain intact.Regression coverage
Adds
tests/unit/openai-responses-optional-params.test.jswith 26 cases covering:sessionID; absent and emptyrequired; nested objects, arrays, unions, and definitions; parameter-less functions.strictvalues, Chat default handling, native Responses defaults, and nested Chat tool normalization.The synthetic streaming fixtures verify transport fidelity, not actual model argument selection or OpenCode execution.
Validation performed
In the available offline environment, the same 26 test assertions were run using Node 22's native test runner against the fetched production translator/executor source and the extracted production response-conversion function. External I/O and unrelated provider configuration dependencies were replaced by isolated adapters; helper behavior was copied from the inspected source.
node --checkandgit diff --checkpassed. Final GitHub blob hashes match the locally validated files.Not run: the normal Vitest dependency graph, full repository suite/build, live Codex inference, or the OpenCode acceptance probe. Dependencies could not be installed in this environment. This PR remains a draft pending normal integration validation.
From a full checkout with dependencies installed, run:
Live acceptance still required
Using OpenCode v2 2.0.3, rerun the original identical probe through
9router/cx/gpt-5.6-solafter building and deploying this branch. Retain the direct-provider control.strict: falsefor the translated subagent function, and its originalrequiredarray does not includesessionID.rawInputlackssessionIDentirely, not merelynullor an empty string.ROUTED-SUBAGENT-OK.sessionIDcan still resume that child.No changes to OpenCode's parent/child validation are proposed. No automatic merge, deployment, or upstream issue/PR is included.