Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(agents): assignment_status passes on a same-turn hand-off instead of failing the call (#7180)

Santhi Prakash28fb7ce7fa0d
diff --git a/server/drivers/agents-call.test.ts b/server/drivers/agents-call.test.ts
index 3902b10d36..9bc17f0b02 100644
--- a/server/drivers/agents-call.test.ts
+++ b/server/drivers/agents-call.test.ts
@@ -684,6 +684,23 @@ it("falls back to a nonblank camelCase groupId when group_id is blank", async ()
});
});
+describe("assignment_status", () => {
+ const stub = (status: number, body: Record<string, unknown>) => context({
+ client: { apiResponse: async () => ({ ok: false, status, body }), api: async () => ({}) },
+ });
+
+ it("answers an id sent this turn as an instruction, and keeps a real failure a failure", async () => {
+ const text = "Assignment asg-1 was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn.";
+ const answer = await callTool("assignment_status", { id: "asg-1" }, stub(409, { error: text, sentThisTurn: true }));
+ expect(answer.isError).toBeUndefined();
+ expect(answer.text).toBe(text);
+ expect((await callTool("assignment_status", { id: "asg-1" }, stub(409, { error: text }))).isError).toBe(true);
+ const unknown = await callTool("assignment_status", { id: "asg-2" }, stub(404, { error: "unknown assignment id" }));
+ expect(unknown.isError).toBe(true);
+ expect(unknown.text).toContain("No assignment asg-2 is known here");
+ });
+});
+
describe("blank optional arguments", () => {
it("drops blank session_search ids, so a blank-filled search stays a search", async () => {
const paths: string[] = [];
diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.ts
index f0e869fe53..fd5608a6d3 100644
--- a/server/drivers/agents-call.ts
+++ b/server/drivers/agents-call.ts
@@ -344,6 +344,8 @@ export async function callTool(called: string, input: Json, context: ToolCallCon
const why = status === 404 ? `No assignment ${id || "(none given)"} is known here: check the id against your coordinate_bots receipt or list_threads.`
: status === 403 ? `Assignment ${id} can't be read here: ${String(r.error ?? "only the conversation that sent it can read it")}.`
: String(r.error ?? `HTTP ${status}`);
+ // An id this turn sent is an instruction to finish the turn, not a failed call that ends it.
+ if (r.sentThisTurn === true) return { text: why };
return { text: why, isError: true };
}
if (id) return { text: renderAssignmentStatus(r, id) };
diff --git a/server/drivers/agents-proxy.test.ts b/server/drivers/agents-proxy.test.ts
index c5bb65f88e..f849af63c1 100644
--- a/server/drivers/agents-proxy.test.ts
+++ b/server/drivers/agents-proxy.test.ts
@@ -1278,17 +1278,19 @@ describe("agents-proxy MCP surface", () => {
expect(JSON.stringify(tool.inputSchema)).not.toMatch(/"(oneOf|anyOf|allOf|const|format)":/);
});
- it("assignment_status relays the harness's refusal to read an assignment handed out this turn", async () => {
+ it("assignment_status passes on an assignment sent this turn, and keeps a real failure a failure", async () => {
// Which turn made it is the harness's to know: a warm proxy serves many.
assignmentStatusCode = 409;
- assignmentStatusResponse = { error: "Assignment asg-abc123 was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn." };
+ assignmentStatusResponse = { error: "Assignment asg-abc123 was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn.", sentThisTurn: true };
try {
lastAssignmentStatusUrl = null;
const status = await callTool("assignment_status", { id: "asg-abc123", wait_ms: 240_000 });
- expect(status.result.isError).toBe(true);
+ expect(status.result.isError).toBeFalsy();
expect(status.result.content[0].text).toContain("handed out during this turn");
expect(status.result.content[0].text).toContain("Finish your response now");
expect(lastAssignmentStatusUrl).toBe("/api/internal/assignment-status?id=asg-abc123&wait_ms=240000");
+ assignmentStatusResponse = { error: "Assignment asg-abc123 was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn." };
+ expect((await callTool("assignment_status", { id: "asg-abc123" })).result.isError).toBe(true);
} finally {
assignmentStatusCode = 200;
assignmentStatusResponse = DONE_ASSIGNMENT;
diff --git a/server/index.ts b/server/index.ts
index e8a0b63a98..be7439d9aa 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -13658,7 +13658,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
return json(res, 200, { outstanding });
}
if (internalCapability.delegatedThisTurn?.has(id)) {
- return json(res, 409, { error: `Assignment ${id} was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn.` });
+ return json(res, 409, { error: `Assignment ${id} was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn.`, sentThisTurn: true });
}
const waitMs = Math.min(Math.max(Number(url.searchParams.get("wait_ms")) || 0, 0), 240_000);
const deadline = Date.now() + waitMs;