Skip to content

fix(server): show Codex and Claude thinking traces in V2 adapters - #12163

Draft
SunkenInTime wants to merge 530 commits into
pingdotgg:t3code/codex-turn-mappingfrom
SunkenInTime:devin/1789601755-v2-thinking-traces
Draft

SunkenInTime wants to merge 530 commits into
pingdotgg:t3code/codex-turn-mappingfrom
SunkenInTime:devin/1789601755-v2-thinking-traces

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

What Changed

Ports #11784 (feat(chat): show provider thinking traces) into the V2 orchestration adapters, which the v2 rewrite left behind when it deleted the v1 ProviderRuntimeIngestion / ClaudeAdapter / CodexAdapter files.

  • CodexAdapterV2: handles item/reasoning/summaryTextDelta and item/reasoning/textDelta via a second makeCodexAgentMessageDeltaCoalescer, emitting a kind: "reasoning" node + type: "reasoning" turn item (streaming: true while deltas arrive). Indexed parts (summaryIndex / contentIndex) are joined with \n\n, mirroring main's ingestion. item/completed for a reasoning item finalizes from item.summary / item.content; flushTurn runs at turn end. Summary text keeps the native item id; raw chain-of-thought (when Codex emits it) is a sibling item with id ${itemId}:raw.
  • ClaudeAdapterV2: thinking content blocks on a completed assistant SDK message become one completed reasoning item (${uuid}:thinking), emitted before the assistant text so it orders ahead of the answer. Query options now set showThinkingSummaries: true unless the thinking option is off or --thinking-display omitted is passed (same rule as main's shouldRequestClaudeThinkingSummaries).
  • apps/web/session-logic.ts: workEntryIndicatesToolNeutralStatus no longer treats a reasoning entry that has text as neutral. Without this, the completed reasoning items are persisted but filtered out of the expanded Worked group (workEntryIsVisibleInGroup), so the trace was invisible even after the adapter fix. This also un-hides completed Cursor/OpenCode/Pi/ACP V2 reasoning items, which were already emitted but hidden.

Focused tests: Codex replay transcript (summary + raw deltas, indexed separation, completion, ordering vs. final answer), Claude thinking-block projection + showThinkingSummaries option rule, and the web neutral-status rule.

Why

On t3code/codex-turn-mapping, Codex and Claude thinking traces are dropped: CodexAdapterV2 registered no item/reasoning/* handlers (despite advertising streamsReasoning: true) and ClaudeAdapterV2 ignored thinking blocks. Main's fix (052c7ae) is an ancestor of this branch but only touched v1 files that the V2 rewrite removed, so it merged as a no-op. The V2 contract (reasoning node/turn item) and the UI mapping (reasoning -> "Thinking" work entry) already existed; only the adapters (and the group visibility rule) needed the port.

Reproduction

No Codex/Claude credentials were available, so the repro drives the real web app against the repo's mock Codex app-server (apps/server/src/provider/testFixtures/codexCollabMockPeer.sh), which replays scripted notifications on turn/start.

  1. Isolated state per worktree (vp run dev --home-dir <worktree>/.t3, never ~/.t3/userdata); providers.codex.binaryPath in that .t3/userdata/settings.json pointed at codexCollabMockPeer.sh; server started with T3_CODEX_COLLAB_SCRIPT=<script.json>.
  2. Script notifications: item/started (reasoning), two item/reasoning/summaryTextDelta (summaryIndex 0 and 1), item/completed (reasoning with both summaries), then an agentMessage final answer.
  3. Pair the browser, add a scratch project, start a Codex thread, send a prompt, wait for the turn to complete, expand "Worked".
  • Expected: a Thinking row with "Weighing the options" / "Choosing the shortest path" above the final answer.
  • Actual (base f08294a11 (pre-rewrite tip of t3code/codex-turn-mapping)): only the final answer; no Thinking row; the V2 DB contains zero reasoning items.

UI Changes

Before (base f08294a11 (pre-rewrite tip of t3code/codex-turn-mapping)) After (this branch)
Before: final answer, no Thinking row After: expanded Thinking with both summaries

V2 item inspector after the fix, showing reasoning-1 completed with both summaries:

Inspector showing completed reasoning item

Verification

  • vp test run on CodexAdapterV2.test.ts, ClaudeAdapterV2.test.ts (183 passed) and apps/web/src/session-logic.test.ts.
  • tsc --noEmit for apps/server and apps/web (only pre-existing @cursor/sdk type errors in Cursor files before pnpm install; clean after).
  • vp check on the changed files (only pre-existing unused-variable warnings).
  • Computer-use before/after in the web app as described above; reasoning survives reload and appears in the V2 inspector.

Verification blockers: not tested against live Codex or Claude CLIs (no credentials on the test machine), so real streaming timing, raw textDelta content from Codex, and Claude thinking blocks from the real SDK were only covered by unit tests. Desktop/mobile not exercised; mobile renders V2 work entries through packages/client-runtime and was not changed.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (n/a)

Written by Devin (Claude) via the Devin harness.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 17, 2026
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 2 times, most recently from d61550b to e6cb2b5 Compare September 17, 2026 06:46
Prune stale git worktree registration and recreate the saved branch at the saved path before provider startup. Recovery remains best effort so normal provider errors still report when repair is impossible.

Finding: R10

Implemented by GPT-5.6 Sol in Codex.
Intercept /feedback in web and mobile, show the upload result and feedback ID in the thread, and block duplicate submissions while an upload is active.

Audit: R12
R02: Append persisted paths for every uploaded file on provider sends and steering while reserving native image payloads for supported images.
Classify markdown image sources and request environment-scoped asset URLs for workspace files while leaving ordinary web images direct.

Audit: R17
Normalize drive-path links and image sources before sanitization so file chips and signed workspace images receive usable paths.

Audit: R18
R07: Project Codex last-turn and Claude assistant context usage, and retain the latest usage when terminal provider-turn updates omit it.
Keep ordinary file-chip clicks in the in-app preview while restoring modifier-click editor opening, configured editor labels, remote gating, and reveal-in-file-manager actions.

Audit: R19
Use the owning thread or pull request environment for editor, shell, and remote-open actions instead of whichever environment is active. Add a multi-environment regression test for the action hooks.

Audit: R20

Implemented by GPT-5.6 Sol with Codex.
Advertise and validate an explicit orchestration protocol before clients open RPC sessions. Announce the same protocol on WebSocket upgrades so hosts reject older clients before request decoding while preserving existing auth and relay parameters.

Audit: D03

Implemented by GPT-5.6 Sol with Codex.
Document which thread metadata and transcript data migrate, which runtime history does not, and how the fresh provider continuation uses the latest 32,000 characters. Add a safe read-only recovery procedure without claiming an export API.

Audit: D02

Written by GPT-5.6 Sol with Codex.
Explain the eligible timeline items, whitespace-normalized 240-character prefixes, omitted tail risk, and practical preparation for provider or fork handoffs. Distinguish this rule from the legacy import's 32,000-character transcript suffix.

Audit: D04

Written by GPT-5.6 Sol with Codex.
Remove obsolete implementation plans and the probe write marker so temporary work artifacts no longer ship with the repository.

Audit: H01

Implemented by GPT-5.6 Sol with Codex.
R14: Hold idle completion through prompt admission, reconcile status only for the current admission generation, and invalidate admission before abort.
Project AskUserQuestion as a structured user-input runtime request and return keyed answers to the Claude SDK instead of routing the tool through generic approval.

Finding: R04

Model: GPT-5.6 Sol via Codex
Translate TodoWrite and ExitPlanMode tool input into canonical todo-list and proposed-plan artifacts so every client can render Claude planning state.

Finding: R05

Model: GPT-5.6 Sol via Codex
Load at most one turn-item page per thread in a fork lineage before decoding, keyed by the stable history cursor. Restrict message, plan, and handoff reads to that page plus live actionable state so cold opens and older-page requests no longer decode complete historical tables.

Finding: P01

Implemented by GPT-5.6 Sol in Codex.
Budget the serialized bounded projection after retaining live control state. Cap historical control arrays and large plan or handoff details only on the bounded route; the full thread-detail route remains available for complete text.

Finding: P02

Implemented by GPT-5.6 Sol in Codex.
Pass the automatic compaction window to Claude and route resume-return dialogs through structured user input so users can compact, continue, or permanently dismiss the prompt.

Finding: R06

Model: GPT-5.6 Sol via Codex
Permit the canonical orchestration protocol header in browser API preflights so cross-origin web and desktop clients can negotiate compatibility while retaining authorization and DPoP headers.

Finding: D03

Model: GPT-5.6 Sol via Codex
Merge terminal provider updates with stored context usage before replacing the SQLite payload. Keep newer usage reports authoritative and verify the persisted projection after reload.

Finding: R07 follow-up

Model: GPT-5.6 Sol via Codex
Keep typed plan and todo records distinct from generic tool events, activate captured plans, and supersede older planning state within the owning thread. Ignore nested todo snapshots for the parent and retain identity across duplicate SDK messages.

Finding: R05 follow-up

Model: GPT-5.6 Sol via Codex
R04 follow-up

Convert client multi-select answer arrays to the comma-separated string shape required by the pinned Claude SDK while preserving single-select strings.

Implemented by GPT-5.6 Sol via Codex.
Stale cached user and status events could admit and complete a newly submitted OpenCode prompt. Generate the native message ID before submission and only advance admission when that exact message is observed.

Finding: R14

Implemented by GPT-5.6 Sol with Codex.
R12 follow-up

Insert persistent feedback blocks by their timestamp within the canonical timeline while preserving projected row order. Keep real optimistic sends appended and suppress duplicate local messages already committed by the server.

Implemented by GPT-5.6 Sol via Codex.
R20 follow-up

Give inspector reasoning markdown its projected source thread and retain the explicit environment fallback for proposed plans without a thread reference. Workspace links and images now resolve through their owning environment after removal of the active-environment fallback.

Implemented by GPT-5.6 Sol via Codex.
Read the inclusive cursor, a full history page, and a look-behind row so older history does not terminate after one page.

Finding: P01 pagination termination

Model: GPT-5.6 Sol via Codex
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch from a6b73de to 3d45b30 Compare September 17, 2026 19:51
SunkenInTime and others added 2 commits September 17, 2026 19:59
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1789601755-v2-thinking-traces branch from 3768fd3 to 4fab841 Compare September 17, 2026 20:01
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 16 times, most recently from 5ff0a93 to fd8ea2f Compare September 19, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants