Commit Graph
1 Commits
Author SHA1 Message Date
yetone a21a2b54f1 gateway: a Codex title the model was cut short on before any text goes back as response.incomplete with its reason and usage, not as a completed reply with nothing in it (#1466, Edward4226)
codexTitle read the title model's reply with compactReply, which kept
the output and usage of response.completed and response.incomplete alike
and dropped how it ended, and writeTitleReply always wrote status
"completed". A title cut short at max_output_tokens (all of it spent
reasoning) reached Codex as a finished reply with output [].

What changed:
- compactResult keeps the response's status and incomplete_details
  (from the terminal event's response, or its type).
- codexTitle: when no title can be read and the reply was incomplete,
  writeTitleEnd streams response.created then one response.incomplete,
  status "incomplete", the vendor's incomplete_details and usage. A
  title read from the reply still completes with it; Titles off still
  completes with nothing (writeTitleReply is writeTitleEnd "completed").
- Compaction (codexCompact) is left as it was: a summary cut short with
  text in it is still used.

Codex: codex-rs/codex-api/src/sse/responses.rs takes response.incomplete
with a reason other than interrupted/content_filter as a stream error
("Incomplete response returned, reason: max_output_tokens"), which
core/src/responses_retry.rs retries up to the provider's
stream_max_retries; then the hidden title turn fails and
tui/src/temporary_structured_request.rs sets no title, as it did for
the empty completed reply. This is what Codex does when its own backend
answers so.

Run:
- TestCodexTitleIncompleteStaysIncomplete (Responses upstream, #1466's
  two-field schema) and TestCodexTitleIncompleteFromChat (Chat upstream,
  finish_reason length) fail on the old code (one response.completed,
  status completed) and pass now; the same test's whole title under the
  same schema completes. Existing TestCodexTitle*/TestTitle* pass.
- gofmt -l clean; go vet -tags nogui ./internal/gateway on darwin,
  GOOS=linux, GOOS=windows.
- go test -tags nogui -count=1 ./... under a temp HOME: all ok (with
  ./internal/gateway and ./ rerun after this change).
- Real use: the built binary's gateway in a sandbox HOME with only the
  owner's DeepSeek provider, the issue's title request on
  deepseek-flash. max_output_tokens 16: old response.completed,
  output [], status completed; new one response.incomplete, reason
  max_output_tokens, usage 16 reasoning tokens. 2048: a title and
  description, response.completed, before and after.
2026-10-10 14:14:47 +08:00