Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Keep watch and cron delivery on the conversation's own surface (#1717)

Joshua France47572ea71255
diff --git a/src/core/gateway-context.ts b/src/core/gateway-context.ts
index 0d86ec250..cfc544b85 100644
--- a/src/core/gateway-context.ts
+++ b/src/core/gateway-context.ts
@@ -20,7 +20,7 @@ export function renderGatewayContext(surface: string | undefined, ctx?: GatewayC
}
if (gateway.toLowerCase() === "web") {
lines.push(
- 'This web UI cannot receive future external notifications. For scheduled notifications, reminders, digests, or reports, create the cron with a real platform destination: use `recipient` for a Slack DM to the requesting user when you can resolve them as a teammate, `channel` for a named Slack channel, or ask the user where it should post. Do not put "deliver to Slack" only inside `action`.',
+ "A cron, reminder, or watch you create here with no explicit destination posts back into this web conversation, and the person sees it here. Leave the destination unset by default; use `recipient`, `channel`, or `destinationKey` only when the person asks for delivery somewhere else.",
);
}
if (instructions) lines.push(instructions);
diff --git a/src/harness/agent-tools.ts b/src/harness/agent-tools.ts
index df1b0d926..49ad5737b 100644
--- a/src/harness/agent-tools.ts
+++ b/src/harness/agent-tools.ts
@@ -2242,7 +2242,9 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):
"{everyMs} is ONLY for genuine sub-day polling where wall-clock time does not matter (first run one " +
"interval from now, not immediately; an everyMs of 24h+ is rejected — use {cron,timezone} instead), or " +
'{firstFireAt} (epoch ms; fires once then auto-cancels — use Date.now() for "send now").\n' +
- "DELIVERY: by default a cron posts back to this conversation. To deliver elsewhere, set `recipient` " +
+ "DELIVERY: by default a cron posts back to this conversation — the surface where you are talking now (a web session, Slack DM, or thread). " +
+ "Keep that default for watches and follow-ups on work started here (including delegated sessions) unless the person names another destination; don't pick a DM just because it is a DM. " +
+ "To deliver elsewhere, set `recipient` " +
"(a teammate's name → a DM; core resolves the name and the result echoes who it matched), `channel` " +
"(a channel name → that channel), `participants` (a list of member ids → a group DM, which has no name; " +
"you're added automatically; the group must already exist — post to it once with the slack tool's " +
diff --git a/test/gateway-context.test.ts b/test/gateway-context.test.ts
index 90f5246ba..35afcede4 100644
--- a/test/gateway-context.test.ts
+++ b/test/gateway-context.test.ts
@@ -28,12 +28,13 @@ test("gateway only (no surface-provided context) still names the gateway", () =>
assert.doesNotMatch(out, /Identifiers for this conversation/);
});
-test("web gateway warns scheduled notifications need an external destination", () => {
+test("web gateway keeps scheduled deliveries in the web conversation by default", () => {
const out = renderGatewayContext("web");
assert.match(out, /over web\./);
- assert.match(out, /web UI cannot receive future external notifications/);
- assert.match(out, /use `recipient` for a Slack DM/);
- assert.match(out, /Do not put "deliver to Slack" only inside `action`/);
+ assert.match(out, /no explicit destination posts back into this web conversation/);
+ assert.match(out, /Leave the destination unset by default/);
+ assert.doesNotMatch(out, /cannot receive future external notifications/);
+ assert.doesNotMatch(out, /use `recipient` for a Slack DM/);
});
test("surface-supplied instructions are appended verbatim (and alone are enough to render)", () => {
@@ -100,9 +101,8 @@ test("web prompt tells cron creators to use a real notification destination", as
text: "!sysprompt",
});
assert.equal(res.status, "ok");
- assert.match(res.reply ?? "", /web UI cannot receive future external notifications/);
- assert.match(res.reply ?? "", /recipient.*Slack DM/s);
- assert.match(res.reply ?? "", /Do not put "deliver to Slack" only inside `action`/);
+ assert.match(res.reply ?? "", /posts back into this web conversation/);
+ assert.doesNotMatch(res.reply ?? "", /cannot receive future external notifications/);
});
test("triggered destination turns tell the agent to return the deliverable, not self-send it", async () => {
@@ -125,3 +125,11 @@ test("triggered destination turns tell the agent to return the deliverable, not
assert.match(res.reply ?? "", /Core will deliver your final reply/);
assert.match(res.reply ?? "", /Do not call Slack, email, chat, or other send APIs/);
});
+
+test("a web turn's default delivery destination is its own web session", async () => {
+ const { deliveryCandidatesFor } = await import("../src/core/orchestrator/turn-helpers.ts");
+ const delivery = deliveryCandidatesFor("web", "web:session-1", undefined, scopeId("personal", "[email protected]"));
+ const chosen = delivery.candidates.find((c) => c.key === delivery.defaultKey);
+ assert.equal(chosen?.type, "web");
+ assert.equal(chosen?.target, "web:session-1");
+});