Skip to content

Capture and display reasoning/thinking tokens #133

Description

@louismorgner

Summary

Some models return extended thinking / chain-of-thought tokens (e.g., Claude with extended thinking enabled). The native runtime currently silently drops these. They should be captured in session state and optionally displayed.

What OpenCode does

OpenCode processes reasoning-start/delta/end stream events, persists reasoning parts to the database, and provides a /thinking toggle to show/hide them in the TUI.

Proposed implementation

  • In mergeStreamChunk() (openrouter.go), detect and accumulate reasoning content from stream deltas
  • Store reasoning tokens in the message alongside content (e.g., a Reasoning field on the Message struct)
  • Persist in state.json for debugging and replay
  • Emit reasoning as a separate event type in session events.jsonl
  • Surface via toc runtime watch and Conductor UI

Priority

P1 — important for debugging agent behavior and supporting reasoning-heavy models

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions