Skip to content

feat(threads): record what settled a thread and show it in MCP - #47

Merged
maschwenk merged 1 commit into
mainfrom
feat/settlement-source
Nov 9, 2026
Merged

maschwenk merged 1 commit into
mainfrom
feat/settlement-source

Conversation

@maschwenk

Copy link
Copy Markdown
Owner

on 2026-11-09 the thread mcp:ac48f2ab-5aac-40fc-80f3-17504248d680 got settled while its last message was still asking me a question, and the thread itself didn't say what settled it. thread.auto-settle reuses the same thread.settle mutation a manual settle uses, so the payload only had settledAt and settledOverride: "settled". i had to back it out from settledAt matching the run's completedAt to the ms (it was the closed PR rule)

fwiw the "who" was already in orchestration_command_receipts (command type plus the command id prefix: server:auto-settle:, server:settle-after-run:, mcp:, bare uuid from the app). what wasn't anywhere is which auto-settle rule fired. so this is mostly about putting it on the thread where it's cheap to read, exposing it in MCP, and recording the rule

what changed

  • threads get a settlementSource next to settledAt
    • user: the app's settle (web, mobile, keybinding)
    • agent: t3_thread_organize settle. the settle-when-turn-ends path (server:settle-after-run) also counts as agent, it only runs when an agent settles its own thread mid turn
    • auto_pull_request_merged / auto_pull_request_closed: a PR linked to the thread
    • auto_branch_pull_request_merged / auto_branch_pull_request_closed: a PR the sweep found from the thread's branch with nothing linked (the subagent case)
    • auto_inactivity: sidebarAutoSettleAfterDays
  • the sweep passes the rule through thread.auto-settle. client settles get stamped user at the ws boundary, so a client can't claim it was an agent or a rule
  • unsettle, pin, a new message and a guest message all clear it. forks and subagent children start without one
  • t3_thread_read and t3_thread_list return it next to settled / settledAt
  • it lives in payload_json so no migration

tradeoffs

  • no backfill. receipts tell you which settle commands ran, but finding the one that set a thread's current settledAt means replaying no-op re-settles and every unsettle path (unsettle, message dispatch, pin, guest message). and auto-settle receipts don't have the rule, so the most useful part would still be unknown. existing settled threads stay null
  • settling an already settled thread keeps the first source, same as settledAt
  • imported agent sessions land settled with no source, didn't want to make one up
  • the field decodes leniently (unknown value reads as null) like opens, so a downgrade can't break a thread payload
  • it records the rule, not which PR fired it. easy to add if we want that

not touching the closed PR rule itself here, that's a separate call

possible ui follow-up: map it in client-runtime models.ts and show it on hover for settled rows in SidebarThreadRow.tsx, or in the thread action menu next to unsettle

written with claude opus 5.5 in claude code

@maschwenk maschwenk added the coder-task-generated Created from a coding task label Nov 9, 2026
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 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.
⚠️ This PR changes transfer ceilings:

  • Codex Live turn WebSocket decoded: 29.3 KiB → 24.4 KiB
  • Claude Live turn WebSocket decoded: 29.3 KiB → 24.4 KiB
Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB +33 B (+0.6%) 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 +33 B (+2.7%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 21.5 KiB +674 B (+3.2%) 24.4 KiB ✅
Codex Live turn messages 2 1 −1 (−50.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB +32 B (+0.6%) 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 +32 B (+2.6%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.9 KiB +686 B (+3.2%) 24.4 KiB ✅
Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅

Baseline: cdc3e41 · PR result: 2dcf823 · Source CI: failure

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.

Threads now keep a settlementSource next to settledAt: user, agent, or the auto-settle rule that fired (linked or branch pull request merged/closed, inactivity). t3_thread_read and t3_thread_list return it. Unsettling clears it; existing settled threads stay unknown.
@maschwenk
maschwenk force-pushed the feat/settlement-source branch from 0e689cb to 2dcf823 Compare November 9, 2026 10:14
@maschwenk
maschwenk marked this pull request as ready for review November 9, 2026 10:27
@maschwenk
maschwenk merged commit 91399cb into main Nov 9, 2026
24 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coder-task-generated Created from a coding task 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