Skip to content

Emit Anthropic thinking blocks from reasoning channel #18

@HXYerror

Description

@HXYerror

Part of #1. Pairs with #6 (chat-completions side) and #7 (responses side).

Goal

Today the Anthropic adapter actively suppresses thinking block output. With reasoning models live (gpt-5, o3, codex…), Anthropic clients (Claude Code, Anthropic SDK) lose all visibility into the model's chain of thought. We should emit thinking blocks whenever the upstream provides reasoning material.

Current state

src/routes/messages/non-stream-translation.ts:305 says verbatim:

// GitHub Copilot doesn't generate thinking blocks, so we don't include them in responses

That comment is stale as of the GPT-5 / codex rollout. Additionally the thinking_delta and signature_delta types declared in src/routes/messages/anthropic-types.ts:145–146 are dead code — no producer in the repo.

On the input side, thinking blocks are flattened into plain text:

  • src/routes/messages/anthropic-types.ts:21–24thinking? payload field is silently ignored
  • src/routes/messages/non-stream-translation.ts:146–154, :195–211 — inbound thinking content blocks → text

Tasks

Acceptance criteria

  • Claude Code shows the model's thinking inline when running against gpt-5 / o3 / gpt-5.3-codex
  • Two-turn flow round-trips thinking.signature byte-exact (no upstream verification errors)
  • No regression on tests in tests/anthropic-response.test.ts

File pointers

  • src/routes/messages/non-stream-translation.ts:305 — remove suppression
  • src/routes/messages/anthropic-types.ts:21–24, 145–146
  • src/routes/messages/stream-translation.ts — state machine

Metadata

Metadata

Assignees

No one assigned

    Labels

    anthropicAnthropic Messages API compatibilityreasoningReasoning / thinking / encrypted_content

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions