A truncated streamed reply is accepted as a complete answer
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Start with internal/provider/sse.go:129 and internal/provider/client.go:1741, then run the deterministic TestAStreamCutBeforeItsEndIsNotAnAnswer test. Compare it with TestStreamedTextAnswerCarriesNoToolCalls and the cut/hold stub.py scenarios. Done means premature EOF is treated as a stream failure, partial text is not finalized, terminal-frame streams still succeed, and the manual plus invalidates coverage are updated.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Seen on dev@debffabf6.
What happened
A stream that sends a content delta and then closes without finish_reason or [DONE] is returned as a complete answer. In the 2026-09-24 hand test, the chat finalized Partial ans. The same happened on #1410 and its dev base.
Replication
Deterministic (no model). Save as internal/provider/stream_cut_test.go and run go test ./internal/provider -run TestAStreamCutBeforeItsEndIsNotAnAnswer -count=1:
package provider
import (
"context"
"net/http"
"testing"
)
// A stream that ends with neither a finish_reason nor [DONE] was cut; it is not an answer.
func TestAStreamCutBeforeItsEndIsNotAnAnswer(t *testing.T) {
handler := http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
writer.Header().Set("Content-Type", "text/event-stream")
_, _ = writer.Write([]byte(`data: {"choices":[{"index":0,"delta":{"content":"Partial ans"}}]}` + "\n\n"))
})
client, err := NewClient(Config{
APIKey: "k", BaseURL: "http://provider.test", Model: "sim/model", HTTPClient: handlerClient(handler),
})
if err != nil {
t.Fatal(err)
}
ctx := WithStreamObserver(context.Background(), func(StreamEvent) {})
response, err := client.CompleteWithMessages(ctx, userMessages("hi"))
if err == nil {
t.Fatalf("a stream cut before its end was returned as a complete answer: %q", response.Text())
}
}
Today it fails with a stream cut before its end was returned as a complete answer: "Partial ans". The existing TestStreamedTextAnswerCarriesNoToolCalls, whose stream ends with finish_reason:"stop" and [DONE], is the control.
Through the real door (no model). This stub answers every request with one chunk and closes:
# stub.py: a provider whose every reply is one content chunk.
# python3 stub.py cut -> then the connection closes (no finish_reason, no [DONE])
# python3 stub.py hold -> then the connection stays open for ten minutes
import json, sys, time
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
MODE = sys.argv[1]
MODEL = "deepseek/deepseek-v4-flash"
class H(BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1"
def log_message(self, *a): pass
def do_GET(self): # the model listing
b = json.dumps({"object": "list", "data": [{"id": MODEL, "object": "model"}]}).encode()
self.send_response(200); self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(b))); self.end_headers(); self.wfile.write(b)
def do_POST(self):
self.rfile.read(int(self.headers.get("Content-Length", "0")))
self.send_response(200); self.send_header("Content-Type", "text/event-stream")
self.send_header("Connection", "close"); self.end_headers()
chunk = {"id": "c", "object": "chat.completion.chunk", "model": MODEL,
"choices": [{"index": 0, "delta": {"content": "Partial ans"}, "finish_reason": None}]}
self.wfile.write(("data: " + json.dumps(chunk) + "\n\n").encode()); self.wfile.flush()
if MODE == "hold": time.sleep(600)
self.close_connection = True
srv = ThreadingHTTPServer(("", 0), H)
print("http://0.0.0.0:%d/v1" % srv.server_address[1], flush=True)
srv.serve_forever()
export CODEAF_HOME=$(mktemp -d) HOME=$(mktemp -d) OPENROUTER_API_KEY=<any non-empty value>
U=$(mktemp); python3 stub.py cut > "$U" & sleep 1
R=$(mktemp -d) && git -C "$R" init -q && cd "$R"
CODEAF_BASE_URL="$(cat "$U")" codeaf chat --no-host
Send reply with the word OK. Today the chat settles Partial ans as the reply.
Where
internal/provider/sse.go:129 returns EOF at transport close; internal/provider/client.go:1741 breaks its stream loop on that EOF even when no terminal marker was seen.
The fix
Track terminal completion separately from transport EOF. Treat a premature close as a cut eligible for the existing retry policy; do not journal the partial text as a finished answer.
Acceptance
- e2e:
codeaf chatagainst thecutstub above (or anhttptest.NewServerstream in the tagged suite) that closes after one delta does not finalizePartial ans; the terminal-frame control does. - Unit: EOF with and without
finish_reasonor[DONE]has distinct outcomes. - Update the stream-failure manual and add the former EOF acceptance to
invalidates.
- Vorherrschende Sprache
- Go
- Sterne
- 115
- Forks
- 14
- Ø Merge
- 15 Std. 56 Min.
- Gemergte PRs (30 T.)
- 231
Entwicklungsumgebung
Die Einrichtungsdateien dieses Projekts haben wir noch nicht geprüft. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Agent-Field/CodeAF
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Agent-Field/CodeAF#1841 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:chat bug sev:papercut
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Agent-Field/CodeAF#1805 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:session bug sev:papercut
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Agent-Field/CodeAF#1779 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:session bug sev:papercut
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Agent-Field/CodeAF#1768 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:chat bug sev:papercut
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Agent-Field/CodeAF#1742 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in Agent-Field/CodeAF
Ähnliche Issues
-
[Bug]: message-level cache_control on chat messages is dropped, so Anthropic prompt caching never triggersEvtl. vergeben @Atharva-Kanherkar hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
eugenioenko/ttt#1000 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug needs-acceptance wg/developer-experience-ecosystem
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
vllm-project/semantic-router#5249 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Billionmail/BillionMail#389 ·
-
在“产品文档”下拉列表,增加“探索”频道Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
DaoCloud/DaoCloud-docs#7489 ·
Maintainer antworten meist innerhalb von 1 Tag