Skip to content

feat(cli): add /thinkback to review model thinking blocks#159

Merged
emal-avala merged 3 commits intomainfrom
feat/cmd-thinkback
Apr 22, 2026
Merged

feat(cli): add /thinkback to review model thinking blocks#159
emal-avala merged 3 commits intomainfrom
feat/cmd-thinkback

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Adds `/thinkback` — surfaces the model's thinking blocks from a recent turn so users can review reasoning after the fact.

  • `/thinkback` — most recent turn's thinking blocks
  • `/thinkback ` — nth most recent turn (1 = latest)
  • Walks `state.messages` for `ContentBlock::Thinking`; skips user messages and non-thinking blocks
  • Errors cleanly when there's no thinking in the session or `n` exceeds the count

Why

Extended thinking is enabled in agent-code (interleaved-thinking beta flag), and blocks are persisted in conversation history. But once they scroll off the terminal, they're effectively invisible — there was no way to review why the model went down a specific path. This command closes that loop.

Test plan

  • `cargo fmt --all` clean
  • `cargo check` passes
  • `cargo clippy --no-deps` clean
  • `cargo test --bin agent commands::tests::thinking_walker_skips_user_messages_and_non_thinking_blocks` passes (verifies it picks thinking blocks from assistant messages only and skips messages without thinking)
  • Manual: after a turn with thinking, `/thinkback` prints the thinking text
  • Manual: `/thinkback 99` in a short session prints a clear "only N turn(s)" message
  • Manual: `/thinkback` in a fresh session prints "No thinking blocks in this session yet."

`/thinkback` prints the most recent assistant turn's thinking blocks
(when the model used extended thinking). `/thinkback <n>` walks back
N turns, where 1 is the latest.

Useful for debugging why the model went down a particular path —
previously thinking blocks were rendered once during streaming and
then invisible. They're still in the conversation history, this
just surfaces them.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit 94e23d1 into main Apr 22, 2026
13 of 14 checks passed
@emal-avala emal-avala deleted the feat/cmd-thinkback branch April 22, 2026 23:33
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.

1 participant