Skip to content

feat(fork): answer earlier Chat-mode messages in sub-threads - #250

Merged
orbitingflea merged 1 commit into
mainfrom
feat/chat-steer-reply-in-thread
Nov 22, 2026
Merged

orbitingflea merged 1 commit into
mainfrom
feat/chat-steer-reply-in-thread

Conversation

@orbitingflea

@orbitingflea orbitingflea commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

This pull request lets Chat-mode agents answer an earlier main-list message in its sub-thread.

改了什么行为

Behaviour change: yes, web and desktop Chat-mode users see answers to earlier main-list messages in sub-threads.

Before, send_to_user refused answers to earlier main-list messages. Now an answer to the latest message stays in the main list, and a separate answer to an earlier one shows in its sub-thread under a reply line ("1 reply"). If a later mid-turn message is not yet confirmed as read, the first call to answer an earlier one is refused once and returns it in full.

Why

Users sometimes send two separate questions in a row in Chat mode. Putting the earlier answer in its sub-thread keeps each answer under its question and the main list ordered.

Checks

  • Unit tests cover the fold, read check, send_to_user, replace_send_to_user, user view, and web summary; vp run check:changed passes.
  • Checked in a dev server on web (desktop and phone) and CLI user view. The earlier answer shows under a reply line and the later one stays in the main list.
  • No repo eval covers Chat mode yet, so none ran for the model-facing text.

How to undo

Revert the commit; no stored data changes, and existing threads get the old rules again when the rules version reverts.

Details

Behaviour details:

  • Updated Chat-mode rules (sent once per thread) tell the agent to give one combined answer to the latest message for the same topic, or answer a separate earlier topic in its sub-thread and the latest one in the main list. Bumping the rules version delivers the new rules on the next message.
  • Opening the reply line lets the user read the earlier answer and reply there.
  • The send_to_user result states where the answer went ("in that message's sub-thread, because the user wrote later in the main list") and lists unanswered user messages.
  • A later message the agent already answered or acknowledged counts as read; retrying after a refusal succeeds.
  • replace_send_to_user edits that answer in place until the user replies after it in that sub-thread.
  • An acknowledgement sent before the later message stays in the main list; the answer after it goes to the sub-thread.
  • Normal mode is unchanged.

How it works:

  • One shared fold rule (foldCores) puts an answer to a main-list message in its sub-thread when a later main-list user message precedes it. The web timeline, server tools, user view (t3_thread_user_view), and history loader all use foldCores, so they agree.
  • send_to_user folds its history plus the new answer through foldCores to report placement and list unanswered user messages.
  • The read check inspects stored steer status (isUnread, beside the reply-stage judge) and the agent's answers or acknowledgements to the later message. Pending, cancelled, or never-confirmed mid-turn messages refuse at most once via an in-memory server record kept for 10 minutes.

Accepted tradeoffs:

  • Providers that never report reading a mid-turn message cause one refusal per unanswered later message, even if the agent saw it.
  • Rarely, if a refused mid-turn message is later re-queued and sent again, an answer accepted meanwhile can show in the main list until that message runs again.
  • Stored answers keep their place, except in rare old histories where an answer was stored after a later main-list message; those now show under their question.
  • An answer whose question is more than 120 messages back can be missing from the agent's recap of that sub-thread.

Surfaces not changed:

  • Mobile (no Chat mode), Normal mode, and answers inside a sub-thread (only the latest message in a sub-thread can be answered, as before).

Upstream hooks:

  • apps/server/src/provider/agentContextBudget.json (+1/-1 line) grows the measured tool-list size by 115 bytes for the longer reply_to description.
  • All other changes are in fork files, the README, and tests.

@orbitingflea orbitingflea added the agent-context-increase Accepts growth of the text agents receive label Nov 22, 2026
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: b53eeae · PR result: cad9781 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@orbitingflea
orbitingflea force-pushed the feat/chat-steer-reply-in-thread branch from 622c4e2 to 5bab5d3 Compare November 22, 2026 03:27
When the user sends a second main-list message while the agent is still
on the first, the agent may now answer the first one separately. That
answer shows in the first message's sub-thread; answers to the latest
main-list message still show in the main list.

- foldCores places an answer to a main-list message in that message's
  sub-thread when a later main-list user message comes before it.
- send_to_user no longer refuses such an answer. It refuses once when a
  later main-list message is a steer that no provider has confirmed
  reading (pending, cancelled, or never past the time it was stored),
  and lists it; the retry goes through.
- The result text, the Chat mode rules (chat-replies@4), the per-message
  line and the reply_to description state the new placement, with
  same-topic versus separate-topic guidance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-context-increase Accepts growth of the text agents receive size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant