Repository navigation
fix(claude-plugin): capture only new turns when a subagent stops again - #6323
Merged
Merged
Conversation
t0saki
force-pushed
the
fix-cc-subagent-capture-cursor
branch
from
October 21, 2026 02:56
ec30099 to
0ed17b0
Compare
t0saki
marked this pull request as ready for review
October 21, 2026 07:16
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
ZaynJarvis
approved these changes
Oct 22, 2026
A subagent woken again by a background task notification or SendMessage fires SubagentStop once more with its whole transcript. The stop hook pushed every turn and committed each time, and it deleted its state file after a successful push, so each wake re-uploaded all earlier turns into a new archive. Keep the state file and track a capturedTurnCount cursor in it, as auto-capture does for the main session: push only turns past the cursor, skip the commit when there are none, and have SubagentStart preserve the cursor when it rewrites the state.
t0saki
force-pushed
the
fix-cc-subagent-capture-cursor
branch
from
October 22, 2026 08:18
0ed17b0 to
a3c303f
Compare
mangxy
added a commit
to mangxy/OpenViking
that referenced
this pull request
Oct 24, 2026
- toast刀5/config-schema/auto-recall/session-start 三处全活 - statusline 三刀全活(modelCtx 5处=注释态基线) - recall 止血刀双路 query_expansion off 在位;官方新 recallQueryExpansion 仅显式配置才覆盖,默认不翻车 - 新吃官方: volcengine#6297 api-request-blob 跳过(CC301+防重复上传)、volcengine#6323 subagent cursor、volcengine#6394 Stop 重放 pending - captureRedact(gitleaks) 官方已 revert,不带 Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
Description
A Claude Code subagent can stop more than once: a background task notification or
SendMessagewakes it again, and each wake firesSubagentStopwith the subagent's whole transcript. Before this change,subagent-stop.mjssent every turn in that transcript and committed every time. It also deleted its state file after a successful push. So each wake re-uploaded all earlier turns into the same OpenViking session and committed a new archive holding all of them. Extraction work grew quadratically with the number of wakes.The main-session capture path (
auto-capture.mjs) already avoids this with acapturedTurnCountcursor. This PR applies the same cursor to subagent capture.Human Involvement
Related Issue
N/A
Type of Change
Changes Made
subagent-stop.mjs: the subagent state file is kept after a successful capture and stores acapturedTurnCountcursor. Only turns past the cursor are pushed. If there are none, the hook returns without pushing or committing. The cursor advances only when every turn was sent or queued, so an enqueue failure leaves it in place for a retry.subagent-start.mjs: when it rewrites the state for anagent_idthat already has a state file, it keeps the existingcapturedTurnCount.plugin.jsonandpackage.json).Testing
New test in
scripts/auto-capture.test.mjs. It runs SubagentStart, then SubagentStop, then appends one turn to the transcript, then runs SubagentStart, SubagentStop, and one more SubagentStop with nothing new. All of this runs against a mock OpenViking server. The test checks that the second push carries only the new turn and that there are exactly two commits. Withsubagent-stop.mjsreverted tomain, the test fails with a third batch; with onlysubagent-start.mjsreverted, the second batch resends all three turns. The full Claude plugin suite (node --test examples/claude-code-memory-plugin/scripts/*.test.mjs examples/claude-code-memory-plugin/scripts/lib/*.test.mjs) passes, 55/55, and.github/scripts/check-plugin-version-bumps.sh upstream/mainpasses. I did not test this with a live Claude Code session or a real OpenViking server.Checklist
Additional Notes
Subagent state files in the temp directory now persist after a successful capture, as
auto-capture's state files already do. Without the file, a later wake could not know which turns were already sent.Upgrade note: on
mainthe state file is deleted after a successful stop, so a subagent that already stopped once before the upgrade and is woken again afterwards pushes its full transcript one more time; after that it uses the cursor.