Files
paseo/docs
Ouyang Xingyuan c17e7c5b64 fix(server): release a provider turn the daemon force-canceled
Cancelling a foreground turn can leave two owners of "is a turn running". The
manager force-cancels after its 2 s settle window: it synthesizes turn_canceled
and reports the agent idle. The provider session never confirmed that turn
ended, so it still holds the slot. Every later prompt then fails with "A
foreground turn is already active" until the agent is reloaded.

ACP is the reproducible case. ACPAgentSession.interrupt() sends session/cancel,
which is a notification: it resolves as soon as it is written. An agent that
answers cancelled but keeps working in the same process, or never answers at
all, leaves activeForegroundTurnId set. This is the failure observed locally on
2026-10-20 with a droid-magpie agent: five "[System Error] A foreground turn is
already active" rows and no way to send anything afterwards.

Add AgentSession.abandonForegroundTurn? as the seam for that state. The manager
calls it after a forced settlement, and only then; a cancel that settles keeps
today's path. A provider that implements it must make the session usable again
rather than clear a local flag, because reusing a runtime that may still be
working is the split-brain shape docs/agent-lifecycle.md forbids.

wrapSessionProvider forwards the hook. Without that line the manager only sees
the wrapper's fixed member list, so an optional method added to the interface is
silently dropped for every wrapped provider.

The ACP adapter kills the process that owned the abandoned turn, drops the slot,
and synthesizes cancelled tool calls for rows that were still running. Its next
startTurn resumes the durable session in a new process and drops the replayed
history rows, since the daemon already has them. A kill-timeout rejects, which
leaves the agent as it was.

Tests: a force-canceled turn releases the session and the next prompt starts, a
settled cancel does not call the hook, a rejected release still settles, the
wrapper forwards the hook or omits it, and the ACP adapter reconnects on the
next turn without replaying history twice.
2026-10-20 13:52:24 +08:00
..
2026-08-05 22:47:33 +02:00