Skip to content

Commit 54c8e11

Browse files
fix(v2): keep main's maintenance-command matching
Main now checks /compact and /logout case-insensitively and restart continuation relies on that. The predicate only moves to CommandPolicy, so it keeps main's definition, and RestartContinuation imports it from there. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent f1d5024 commit 54c8e11

2 files changed

Lines changed: 4 additions & 30 deletions

File tree

‎apps/server/src/orchestration-v2/CommandPolicy.test.ts‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ it("targets the latest active run for explicit steer and restart intent", () =>
143143
);
144144
});
145145

146-
it.each(["/compact", " /COMPACT ", "/logout"])(
146+
it.each(["/compact", " /COMPACT ", "/logout", " /LOGOUT "])(
147147
"queues automatic follow-ups behind %s and preserves explicit intent",
148148
(text) => {
149149
const messageId = MessageId.make("command-policy-compaction-message");
@@ -184,32 +184,6 @@ it.each(["/compact", " /COMPACT ", "/logout"])(
184184
},
185185
);
186186

187-
it.each(["/Logout", "/LOGOUT"])("preserves ordinary delivery for %s", (text) => {
188-
const messageId = MessageId.make("command-policy-mixed-case-message");
189-
const base = dispatchProjection(baseCapabilities);
190-
const projection = {
191-
...base,
192-
runs: base.runs.map((run) => ({ ...run, userMessageId: messageId })),
193-
messages: [{ id: messageId, role: "user", text, attachments: [] }],
194-
} as unknown as OrchestrationV2ThreadProjection;
195-
assert.deepEqual(
196-
CommandPolicy.resolveMessageDispatchIntent(projection, { type: "start_immediately" }, "auto"),
197-
{ type: "steer_active", targetRunId: activeRunId },
198-
);
199-
assert.deepEqual(
200-
CommandPolicy.resolveMessageDispatchIntent(projection, { type: "start_immediately" }, "steer"),
201-
{ type: "steer_active", targetRunId: activeRunId },
202-
);
203-
assert.deepEqual(
204-
CommandPolicy.resolveMessageDispatchIntent(
205-
projection,
206-
{ type: "start_immediately" },
207-
"restart",
208-
),
209-
{ type: "restart_active", targetRunId: activeRunId },
210-
);
211-
});
212-
213187
it("keeps steering an ordinary run alongside a compacted message in history", () => {
214188
const messageId = MessageId.make("command-policy-ordinary-message");
215189
const base = dispatchProjection(baseCapabilities);

‎apps/server/src/orchestration-v2/CommandPolicy.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ type MessageDispatchMode = Extract<
117117
{ readonly type: "message.dispatch" }
118118
>["dispatchMode"];
119119

120-
/** Native commands the provider executes as its own whole-turn task, so they
121-
* own the run they start and cannot take steering or a restart. */
120+
/** A native /compact or /logout turn: provider maintenance, not agent work. It
121+
* owns the run it starts and cannot take steering or a restart. */
122122
export function isNativeMaintenanceCommand(message: {
123123
readonly text: string;
124124
readonly attachments: ReadonlyArray<ChatAttachment>;
125125
}): boolean {
126126
return (
127127
message.attachments.length === 0 &&
128-
(message.text.trim().toLowerCase() === "/compact" || message.text.trim() === "/logout")
128+
["/compact", "/logout"].includes(message.text.trim().toLowerCase())
129129
);
130130
}
131131

0 commit comments

Comments
 (0)