Files
Mason Daugherty 457ac435e1 feat(code): optionally show visible reasoning (#5887)
Related: #1117

- add a default-off `display.show_reasoning` preference with env, TOML,
and `--show-reasoning` support
- render canonical provider-visible reasoning separately in headless
stderr and collapsible TUI rows
- preserve reasoning/text ordering across streaming, virtualization, and
checkpoint restore while suppressing nested and opaque reasoning

## Turning it on

Off by default. Three ways in, all resolved at launch:

| Surface | Value |
| --- | --- |
| CLI | `--show-reasoning` |
| Env | `DEEPAGENTS_CODE_SHOW_REASONING=1` |
| config.toml | `[ui] show_reasoning = true` |

The CLI flag outranks the env var, which outranks the persisted config
value. There is no runtime toggle, so a session decides once at startup.
`--show-reasoning` is listed in `--help` and advertised by a startup
tip.

## Headless

Reasoning goes to stderr under a one-time `Reasoning:` heading per
phase, so `-p` output stays pipeable: the answer alone reaches stdout,
and reasoning is never accumulated into the final response. A phase is
closed by the next text block, tool call, or round boundary, which is
what keeps the heading from gluing onto the answer.

```console
$ dcode -p "where does my config live?" --show-reasoning
Your config lives at ~/.deepagents/config.toml.

$ dcode -p "where does my config live?" --show-reasoning 2>&1
Reasoning:
The user wants the config path. I should read it rather than guess.
Your config lives at ~/.deepagents/config.toml.
```

Independent of `--no-stream`: reasoning is written as it arrives even
when the answer is buffered.

## TUI

Reasoning streams into its own muted row, expanded, then collapses to a
`Reasoning` header once the phase ends so the answer is not pushed off
screen. Click the header or press Ctrl+O to reopen it; that state
survives transcript virtualization and thread restore. Provider text
renders as plain content, never as Textual markup or markdown, so it
cannot inject styling into the transcript. Subagent reasoning stays out
of the main transcript, and opaque blocks (`non_standard`, redacted
thinking) are skipped.

Made by [Open
SWE](https://openswe.vercel.app/agents/70049dde-4f1e-5c46-b2fd-d329629b11e2)

## References
- Plan:
https://openswe.vercel.app/agents/eba258eb-4008-5322-97df-c43b607fca26/plan

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-08-27 23:19:31 -04:00
..