Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(agent): report an unconfirmed Operation start as an interrupted Run

shoudi zheng7292394faf5a
diff --git a/apps/node-services/src/agent/runner-gateway/remote-codex-provider.ts b/apps/node-services/src/agent/runner-gateway/remote-codex-provider.ts
index 03c4fd2a..f65802d2 100644
--- a/apps/node-services/src/agent/runner-gateway/remote-codex-provider.ts
+++ b/apps/node-services/src/agent/runner-gateway/remote-codex-provider.ts
@@ -1,5 +1,6 @@
import { displayText } from "@linger/service-kit";
import {
+ OPERATION_OUTCOME_UNKNOWN,
RunnerOperationInputError,
RunnerGatewayError,
type RunnerCapacityPermit,
@@ -1077,7 +1078,13 @@ const localRunFailure = (
cause: error,
});
}
- if (error.code === "cancelled" || error.code === "DAEMON_RESTARTED") {
+ // A restarted Daemon and a start the Computer never confirmed both leave
+ // the native outcome unknown: the Run was interrupted, not refused.
+ if (
+ error.code === "cancelled" ||
+ error.code === "DAEMON_RESTARTED" ||
+ error.code === OPERATION_OUTCOME_UNKNOWN
+ ) {
return new ProviderRunInterruptedError(error.message, { cause: error });
}
return error;
diff --git a/apps/node-services/tests/agent/runner-gateway/remote-codex-provider.test.ts b/apps/node-services/tests/agent/runner-gateway/remote-codex-provider.test.ts
index 1eb1dd83..ceece124 100644
--- a/apps/node-services/tests/agent/runner-gateway/remote-codex-provider.test.ts
+++ b/apps/node-services/tests/agent/runner-gateway/remote-codex-provider.test.ts
@@ -1,4 +1,5 @@
import {
+ OPERATION_OUTCOME_UNKNOWN,
RunnerOperationInputError,
type RunnerSessionCompactOptions,
type RunnerSessionCompactOutcome,
@@ -1475,6 +1476,24 @@ describe("RemoteCodexProvider", () => {
},
);
+ it("reports a start the Computer never confirmed as interrupted", async () => {
+ const dispatcher = new ScriptedDispatcher({
+ runStartError: new RunnerOperationError(
+ OPERATION_OUTCOME_UNKNOWN,
+ "The Computer never confirmed the Operation start; its outcome is unknown",
+ false,
+ ),
+ });
+ const provider = createProvider(dispatcher);
+ const session = await provider.createSession(sessionOptions());
+ await expect(
+ provider.startRun(session, { type: "text", text: "Run once" }, runSpec),
+ ).rejects.toBeInstanceOf(ProviderRunInterruptedError);
+ expect(
+ dispatcher.requests.filter(({ request }) => request.kind === "run.start"),
+ ).toHaveLength(1);
+ });
+
it("never maps a post-start failure into a retryable Provider start", async () => {
const dispatcher = new ScriptedDispatcher({
runError: new RunnerOperationError(
diff --git a/apps/node-services/tests/agent/runner-gateway/runner-operations-public.test.ts b/apps/node-services/tests/agent/runner-gateway/runner-operations-public.test.ts
index 035e8499..3270752d 100644
--- a/apps/node-services/tests/agent/runner-gateway/runner-operations-public.test.ts
+++ b/apps/node-services/tests/agent/runner-gateway/runner-operations-public.test.ts
@@ -9,6 +9,7 @@ import {
RunnerGatewayProtocolError,
type RunnerGatewayConnection,
} from "../../../src/agent/runner-gateway/runner-gateway.js";
+import { OPERATION_OUTCOME_UNKNOWN } from "../../../src/agent/runner-gateway/runner-operation.js";
import { createTestRunnerGateway } from "../test-support/runner-gateway.js";
import { readyContextScope } from "../test-support/ready-context-view.js";
import { runtimeDiagnostics } from "./runtime-diagnostics-fixture.js";
@@ -965,7 +966,7 @@ describe("RunnerGateway", () => {
expect.objectContaining({ type: "operation.start" }),
);
await expect(operation.result).rejects.toMatchObject({
- code: "OPERATION_OUTCOME_UNKNOWN",
+ code: OPERATION_OUTCOME_UNKNOWN,
retryable: false,
});
});