mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
fix(agents): preserve foreground-only MCP cancellation
Opt the app and CLI Stop endpoint into canceling idle session background work. Keep normal agent-run cancellation scoped to an in-flight run.
This commit is contained in:
@@ -102,8 +102,13 @@ async function requestAgentRunCancellation(
|
||||
export async function cancelAgentRunCommand(
|
||||
dependencies: Pick<AgentLifecycleCommandDependencies, "agentManager" | "logger">,
|
||||
agentId: string,
|
||||
options?: { includeBackgroundWork?: boolean },
|
||||
): Promise<CancelAgentRunResult> {
|
||||
const result = await requestAgentRunCancellation(dependencies, agentId, true);
|
||||
const result = await requestAgentRunCancellation(
|
||||
dependencies,
|
||||
agentId,
|
||||
options?.includeBackgroundWork,
|
||||
);
|
||||
if (result.cancellation.status === "refused") {
|
||||
dependencies.logger.warn(
|
||||
{ agentId },
|
||||
|
||||
@@ -2947,9 +2947,17 @@ test.each(["steer", "stop", "interrupt", "refused follow-up"] as const)(
|
||||
await expect.poll(() => calls).toEqual(["Start two commands", "session/cancel"]);
|
||||
expect(manager.getAgent(agent.id)?.lifecycle).toBe("idle");
|
||||
} else {
|
||||
const foregroundOnly = await cancelAgentRunCommand(
|
||||
{ agentManager: manager, logger },
|
||||
agent.id,
|
||||
);
|
||||
expect(foregroundOnly.cancelled).toBe(false);
|
||||
expect(calls).toEqual(["Start two commands"]);
|
||||
|
||||
const { cancelled } = await cancelAgentRunCommand(
|
||||
{ agentManager: manager, logger },
|
||||
agent.id,
|
||||
{ includeBackgroundWork: true },
|
||||
);
|
||||
expect(cancelled).toBe(true);
|
||||
await expect.poll(() => calls).toEqual(["Start two commands", "session/cancel"]);
|
||||
|
||||
@@ -5334,6 +5334,7 @@ export class Session {
|
||||
await cancelAgentRunCommand(
|
||||
{ agentManager: this.agentManager, logger: this.sessionLogger },
|
||||
agentId,
|
||||
{ includeBackgroundWork: true },
|
||||
);
|
||||
if (requestId) {
|
||||
const agent = this.agentManager.getAgent(agentId);
|
||||
|
||||
Reference in New Issue
Block a user