Skip to content

Stream the model's thinking to the editor as agent_thought_chunk - #635

Merged
FMXExpress merged 1 commit into
mainfrom
claude/pasclaw-desktop-plan-uapzcp
Nov 12, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/pasclaw-desktop-plan-uapzcp

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

An editor under pasclaw acp now shows the model's thinking as it is written, separate from the reply, in the place ACP has for it (agent_thought_chunk).

Changes

  • New chunk kind. TStreamChunk gains a thinking kind: the model's reasoning as it streams. It is never part of Content.
  • Anthropic. thinking_delta pieces are passed on as thinking. They're still kept in their block, with the signature, for a pause_turn continuation.
  • OpenAI-compatible. A reasoning model's delta.reasoning_content (DeepSeek, vLLM) or delta.reasoning (OpenRouter) is passed on as thinking and kept out of the reply.
  • Tool loop: TToolLoopConfig.OnThoughtDelta, next to OnTextDelta, with each round's first piece marked.
    • Either callback makes a round stream.
    • With OnThoughtDelta alone, the round's text still goes to OnText whole.
    • Thinking never reaches OnText or the history.
  • ACP. TACPTurn.ThoughtDelta sends agent_thought_chunk. A later round's thinking opens a new paragraph, as its text does.
  • --thinking. pasclaw acp already accepted --thinking low|medium|high, which Anthropic thinking needs. It's now listed in the usage text and in docs/acp.md.

Other readers of stream chunks are unaffected. The gateway's streamed responses and the stream-reliability watcher treat only text chunks as output. A thinking chunk still counts as activity for the idle watcher, so a long thinking phase isn't mistaken for a stall.

Tests

  • make test-streaming:
    • Anthropic thinking chunks;
    • reasoning_content and reasoning;
    • OnThoughtDelta per round, with first pieces marked and the text stream unchanged;
    • OnThoughtDelta alone streaming the round, with its text still going to OnText.
  • make test-acp: agent_thought_chunk kept apart from the reply, with a paragraph per round in each.
  • make test-acp-e2e: Anthropic thinking blocks (thinking_delta pieces plus a signature_delta) and a compatible server's reasoning_content reach the editor as thought chunks, apart from the reply and not saved in the session.
  • Revert checks: each of the 6 changes was reverted, and a test failed every time. Two needed a rerun, because a same-second restore left a stale compiled unit; with a forced recompile both are caught.
  • Live, through the official ACP SDK client, with me as the model behind an Anthropic-format bridge and --thinking low:
    • the request carried thinking: enabled;
    • my thinking reached the editor as agent_thought_chunks about 100 ms apart, then the reply as message chunks about 150 ms apart;
    • all 48 messages validated against the ACP schema;
    • the thinking was not in the saved session.
  • Full make test passes on FPC 3.2.2. Delphi (dcc64) isn't available here.

Generated by Claude Code

An editor under `pasclaw acp` now shows the model's thinking as it is
written, apart from the reply, in the place ACP has for it.

- TStreamChunk gains the "thinking" kind: the model's reasoning as it
  streams, never part of Content.
- Anthropic: thinking_delta pieces are passed on as thinking (still kept
  in their block, with the signature, for a pause_turn continuation).
- OpenAI-compatible: a reasoning model's delta.reasoning_content
  (DeepSeek, vLLM) or delta.reasoning (OpenRouter) is passed on as
  thinking and kept out of the reply.
- Tool loop: TToolLoopConfig.OnThoughtDelta, beside OnTextDelta, each
  round's first piece marked. Either one makes a round stream; with
  OnThoughtDelta alone the round's text still goes to OnText whole.
  Thinking never reaches OnText or the history.
- ACP: TACPTurn.ThoughtDelta sends agent_thought_chunk, a later round's
  thinking opening a new paragraph, as its text does.
- `pasclaw acp` lists --thinking low|medium|high in its usage and docs;
  it already took it (Anthropic thinking is off without it).

The gateway's streamed responses and the stream-reliability watcher read
only text chunks as output; a thinking chunk still counts as activity
for the idle watcher, which keeps a long thinking phase from looking
stalled.

Tests: streaming_tests (Anthropic thinking chunks, reasoning_content and
reasoning, OnThoughtDelta per round, OnThoughtDelta alone streaming);
acp_tests (agent_thought_chunk apart from the reply, a paragraph per
round in each); acp_e2e_test (Anthropic thinking blocks and a compatible
server's reasoning_content reach the editor as thought chunks, apart
from the reply and not saved). Each change was reverted to confirm a
test fails without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T23:51:34.410875Z 7dc176a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@FMXExpress
FMXExpress merged commit 53430b0 into main Nov 12, 2026
FMXExpress pushed a commit that referenced this pull request Nov 13, 2026
…piled

FPC decides a unit is up to date by comparing its source's time with
what the .ppu recorded, to the second. A source rewritten in the same
second its unit was compiled -- an edit straight after a build, a
checkout, a tool that edits and rebuilds in one go -- looks unchanged,
and the build links the old code without a word. It bit the revert
checks for #635: a restored provider unit stayed compiled from the
reverted version, and later builds kept failing on a change no longer
in the source.

scripts/sweep-stale-units.sh runs once per make invocation, before any
recipe: it deletes the .ppu/.o of every source under src changed since
the previous run started (find -newer a marker file compares to the
nanosecond, GNU and BSD find alike), then moves the marker to now. A
unit FPC would have rebuilt anyway costs nothing extra; one it would
have kept is the bug. The Makefile already gives $(BIN) every source as
a prerequisite for the same reason (a stale binary once reached a
benchmark run); this closes FPC's own gap.

test-stale-units (in make test) pins it with fixed timestamps, the same
on every run: a unit compiled from a source stamped 00:00:00.5, the
source rewritten at 00:00:00.9 after the run's marker at 00:00:00.2.
FPC alone keeps the old code; after the sweep the edit is built; a
source older than the marker keeps its unit. With a sweep that does
nothing the test fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
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.

2 participants