Hi maintainer(s),
When reverse-proxying streaming Tool Call responses for GLM-5.1 (or the CodeBuddy model family) via Auth Files, the emitted SSE chunks severely violate the standard OpenAI specifications:
Redundant Header Repetition: According to the OpenAI spec, id, type, and name should only be sent once in the initial chunk (index: 0). Subsequent chunks must only return the incremental delta of function.arguments. Currently, the proxy echoes the complete header in every single chunk.
Inclusion of Non-standard Fields: The stream injects private/undocumented keys such as reasoning_content, function_call, and extra_fields.
Malformed Final Chunk: In the closing chunk where finish_reason: "tool_calls", the delta field should be an empty object {}.
Because strict schema-validating clients (like the official GitHub Copilot extension) cannot parse these malformed payloads, the connection gets dropped immediately with the error: Sorry, no response was returned.
Suggested Fix Logic:
When emitting SSE chunks for tool calls, please maintain a lightweight state:
let hasSentToolHeader = false;
// Before stringifying the chunk:
if (chunk.choices?.[0]?.delta?.tool_calls?.[0]) {
let tc = chunk.choices[0].delta.tool_calls[0];
if (!hasSentToolHeader) {
hasSentToolHeader = true; // Let id, type, name pass for chunk 0
} else {
delete tc.id;
delete tc.type;
if (tc.function) delete tc.function.name; // Keep only arguments delta
}
}
// Strip proprietary dialects globally
delete chunk.choices?.[0]?.delta?.reasoning_content;
delete chunk.choices?.[0]?.delta?.function_call;
delete chunk.choices?.[0]?.delta?.extra_fields;
Hi maintainer(s),
When reverse-proxying streaming Tool Call responses for GLM-5.1 (or the CodeBuddy model family) via Auth Files, the emitted SSE chunks severely violate the standard OpenAI specifications:
Redundant Header Repetition: According to the OpenAI spec, id, type, and name should only be sent once in the initial chunk (index: 0). Subsequent chunks must only return the incremental delta of function.arguments. Currently, the proxy echoes the complete header in every single chunk.
Inclusion of Non-standard Fields: The stream injects private/undocumented keys such as reasoning_content, function_call, and extra_fields.
Malformed Final Chunk: In the closing chunk where finish_reason: "tool_calls", the delta field should be an empty object {}.
Because strict schema-validating clients (like the official GitHub Copilot extension) cannot parse these malformed payloads, the connection gets dropped immediately with the error: Sorry, no response was returned.
Suggested Fix Logic:
When emitting SSE chunks for tool calls, please maintain a lightweight state: