Skip to content

fix: preserve Responses reasoning stream lifecycle - #103

Open
chrisnestrud wants to merge 1 commit into
ZhiYi-R:mainfrom
chrisnestrud:fix/responses-reasoning-sse-lifecycle
Open

chrisnestrud wants to merge 1 commit into
ZhiYi-R:mainfrom
chrisnestrud:fix/responses-reasoning-sse-lifecycle

Conversation

@chrisnestrud

Copy link
Copy Markdown

Summary

Fixes the Anthropic-to-Responses reasoning stream lifecycle used by Codex before tool-call continuations.

  • Initialize the reasoning summary_text part before emitting deltas.
  • Emit reasoning text/part/item completion events with the provider signature.
  • Carry the Anthropic message ID into the Responses lifecycle.
  • Preserve signature_delta rather than treating it as a generic thinking delta.
  • Add a mocked E2E replay: Anthropic thinking + tool use → Responses output → Anthropic tool-result continuation.

Fixes #102
Refs #63
Refs #101

Validation

CGO_ENABLED=0 go test -p 1 ./...
go test -tags=e2e ./internal/e2e -run "^TestOpenAIResponseAnthropicE2E_ReasoningToolReplay$"

The complete tagged E2E suite has unrelated existing failures tracked in #101.

@chrisnestrud

Copy link
Copy Markdown
Author

Cross-reference: while diagnosing the same reported symptom I found a second,
independent defect in the replay path.

prependCachedThinking on the adapter path only inserted a thinking block for
assistant turns containing tool_use, so a conversation whose earlier assistant
turn was plain text reached the provider bare and was rejected with
The content[].thinking in the thinking mode must be passed back to the API.
Every retry re-sent the same body, so the session died rather than recovering.
Replaying a captured failing request against the provider confirmed it: the body
returns 400 as-is, and 200 once the plain assistant turn gains a thinking block
(empty or filled).

Filed as #110, fix in #111, based on main independently of this PR.

This PR is still needed for the reasoning summary lifecycle; the replay gap only
shows up once a session contains a mix of tool-call and text-only assistant
turns, which is why a short probe passes while longer sessions fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(responses): initialize reasoning summary lifecycle for Anthropic streams

1 participant