6 Commits

Author SHA1 Message Date
Xubin Ren
4445fcc8b9 refactor(cli): localize reasoning buffer state 2026-05-18 01:34:08 +08:00
Xubin Ren
3fab736262 fix(cli): keep trace output under assistant header
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 09:13:16 +00:00
Xubin Ren
352aaf0627 refactor(reasoning): unify reasoning extraction across providers
Reasoning surfacing was split across three branches in runner.py plus
two separate streaming buffers (loop hook and runner progress stream),
with three independent display-side gates in the CLI. This collapsed
the policy into one source of truth and fixed two real bugs:

- Structured `reasoning_content` was suppressed whenever the answer was
  streamed, because the runner gated emission on `streamed_content`.
  Providers don't stream `reasoning_content`; it only arrives on the
  final response, so the answer stream and the reasoning channel are
  independent. Added `streamed_reasoning` to `AgentHookContext` to track
  the right bit.
- `channels.showReasoning` was subordinated to `sendProgress`. They are
  orthogonal — turning off progress streaming shouldn't silence
  reasoning. Reworked the CLI gates accordingly.

Single-helper consolidation:

- `extract_reasoning(reasoning_content, thinking_blocks, content)`
  returns `(reasoning_text, cleaned_content)` with a defined fallback
  order: dedicated field → Anthropic thinking_blocks → inline
  `<think>`/`<thought>` tags. Models that expose none of these
  short-circuit to `(None, content)` — zero overhead.
- `IncrementalThinkExtractor` replaces the ad-hoc `emit_incremental_think`
  function and its hand-rolled "emitted cursor" state in both the loop
  hook and the runner progress stream.

Also documented the new `showReasoning` channel option in
docs/configuration.md and noted its independence from sendProgress.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 17:14:19 +00:00
Flinn Xie
3a27af0018 feat(cli): display model reasoning content during streaming
Add show_reasoning config (default: False) to display model
thinking/reasoning content in the TUI during streaming.  Reasoning
is emitted via a new emit_reasoning hook on AgentHook, gated by the
channels config.  Display uses ✻ prefix with dim italic styling.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 01:02:49 +08:00
Flinn Xie
d630ac90d1 fix(cli): prevent TUI content duplication via transient Live and renderer routing
Route progress output through the Live's render hook to fix cursor
misalignment that caused content duplication.  The root cause was that
progress/reasoning output used a separate Console instance, bypassing
Rich Live's process_renderables hook.  Also fixes pre-existing issue
where multiple headers printed per agent turn.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 01:02:49 +08:00
Xubin Ren
66682eb46f test(cli): cover retry-wait interactive routing
Keep provider retry wait messages on the interactive progress path so they do not fall through as assistant responses.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-03 22:59:08 +08:00