Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
57f771d
feat(mcp): t3_thread_result and t3_thread_read accept links and bare …
rallymewrx Nov 13, 2026
5fc94a9
feat(mcp): t3_thread_send reports where a queued message waits
rallymewrx Nov 13, 2026
fd1d74a
fix(mcp): delegate_task errors name the field and the valid choices
rallymewrx Nov 13, 2026
d1a23b5
feat(mcp): t3_thread_configure can schedule a model change on a busy …
rallymewrx Nov 13, 2026
751bdd3
docs(user): scheduled model changes, queue standing and thread links …
rallymewrx Nov 13, 2026
5aeeda9
fix(mcp): check a scheduled model up front and refuse applyAt alone
rallymewrx Nov 13, 2026
41ca4c9
docs(user): say that app messages keep the composer's model over a sc…
rallymewrx Nov 13, 2026
0af621e
feat(mcp): agent sends and posts keep a thread's snooze
rallymewrx Nov 13, 2026
1794b1d
fix(mcp): release snooze-held turns once, and only when the thread wakes
rallymewrx Nov 13, 2026
963ad2f
test(server): type the snooze release worker test and its service key
rallymewrx Nov 13, 2026
43d12e5
docs(jarvis): record the snooze default for agent sends and scheduled…
rallymewrx Nov 13, 2026
146946f
fix(mcp): retry refused snooze releases, wake on isSnoozed, keep queu…
rallymewrx Nov 13, 2026
cfe85b0
chore(server): re-measure the agent context budget on the integration…
rallymewrx Nov 13, 2026
bfe4be4
Merge remote-tracking branch 'origin/integration/mcp-events-20261109'…
rallymewrx Nov 13, 2026
b564470
fix(server): an unfreeze leaves a sleeping thread's snooze-held turns…
rallymewrx Nov 13, 2026
c5992fb
Merge integration/mcp-events-20261109 (#86, #96, #100) into r4/mcp-to…
rallymewrx Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 146 additions & 8 deletions apps/server/src/mcp/OrchestratorMcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1986,8 +1986,22 @@ describe("OrchestratorMcpService provider resolution", () => {
})
.pipe(Effect.flip);
assert.equal(byDriver.code, "provider_unavailable");
assert.isTrue(
byDriver.message.includes("No V2 provider adapter is registered for driver forkOnly."),
assert.include(
byDriver.message,
"No V2 provider adapter is registered for target.driverKind forkOnly. Drivers here: ",
);

const elsewhere = yield* service
.delegateTask(scope, {
task: "Summarize the diff.",
target: { projectId: ProjectId.make("project:elsewhere") },
mode: "async",
})
.pipe(Effect.flip);
assert.equal(elsewhere.code, "invalid_request");
assert.include(
elsewhere.message,
'use t3_thread_launch with projectId: "project:elsewhere"',
);
}).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies))));
}),
Expand Down Expand Up @@ -3982,6 +3996,7 @@ describe("OrchestratorMcpService thread lookup", () => {
Layer.mock(ThreadManagementService.ThreadManagementService)({
getThreadShell: (threadId) =>
Effect.succeed(shells.find((shell) => shell.id === threadId) ?? null),
listActiveShellIndex: () => Effect.succeed([]),
sendToThread: () => Ref.update(sent, (count) => count + 1).pipe(Effect.as({} as never)),
...overrides,
}),
Expand All @@ -4002,7 +4017,11 @@ describe("OrchestratorMcpService thread lookup", () => {
const sent = yield* Ref.make(0);
return yield* Effect.gen(function* () {
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
const read = yield* mcp.readThread(client, { threadId: bareId }).pipe(Effect.flip);
// Reads resolve a bare uuid to its mcp: thread, so only a miss fails.
const read = yield* mcp.readThread(client, { threadId: bareId }).pipe(
Effect.match({ onFailure: (error) => error, onSuccess: () => null }),
Effect.catchDefect(() => Effect.succeed(null)),
);
const send = yield* mcp
.sendToThread(client, { threadId: bareId, message: "hello" })
.pipe(Effect.flip);
Expand Down Expand Up @@ -4161,6 +4180,125 @@ describe("OrchestratorMcpService thread lookup", () => {
}),
);

it.effect("keeps a target's snooze unless told to wake it, and says so", () =>
Effect.gen(function* () {
const sent = yield* Ref.make(0);
const snoozedUntil = DateTime.makeUnsafe("2099-01-01T00:00:00Z");
const snoozed = { ...launched, snoozedUntil };
const dispatched: Array<unknown> = [];
const results = yield* Effect.gen(function* () {
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
return [
yield* mcp.sendToThread(client, { threadId: launched.id, message: "held" }),
yield* mcp.postToThread(client, { threadId: launched.id, message: "posted" }),
yield* mcp.sendToThread(client, {
threadId: launched.id,
message: "wake",
respectSnooze: false,
}),
];
}).pipe(
Effect.provide(
service([snoozed], sent, {
// The orchestrator keeps the snooze only for a sender that respects it.
getThreadShell: () =>
Effect.succeed(
dispatched.length === 0 ||
(dispatched.at(-1) as { respectSnooze?: boolean }).respectSnooze === true
? snoozed
: launched,
),
getProjectThreadRecords: () => Effect.succeed(idleThreadProjection(snoozed)),
dispatch: (command) =>
Effect.sync(() => {
dispatched.push(command);
return { sequence: 1, storedEvents: [] };
}),
sendToThread: (input) =>
Effect.sync(() => {
dispatched.push(input);
return {
delivery: "queued",
run: {
id: RunId.make("run:held"),
status: "queued",
...(input.respectSnooze ? { snoozeDeferred: true } : {}),
},
} as never;
}),
getThreadRecords: () =>
Effect.succeed(idleThreadProjection(snoozed) as OrchestrationV2ThreadProjection),
}),
),
);
expect(dispatched).toMatchObject([
{ respectSnooze: true },
{ postOnly: true, respectSnooze: true },
{ text: "wake" },
]);
expect((dispatched[2] as { respectSnooze?: boolean }).respectSnooze).toBeUndefined();
const [held, posted, woke] = results;
for (const result of results) {
expect(result.snoozedUntil).toBe("2099-01-01T00:00:00.000Z");
}
expect(held!.warning).toContain("waits, held, until it wakes");
expect(posted!.warning).toContain("stays snoozed");
expect(woke!.warning).toContain("ended the snooze");
}),
);

it.effect("reports where a queued send waits behind the active run", () =>
Effect.gen(function* () {
const sent = yield* Ref.make(0);
const startedAt = DateTime.makeUnsafe(0);
const runs = [
{
id: RunId.make("run:active"),
ordinal: 1,
status: "running",
requestedAt: startedAt,
startedAt,
},
{ id: RunId.make("run:ahead"), ordinal: 2, status: "queued", userMessageId: "m:ahead" },
{ id: RunId.make("run:mine"), ordinal: 3, status: "queued", userMessageId: "m:mine" },
];
const filters: Array<unknown> = [];
yield* TestClock.adjust("90 seconds");
const result = yield* Effect.gen(function* () {
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
return yield* mcp.sendToThread(client, { threadId: launched.id, message: "hello" });
}).pipe(
Effect.provide(
service([launched], sent, {
getProjectThreadRecords: () => Effect.succeed(idleThreadProjection(launched)),
sendToThread: () =>
Effect.succeed({
delivery: "queued",
run: { id: RunId.make("run:mine"), status: "queued" },
} as never),
getThreadRecords: (_threadId, _fields, filter) => {
filters.push(filter);
return Effect.succeed({
runs,
messages: [{ id: "m:ahead" }, { id: "m:mine" }],
} as unknown as OrchestrationV2ThreadProjection);
},
}),
),
);
assert.deepEqual(result.queue, {
position: 2,
messagesAhead: 1,
activeRunId: RunId.make("run:active"),
activeRunAgeSeconds: 90,
});
assert.deepEqual(filters, [
{ runStatuses: ["preparing", "starting", "running", "waiting", "queued"] },
{ messageIds: ["m:ahead", "m:mine"] },
]);
}),
);

it.effect(
"seeds coordinator rollover while leaving ordinary sends and clean resets unchanged",
() =>
Expand Down Expand Up @@ -4277,8 +4415,8 @@ describe("OrchestratorMcpService thread lookup", () => {

it.effect("points a bare uuid at the mcp: thread it belongs to", () =>
Effect.gen(function* () {
const { read, send, wait, sends } = yield* failuresFor([launched]);
for (const error of [read, send, wait]) {
const { send, wait, sends } = yield* failuresFor([launched]);
for (const error of [send, wait]) {
assert.equal(error.code, "thread_not_found");
assert.include(error.message, `mcp:${bareId}`);
}
Expand All @@ -4289,8 +4427,8 @@ describe("OrchestratorMcpService thread lookup", () => {
it.effect("keeps the plain message for an id that matches nothing", () =>
Effect.gen(function* () {
const { read, send, wait } = yield* failuresFor([]);
assert.equal(read.code, "thread_not_found");
assert.equal(read.message, `Thread ${bareId} is no longer available.`);
assert.equal(read?.code, "thread_not_found");
assert.include(read?.message, `No thread ${bareId} in this environment`);
assert.equal(send.code, "thread_not_found");
assert.equal(send.message, `Thread ${bareId} was not found.`);
assert.equal(wait.code, "thread_not_found");
Expand All @@ -4301,7 +4439,7 @@ describe("OrchestratorMcpService thread lookup", () => {
it.effect("does not name an mcp: thread that was deleted", () =>
Effect.gen(function* () {
const { read, send, wait } = yield* failuresFor([deletedLaunched]);
assert.equal(read.message, `Thread ${bareId} is no longer available.`);
assert.equal(read?.message, `Thread mcp:${bareId} was deleted.`);
assert.equal(send.message, `Thread ${bareId} was not found.`);
assert.equal(wait.message, send.message);
}),
Expand Down
Loading
Loading