Remove all implementation specific fields from streaming chunks and "error"
I'm using OpenAI's .NET and Go SDKs with Foundry Local 0.7.120. When using Chat Completion streaming, Foundry Local (still) adds a number of non-standard fields to each streaming chunk:
{
"model": "qwen2.5-1.5b-instruct-generic-gpu:3",
"choices": [
{
"delta": {
"role": "assistant",
"content": " breath",
"name": null,
"tool_call_id": null,
"function_call": null,
"tool_calls": []
},
"message": {
"role": "assistant",
"content": " breath",
"name": null,
"tool_call_id": null,
"function_call": null,
"tool_calls": []
},
"index": 0,
"finish_reason": null,
"finish_details": null,
"logprobs": null
}
],
"usage": null,
"system_fingerprint": null,
"service_tier": null,
"created": 1759756514,
"CreatedAt": "2025-10-06T13:15:14+00:00", // Remove
"id": "chat.id.1",
"StreamEvent": null, // Remove
"IsDelta": false, // Remove
"Successful": true, // Remove
"error": null, // See below
"HttpStatusCode": 0, // Remove
"HeaderValues": null, // Remove
"object": "chat.completion.chunk"
}
The Go SDKs v1/v2/v3 break because of the presence of the error field. The SDK uses the same SSE stream implementation for both the Chat Completion and the Response API. While error is not defined for Chat Completion chunks, it is defined for Response chunks. The SSE stream decoder scans for the presence of an error field anywhere in a chunk, regardless of whether it's a Chat Completion or a Response chunk. Long story short, sending error as part of a Chat Completion chunk inevitably triggers the error handling meant for Response chunks in the Go SDK. If Foundry Local was to support the Response API, this needed to be changed for the same reason.
The other fields are at least not harmful for now, but since they are non-standard, they just bloat the response and might trigger JSON decoding bugs in future SDK versions.
Foundry Local 0.8.101 no longer emits error, but introduces an even more serious bug.