From 22d4812bb5981334222fffc9612b2ab76336ce83 Mon Sep 17 00:00:00 2001 From: Janghoon Lee <44862514+its-janghoon@users.noreply.github.com> Date: Tue, 17 Nov 2026 04:36:42 +0000 Subject: [PATCH] fix(desk): let phone and web answer the agent's questions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The question tool waits for an answer, but the desk forwarder allowed no question routes, so a turn driven from the web (a Redrob cloud preview run) sat on "질문을 준비하는 중" for an hour. Allow GET /api/session/:id/question, POST .../question/:id/reply (answers: string[][], bounded) and POST .../question/:id/reject, and send question.v2.* events to every device like permission events. --- packages/redrob/src/desk/forward.ts | 19 ++++++++++++++++++- .../redrob/test/desk/forward-question.test.ts | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 packages/redrob/test/desk/forward-question.test.ts diff --git a/packages/redrob/src/desk/forward.ts b/packages/redrob/src/desk/forward.ts index 09869aa026..2f5cc082f2 100644 --- a/packages/redrob/src/desk/forward.ts +++ b/packages/redrob/src/desk/forward.ts @@ -167,6 +167,22 @@ export const ROUTES: readonly Route[] = [ return reply === "once" || reply === "reject" }, }, + // The agent's questions (the `question` tool): the device lists, answers or dismisses them, or the + // turn waits on an answer nobody can give. + { method: "GET", path: new RegExp(`^/api/session/${ID}/question$`) }, + { + method: "POST", + path: new RegExp(`^/api/session/${ID}/question/${ID}/reply$`), + body: (body) => { + const answers = (body as { answers?: unknown } | undefined)?.answers + return ( + Array.isArray(answers) && + answers.length <= 20 && + answers.every((a) => Array.isArray(a) && a.length <= 20 && a.every((v) => typeof v === "string" && v.length <= 2000)) + ) + }, + }, + { method: "POST", path: new RegExp(`^/api/session/${ID}/question/${ID}/reject$`) }, { method: "GET", path: /^\/v1\/apps$/ }, // AI 방화벽 "strong": the web reads and sets the PC's masking, and masks a message on the PC first. { method: "GET", path: /^\/api\/privacy$/ }, @@ -1093,7 +1109,8 @@ export class Forwarder { return } const sessionID = typeof event.data?.sessionID === "string" ? event.data.sessionID : undefined - const permission = event.type.startsWith("permission.") + // Permission and question requests reach every device, like the approval count. + const permission = event.type.startsWith("permission.") || event.type.startsWith("question.") if (event.type === "session.next.attachment" && isAttachment(event.data)) this.remember(event.data) if (event.type === "permission.v2.asked" && typeof event.data?.id === "string") this.asked.add(event.data.id) if (event.type === "permission.v2.replied" && typeof event.data?.requestID === "string") diff --git a/packages/redrob/test/desk/forward-question.test.ts b/packages/redrob/test/desk/forward-question.test.ts new file mode 100644 index 0000000000..85cd6af693 --- /dev/null +++ b/packages/redrob/test/desk/forward-question.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, test } from "bun:test" +import { match } from "../../src/desk/forward" + +describe("desk question routes", () => { + test("a device lists, answers and dismisses the agent's questions", () => { + expect(match({ method: "GET", path: "/api/session/ses_a/question" })).toMatchObject({ sessionID: "ses_a" }) + expect( + match({ method: "POST", path: "/api/session/ses_a/question/que_1/reply", body: { answers: [["예"], ["A", "B"]] } }), + ).toBeDefined() + expect(match({ method: "POST", path: "/api/session/ses_a/question/que_1/reject" })).toBeDefined() + }) + + test("bad answers and paths are refused", () => { + expect(match({ method: "POST", path: "/api/session/ses_a/question/que_1/reply", body: { answers: "예" } })).toBeUndefined() + expect(match({ method: "POST", path: "/api/session/ses_a/question/que_1/reply", body: { answers: [[1]] } })).toBeUndefined() + expect(match({ method: "POST", path: "/api/session/ses_a/question/../reply", body: { answers: [] } })).toBeUndefined() + expect(match({ method: "GET", path: "/api/question/request" })).toBeUndefined() + }) +})