Resumed subagent loses completed status after app-server restart
Summary
When a persisted multi-agent v1 thread tree is resumed after the thread manager or app-server process restarts, descendant threads are reloaded from their rollouts but their in-memory AgentStatus starts at PendingInit.
A completed child therefore loses its persisted Completed(Some(message)) status. A subsequent wait_agent does not return the child's final reply and can time out even though the child completed before the restart.
Reproduction
- Start a root thread with SQLite persistence enabled.
- Spawn a v1 child agent.
- Let the child complete with a final message and flush its rollout.
- Shut down the thread manager/app-server cleanly.
- Create a new manager over the same state and resume the root rollout.
- Read or subscribe to the resumed child's status.
Expected: Completed(Some(final_message)).
Actual: PendingInit (or a wait blocks until timeout).
The child rollout may end with ShutdownComplete; that event represents the prior in-memory session lifecycle and should not erase the preceding turn outcome.
An unfinished persisted TurnStarted should resume as Interrupted, since that turn cannot still be running in a new process.
Proposed fix
Reconstruct the initial status for InitialHistory::Resumed from the latest meaningful status-bearing rollout event, ignoring ShutdownComplete, and convert a trailing Running state to Interrupted. Add restart coverage that asserts descendant final messages survive shutdown/resume.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗