Skip to content

Prime Agent active turns fail after daemon reconnect #79

Description

@rynfar

Problem

A live daemon-backed Prime Agent turn can fail when the in-process connection to the Prime daemon reconnects while the turn is active. The user sees Prime Agent stopped before sending a final response and must send another message manually even though the underlying work may have continued or completed.

This is separate from scoped browser tools in #77 / #78 and from adopting an active execution after the Pylon server process itself restarts in #84.

Reproduction observed on 2026-08-25

  1. Start a daemon-backed Prime Agent turn in Pylon.
  2. Let the turn enter tool or child-agent work.
  3. Interrupt the Pylon-to-daemon transport while the Pylon server remains alive.
  4. Observe the authoritative reconnect snapshot.

The provider event log recorded:

turn.completed state=failed
errorMessage="Prime Agent could not reconcile the active turn after reconnecting."
session.exited exitKind=error
reason="Prime Agent session state could not be reconciled."

The client rendered Prime Agent stopped before sending a final response.

Expected behavior

When Prime's reconnect metadata proves event continuity, Pylon should retain the existing adapter context and canonical turn without duplicating lifecycle events. When events were missed but the bounded public snapshot can be reconciled exactly with the current turn, Pylon should restore that safe state and continue. If authoritative recovery is impossible, the client should retain a precise reconnect-recovery failure rather than presenting a generic missing-response stop.

Acceptance coverage

  • reconnect during a root tool call
  • reconnect while a depth-1 child or another asynchronous continuation is pending
  • reconnect after native work completed but before the final public response was projected
  • generation-scoped replay/resync handling; a same-sequence snapshot from a new connection is not discarded as a duplicate
  • no duplicate turn.started / turn.completed or prompt admission
  • unavailable or inconsistent replay/snapshot state fails once and disposes uncertain native ownership
  • no orphaned child, queue, MCP credential, or provider-session ownership
  • focused adapter/runtime tests plus one real daemon-backed client pass

Process-restart adoption is tracked separately in #84.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions