Repository navigation
fix(transcript): realign rebuilt turn ordinals to wire ids and mark wedged turns - #4280
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 5735f14 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
…edged turns Cold transcript rebuilds numbered materialized turns 0..N while the live projector assigns ordinal=wireId, so a session rebuilt after a restart got a shifted axis that no longer aligned with what clients had cached live, and a turn whose loop died before writing a terminal event was rebuilt as a fake completed turn with no timestamps. foldWireRecordFacts now reassigns every matched rebuilt turn to its wire turn id (leaving holes for folded turns), restores startedAt from the agent.turn.started / turn.prompt records, and marks a turn with no terminal event as wedged (state failed + wedged flag) once a later turn prompt exists in the wire; the tail turn is only wedged when it is not the live active one. The live projector closes the previous running turn as wedged when a new turn starts. The wedged marker is an additive optional field so released clients keep parsing transcripts and render the turn as failed.
…ence failures The wedged-turn incident showed a main agent loop can stall for hours with zero diagnostics: task notifications pooled in memory, a latched or hung wire flush swallowed every subsequent record, and the running turn produced no watchdog output. - AppendLogStore warns once when an append is accepted while a storage failure is latched, and warns when a flush stays pending past 30s (repeating every 10min) with scope/key/pending counts. - WireService routes append failures to ILogService in addition to onUnexpectedError so they land in the daemon log. - AgentLoopService arms a per-turn watchdog that warns after 10min without observable progress (steps, streaming partials, machine phase), including pending notification/pause/queue state; loop.notify and nudge consumption log buffered/drained counts at debug level. - AgentTaskService warns when lifecycle guards silently drop task notifications or terminal events, and debug-logs in-process redelivery suppression. - EventDispatcherService warns once per episode when dispatch is stuck for over 30s and events keep queueing behind it.
liruifengv
previously approved these changes
Oct 20, 2026
…nting leaked timers With the loop turn watchdog armed, a notification-driven turn that happens to be running at the assertion holds a legitimate interval, making the global timer count scheduling-dependent. Cancel any spawned turn and pump the clock until the loop is idle before counting.
sailist
force-pushed
the
bug-292-10-15-wedged-turn-transcript-seam
branch
from
October 20, 2026 09:49
b9f2b4f to
5735f14
Compare
liruifengv
approved these changes
Oct 20, 2026
This was referenced Oct 27, 2026
Closed
Merged
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.
Requirement or Bug
A user session froze in the past: after the agent loop silently stalled mid-turn (background subagents kept running), restarting the app made the conversation view roll back roughly two days and never catch up; search still surfaced a query that never landed in the transcript.
Bug Reproduction Steps
completedwith null timestamps.Root Cause
Three layers, two fixed here, one instrumented:
started-forever; nothing reconciles it on rebuild, and the cold materializer hardcodesstate: 'completed'. → Fixed: rebuilt transcripts now derive an explicit wedged state.ordinal = wire turn id; cold rebuild renumbered 0..N, so the axes always diverged at folded turns. → Fixed: cold rebuild now uses the same wire-id axis with holes.Code Changes
packages/transcript(foldWireRecordFacts): rebuilt turns matched to wire facts are realigned to their wire turn ids (holes left for folded turns),startedAtrestored fromagent.turn.started/turn.promptrecord times, and any turn with a prompt but no terminal event is marked wedged once a later turn prompt exists — the tail turn only when it is not the live active one.TranscriptTurngains an additive optionalwedgedboolean; state stays'failed'so released clients keep parsing transcripts and render the turn as failed.packages/kap-server:readColdSnapshotpasses the live active wire turn id into the fold; the live projector closes the previous running turn as wedged when a new turn starts instead of silently overwriting it.packages/agent-core-v2observability: AppendLogStore warns once when appending over a latched storage failure and when a flush stays pending past 30s (repeats every 10min with scope/key/pending); WireService routes append failures to the daemon log; AgentLoopService arms a per-turn watchdog warning after 10min without observable progress (including pending-notification/pause/queue state) and logs notify buffering/consumption at debug level; AgentTaskService warns when lifecycle guards silently drop task notifications or terminal events; EventDispatcherService warns once per episode when dispatch is stuck for 30s+ with events queueing.readColdSnapshotregression replicating the incident wire shape (folded notification turns, a never-ended turn, a successor turn), consolidation of adjacent robustness cases to keep the test count flat, and a timer-leak assertion made deterministic by quiescing the spawned notification turn first.Behavior Changes and Affected Users
completedwith null timestampsfailed+wedged: true, realstartedAt, noendedAtstartedAton cold-rebuilt turnsfailed+ wedged with its open step interruptedAffected modules and coverage: transcript fold/group (foldFacts cases in
packages/transcript/test/layers.test.ts), kap-server cold rebuild (test/services/transcript.test.tsregression), live projector (existing kap-server transcript suites), agent-core-v2 loop/task/persistence/wire/dispatcher (existing suites incl. timer-leak test made deterministic). Full monorepo suite on Linux: 17029/17029 passed.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.