Clear a failed start's run even when reporting the failure throws

A steer waiting on that start is released only when the run is cleared.
This commit is contained in:
paseo-bot[bot]
2026-10-06 04:36:28 +02:00
parent 0e2870c413
commit 03d23c577a
@@ -2457,13 +2457,17 @@ export class AgentManager {
agent.pendingReplacement = false;
const errorMsg = error instanceof Error ? error.message : "Failed to start turn";
this.runs.settleForegroundStart(pendingRun, { status: "failed", error: errorMsg });
await this.handleStreamEvent(agent, {
type: "turn_failed",
provider: agent.provider,
error: errorMsg,
});
this.finalizeForegroundTurn(agent);
this.runs.settleForegroundRun(agentId, pendingRun.token);
try {
await this.handleStreamEvent(agent, {
type: "turn_failed",
provider: agent.provider,
error: errorMsg,
});
this.finalizeForegroundTurn(agent);
} finally {
// A steer waiting on this start is released only once the run is cleared.
this.runs.settleForegroundRun(agentId, pendingRun.token);
}
throw error;
}
}