Repository navigation
Conversation
…ed prompt Store a subagent prompt once in orchestration_events and point later unchanged updates at that row. Reads and replay budgets restore it in SQL, so events, the wire, and clients are unchanged. Slim rows keep an empty prompt so older servers can still decode them. Fixes pingdotgg#18204
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized persistence optimization for repeated Claude subagent prompts; replayed events, wire data, projections, and clients remain unchanged. The new storage indirection and rollback behavior are covered by focused tests, with no schema, default, deployment, security, billing, or static-analysis changes. Notes:
You can add or adjust custom eligibility rules. Learn more. |
macroscopeapp
Bot
dismissed
their stale review
October 11, 2026 22:55
Dismissing prior approval to re-evaluate 0eb17fc
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every Claude subagent progress tick appends two events,
subagent.updatedand a subagentturn-item.updated, and both repeat the full prompt even though onlyprogresschanged. Heavy subagent use growsstatev2.sqliteby about 50x the subagents' real state (#18204). On my install, 41.4 MiB of the 63.3 MiB stored in these events is repeated prompt text.Change
The fix lives entirely in the event store (
OrchestrationEventStore), so the contracts, the wire, projections, and every client stay as they are. Older web, desktop, and mobile builds keep working because they still receive full events.promptSequence(that row's sequence) and an emptypromptinstead of the text. An in-memory hint remembers the latest full row per subagent. TheINSERTre-checks that the row still exists with the same prompt, because the transaction that wrote it can roll back. A cold or stale hint just stores the full prompt again.readApplicationRows) restores the prompt in SQL. Thread replay, catch-up, projection recovery, and the replay byte budgets (getAgentReplayStats,getReplayStats) all see the original payload.prompt: "", so an older server sharing the same T3 home (for example after a desktop rollback) can still decode them. It shows an empty prompt rather than failing.subagent.updatedorturn-item.updatedrows, so the rows these pointers reference stay.ProjectionMaintenancenow carries a comment about this.Scope and approval
Triaged bug: #18204. The maintainer triage named persisting only the changed fields as an acceptable fix (comment). This PR does that at the storage layer. Live subagent progress keeps updating at the same rate, and there is no contract change.
Verification
stores an unchanged subagent prompt once and replays it on every update(new,OrchestrationEventStore.test.ts) appends three progress ticks and one prompt change for both event types. It asserts that only the first row of each type stores the prompt, that replay returns the original events, and that both replay budgets count the restored bytes. It fails onmainbecause every row stores the prompt.stores the full subagent prompt when its hint row was rolled back(new) rolls back the transaction that wrote the hinted row. It checks that the next append stores the full prompt, the one after it points at that new row, and bothreadAgentEventsandreadApplicationEventsreturn full events. It fails onmain.vp test run src/persistence/OrchestrationEventStore.test.ts src/persistence/OrchestrationEventStore.sequence.test.ts src/orchestration-v2/FoundationPersistence.test.ts src/orchestration-v2/ThreadStream.test.ts src/orchestration-v2/ShellStream.test.ts src/orchestration-v2/ProjectionRecovery.test.ts: 100 passed.tsc --noEmitis clean. Scopedvp lintandvp fmt --checkare clean on the touched files.statev2.sqlite: 14,915 subagent snapshot rows across 556 subagent records and turn items, 63.3 MiB stored, 41.4 MiB of it repeated prompts (5.7% of all V2 event payload bytes here). Rows written before this change keep their full prompts; only new events are slimmed.RETURNINGcost on every insert,getReplayStatscoverage). All five are fixed. Round 2 found no defects.Implemented with GPT-6 Astra (Codex CLI) and Claude Opus 5.5 (Claude Code via T3 Code), reviewed by Claude Opus 5.5.