kimi-code/packages/transcript
Luyu Cheng 895e9d9b86
fix: restore swarm members from persisted lifecycle events (#3970)
* fix: restore swarm members from persisted lifecycle events

* test(agent-core-v2): register subagent lifecycle records in the wire vocabulary

* chore(agent-core-v2): regenerate the wire manifest for subagent lifecycle records

The manifest inventory drives the vis wire-renderer coverage check, so vis gains a renderer for each new record type and treats them as timeline-neutral in the context projector.

* fix(transcript): associate a folded subagent with the task registered after its spawn

Some emitters register the task after publishing the spawn, so the durable
spawn record carries no task id and the cold fold keyed the member by its
agent id. A later task.started then created a second task that no subagent
terminal event ever reached, leaving a duplicate stuck in the running state.
Folding task.started now records the agent-to-task association the live
projector keeps, and terminal subagent records update both representations
when both are retained.

* fix(transcript): restore subagent token usage when folding a completed member

The durable subagent.completed record carries the member's token usage and the
live projector copies it onto the task, but the cold fold dropped it, so a
reopened conversation showed a completed member without usage metadata. The
fold now validates the payload's four counters and restores them.

* fix(kap-server): base the lost-member decision on the turn that spawned it

The cold snapshot only terminalised an unfinished foreground member when the
parent agent was idle, so a member left behind by a restart stayed marked as
running forever once the user started a new parent turn before backfill.
The restored agent refs already name the tool call that spawned each member,
so the decision now uses the turn owning that call: a member is lost when its
own loop is not running and its spawning turn is not the turn the parent is
running now.

* fix(transcript): adopt the spawn placeholder into the task registered afterwards

A spawn published before its task is registered — the Tower worker path —
carries no task id, so the fold created a placeholder keyed by the agent id
and the later task.started added a second task under the registered id. Only
the registered task was ever terminalised, and the detached placeholder was
skipped by the lost-member pass, so a restored transcript kept a duplicate
worker shown as running forever. task.started now folds the placeholder into
the registered task instead of leaving it behind.

* fix(kap-server): drain the live wire before reading a cold snapshot

The append log buffers records and writes them in batches, which is why its
own reader flushes the log first. The cold transcript reads the wire file
directly and skipped that drain, so a snapshot could stop on a stale prefix.
When the transcript binding is created after a turn has already ended, the
whole store is built from that snapshot and nothing repairs it afterwards,
leaving the turn's last tool call without its result and its member marked
lost. Reading now drains the live agent's wire first, as session export
already does before it reads the same files.
2026-09-23 14:25:40 +08:00
..
src fix: restore swarm members from persisted lifecycle events (#3970) 2026-09-23 14:25:40 +08:00
test fix: restore swarm members from persisted lifecycle events (#3970) 2026-09-23 14:25:40 +08:00
CHANGELOG.md ci: release packages (#3140) 2026-08-27 19:33:51 +08:00
package.json ci: release packages (#3140) 2026-08-27 19:33:51 +08:00
tsconfig.json feat(transcript): add unified transcript layer, drop the /api/v2 RPC surface (#1888) 2026-07-20 15:33:05 +08:00
tsdown.config.ts feat(transcript): add unified transcript layer, drop the /api/v2 RPC surface (#1888) 2026-07-20 15:33:05 +08:00
vitest.config.ts feat(transcript): add unified transcript layer, drop the /api/v2 RPC surface (#1888) 2026-07-20 15:33:05 +08:00