Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

feat(ego-browser): align the two business error messages as parallel stop-and-resume guidance

0x07a85b5f4a225
diff --git a/package/ego-browser/src/browser-runtime.test.mjs b/package/ego-browser/src/browser-runtime.test.mjs
index c9e97ab..fc65f41 100644
--- a/package/ego-browser/src/browser-runtime.test.mjs
+++ b/package/ego-browser/src/browser-runtime.test.mjs
@@ -21,10 +21,9 @@ test("browserCdp surfaces the owned message and error_code when ensureSession is
() => browserCdp("Runtime.evaluate", {}, undefined, 1000),
(err) => {
assert.equal(err.error_code, "EGO_TASK_SPACE_INACTIVE");
- assert.equal(
- err.message,
- "Task space is not assigned to an agent. Claim this task space before sending CDP messages.",
- );
+ // Owned guidance block, not the native "Task space 10 ..." text.
+ assert.match(err.message, /claimTaskSpace\(id\)/);
+ assert.doesNotMatch(err.message, /\b10\b/);
return true;
},
);
@@ -55,10 +54,9 @@ test("browserCdp rejects the in-flight request via onSendCDPMessageError", async
() => browserCdp("Browser.getVersion", {}, undefined, 1000),
(err) => {
assert.equal(err.error_code, "EGO_TASK_SPACE_INACTIVE");
- assert.equal(
- err.message,
- "Task space is not assigned to an agent. Claim this task space before sending CDP messages.",
- );
+ // Owned guidance block, not the native reconstructed text.
+ assert.match(err.message, /claimTaskSpace\(id\)/);
+ assert.doesNotMatch(err.message, /native reconstructed text/);
return true;
},
);
diff --git a/package/ego-browser/src/ego-errors.test.mjs b/package/ego-browser/src/ego-errors.test.mjs
index 243264c..6fdbdab 100644
--- a/package/ego-browser/src/ego-errors.test.mjs
+++ b/package/ego-browser/src/ego-errors.test.mjs
@@ -42,15 +42,14 @@ test("isEgoErrorCode narrows to known codes only", () => {
});
test("resolveEgoError overrides the native error message with the owned wording for an owned code", () => {
- const resolved = resolveEgoError({
+ const { code, message } = resolveEgoError({
error: "Task space 7 is not assigned to an agent.",
error_code: "EGO_TASK_SPACE_INACTIVE",
});
- assert.deepEqual(resolved, {
- code: "EGO_TASK_SPACE_INACTIVE",
- message:
- "Task space is not assigned to an agent. Claim this task space before sending CDP messages.",
- });
+ assert.equal(code, "EGO_TASK_SPACE_INACTIVE");
+ // Owned id-less guidance replaces the native "Task space 7 ..." text.
+ assert.match(message, /claimTaskSpace\(id\)/);
+ assert.doesNotMatch(message, /\b7\b/);
});
test("resolveEgoError keeps the native error message for an unknown future code", () => {
@@ -93,7 +92,8 @@ test("resolveEgoError falls back to the raw code for a bare non-owned code", ()
test("resolveEgoError uses the id-less guidance block for a bare user-control code", () => {
const { code, message } = resolveEgoError("EGO_TASK_SPACE_USER_IN_CONTROL");
assert.equal(code, "EGO_TASK_SPACE_USER_IN_CONTROL");
- assert.match(message, /controlling this task space/);
+ assert.match(message, /taken control of this task space/);
+ assert.match(message, /takeOverTaskSpace\(\)/);
assert.doesNotMatch(message, /<id>/);
});
@@ -152,10 +152,10 @@ test("assertNoEgoError omits the prefix when no op is given", () => {
});
assert.fail("expected assertNoEgoError to throw");
} catch (err) {
- assert.equal(
- err.message,
- "Task space is not assigned to an agent. Claim this task space before sending CDP messages.",
- );
+ // No op given, so no "<op>: " prefix — the owned block starts the message.
+ assert.match(err.message, /^The user has taken control/);
+ assert.match(err.message, /claimTaskSpace\(id\)/);
+ assert.doesNotMatch(err.message, /\b10\b/);
assert.equal(err.error_code, "EGO_TASK_SPACE_INACTIVE");
}
});
diff --git a/package/ego-browser/src/ego-errors.ts b/package/ego-browser/src/ego-errors.ts
index efa8e4d..6d95900 100644
--- a/package/ego-browser/src/ego-errors.ts
+++ b/package/ego-browser/src/ego-errors.ts
@@ -44,15 +44,21 @@ export type EgoErrorCode = (typeof EGO_ERROR_CODES)[number];
* specific than any static line.
*/
const EGO_ERROR_MESSAGES: Partial<Record<EgoErrorCode, string>> = {
- EGO_TASK_SPACE_INACTIVE:
- "Task space is not assigned to an agent. Claim this task space before sending CDP messages.",
+ EGO_TASK_SPACE_INACTIVE: [
+ "The user has taken control of this task space and ended the task, so it is no longer assigned to the agent and browser commands are paused.",
+ "This is a hard stop, not an obstacle to route around — do not retry and do not take ownership back on your own.",
+ "Wait until the user explicitly asks you to continue, then claim the space and resume:",
+ " await claimTaskSpace(id)",
+ "",
+ `Offer the user choices like "Continue" or "Finish task" if your harness supports it; otherwise tell them: "You now control this task space. Reply 'continue' when ready and I will resume."`,
+ ].join("\n"),
EGO_TASK_SPACE_USER_IN_CONTROL: [
- "The user is controlling this task space. Browser commands are paused.",
- "Do not take over automatically. Wait for the user to return control or ask you to continue.",
- "To resume after user confirmation, call:",
+ "The user has taken control of this task space, so browser commands are paused.",
+ "This is a hard stop, not an obstacle to route around — do not retry and do not take control back on your own.",
+ "Wait until the user explicitly asks you to continue, then take control back and resume:",
" await takeOverTaskSpace()",
"",
- `If supported, offer choices like "Continue" or "Finish task"; otherwise tell the user: "You are now controlling this task space. Reply 'continue' when ready, and I will resume."`,
+ `Offer the user choices like "Continue" or "Finish task" if your harness supports it; otherwise tell them: "You now control this task space. Reply 'continue' when ready and I will resume."`,
].join("\n"),
};
diff --git a/package/ego-browser/src/helpers.test.mjs b/package/ego-browser/src/helpers.test.mjs
index 08350b7..116dba3 100644
--- a/package/ego-browser/src/helpers.test.mjs
+++ b/package/ego-browser/src/helpers.test.mjs
@@ -353,7 +353,7 @@ test("useOrCreateTaskSpace selects user-owned spaces without claiming and surfac
async () => {
await assert.rejects(
() => useOrCreateTaskSpace("checkout-flow"),
- /useOrCreateTaskSpace: The user is controlling this task space/,
+ /useOrCreateTaskSpace: The user has taken control of this task space/,
);
},
);
diff --git a/package/ego-browser/src/taskspace-e2e.test.mjs b/package/ego-browser/src/taskspace-e2e.test.mjs
index 14cdf30..4f7d6e2 100644
--- a/package/ego-browser/src/taskspace-e2e.test.mjs
+++ b/package/ego-browser/src/taskspace-e2e.test.mjs
@@ -230,7 +230,7 @@ test("taskspace e2e useOrCreateTaskSpace selects user-owned spaces without claim
await assert.rejects(
() =>
runTaskspaceScript(ego, `await useOrCreateTaskSpace("checkout-flow")`),
- /controlling this task space/,
+ /has taken control of this task space/,
);
assert.deepEqual(ego.calls, [["listTaskSpaces"], ["useTaskSpace", 7]]);
});