Repair orphan tool-call tails on resume and stop mutating memory on Stop.Replacement (N3 WP1) #30

Merged
weichen merged 1 commits from feature/n3-runstate-wp1 into main 2026-10-07 15:03:53 +00:00
Owner

Why: a kill between persist(assistant) and commitToolIntent left an unpaired tail no recovery path repaired (acceptance ① library gap); Stop.Replacement mutated the in-memory assistant while the transcript kept the original (audit N6 residual).

What:

  • repairOrphanTail runs after recoverPending on every Run: the trailing assistant-with-tool_calls gets crashInterrupted IsError pairs for any resultless call (deduped by CallID; healthy transcripts untouched; deep-history orphans stay with poison rotation).
  • Stop.Replacement now only appends the replacement as a user message — memory and transcript agree (audit N6 closes).

Evidence: GOWORK=off go vet + go test -count=1 ./... green; TestResumePairsOrphanTailAfterCrashWindow (acceptance ① core), TestResumeMixedIntentAndOrphanTail, TestRepairOrphanTailNoopOnHealthyTranscript; harness pins replacement-as-user-note.

Impact: replacement display form changes intentionally (recorded in the N3 card); every Run now guarantees pairing before the first provider request.

Refs: Agent-System-Documents#43 (N3 plan WP1)

Why: a kill between persist(assistant) and commitToolIntent left an unpaired tail no recovery path repaired (acceptance ① library gap); Stop.Replacement mutated the in-memory assistant while the transcript kept the original (audit N6 residual). What: - repairOrphanTail runs after recoverPending on every Run: the trailing assistant-with-tool_calls gets crashInterrupted IsError pairs for any resultless call (deduped by CallID; healthy transcripts untouched; deep-history orphans stay with poison rotation). - Stop.Replacement now only appends the replacement as a user message — memory and transcript agree (audit N6 closes). Evidence: GOWORK=off go vet + go test -count=1 ./... green; TestResumePairsOrphanTailAfterCrashWindow (acceptance ① core), TestResumeMixedIntentAndOrphanTail, TestRepairOrphanTailNoopOnHealthyTranscript; harness pins replacement-as-user-note. Impact: replacement display form changes intentionally (recorded in the N3 card); every Run now guarantees pairing before the first provider request. Refs: Agent-System-Documents#43 (N3 plan WP1)
weichen added 1 commit 2026-10-07 15:02:40 +00:00
Repair orphan tool-call tails on resume and stop mutating memory on Stop.Replacement (N3 WP1)
ci / vet-and-test (pull_request) Successful in 50s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
5abb231efe
Why: a kill between persist(assistant) and commitToolIntent left an
unpaired tail that no recovery path repaired (acceptance clause 1's
library gap), and Stop.Replacement mutated the in-memory assistant
while the transcript kept the original (audit N6 residual).
Evidence: GOWORK=off go vet + go test -count=1 ./... green;
TestResumePairsOrphanTailAfterCrashWindow (no-intent window pairs with
crashInterrupted, run continues), TestResumeMixedIntentAndOrphanTail
(intent path and tail repair never double-pair),
TestRepairOrphanTailNoopOnHealthyTranscript; the harness assertion now
pins replacement-as-user-note (forged=4, notes=3).
Impact: every next Run repairs the trailing assistant's resultless
calls before the first request; replacement text now appears only as a
user message in both memory and transcript (intentional, recorded in
the N3 card).
Refs: Agent-System-Documents#43 (N3 plan WP1)
weichen merged commit cb21ec4e2a into main 2026-10-07 15:03:53 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-Native#30