Repository navigation
fix(server): normalize Codex Responses tool-call follow-ups - #260
Merged
Merged
Conversation
Codex CLI could miss tool calls or loop on follow-up turns when the native server handled Qwen Responses output too literally. Qwen can emit bare `<function=...>` XML without an outer `<tool_call>` wrapper, and Codex sends follow-up `function_call` / `function_call_output` items that must be replayed back into the prompt as assistant/tool turns. Handle bare `<function=` and `<tool_code>` openers in the SSE emitter so the native Responses path still converts Qwen tool XML into Responses `function_call` events. Normalize Responses follow-up items in `http_server.cpp` by replaying prior function calls as assistant tool-call XML, mapping `function_call_output` items to tool turns, and preserving the system / developer prompt folding used by Codex requests. Add regression coverage for both failures: bare-function Responses tool calls in the emitter and the Responses follow-up normalization path in the native server flow. Compile `http_server.cpp` into `test_server_unit` so the regression test exercises the production normalization logic directly. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="dflash/src/server/http_server.cpp">
<violation number="1" location="dflash/src/server/http_server.cpp:37">
P2: parse_responses_arguments silently swallows JSON parse errors, returning an empty object and losing malformed argument data without any log or error</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| return buf; | ||
| } | ||
|
|
||
| json parse_responses_arguments(const json & item) { |
Contributor
There was a problem hiding this comment.
P2: parse_responses_arguments silently swallows JSON parse errors, returning an empty object and losing malformed argument data without any log or error
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At dflash/src/server/http_server.cpp, line 37:
<comment>parse_responses_arguments silently swallows JSON parse errors, returning an empty object and losing malformed argument data without any log or error</comment>
<file context>
@@ -34,6 +34,125 @@ static std::string generate_id(const char * prefix) {
return buf;
}
+json parse_responses_arguments(const json & item) {
+ if (!item.contains("arguments")) return json::object();
+ const auto & arguments = item["arguments"];
</file context>
easel
added a commit
to easel/lucebox-hub
that referenced
this pull request
May 23, 2026
Pulls in PR Luce-Org#260 (howard0su): fix(server): normalize Codex Responses tool-call follow-ups, which improves the sse_emitter THINK_OPEN/CLOSE extraction parser. Also picks up frequency/presence penalty sampling, test tightening, and gemma4 HIP runtime fixes. # Conflicts: # dflash/src/server/http_server.cpp
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.
Codex CLI could miss tool calls or loop on follow-up turns when the native server handled Qwen Responses output too literally. Qwen can emit bare
<function=...>XML without an outer<tool_call>wrapper, and Codex sends follow-upfunction_call/function_call_outputitems that must be replayed back into the prompt as assistant/tool turns.Handle bare
<function=and<tool_code>openers in the SSE emitter so the native Responses path still converts Qwen tool XML into Responsesfunction_callevents. Normalize Responses follow-up items inhttp_server.cppby replaying prior function calls as assistant tool-call XML, mappingfunction_call_outputitems to tool turns, and preserving the system / developer prompt folding used by Codex requests.Add regression coverage for both failures: bare-function Responses tool calls in the emitter and the Responses follow-up normalization path in the native server flow. Compile
http_server.cppintotest_server_unitso the regression test exercises the production normalization logic directly.