Skip to content

Commit a700865

Browse files
fix(provider-muse): invoke skills on a thread's first message again
The first-turn guard sent every new thread's skill mention as text, so user-only skills still could not run from a first message. Remove it and restore first-turn structured skill dispatch. AI-assisted; verified with the tests and tools listed above.
1 parent a83e6b0 commit a700865

3 files changed

Lines changed: 24 additions & 37 deletions

File tree

‎docs/user/providers-muse.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ on the host. Skill changes may take up to five minutes to appear as you type in
5757
the composer. See [Commands and skills](./composer.md#commands-and-skills) for
5858
restarting an active agent after changes. When a message mentions several skills,
5959
T3 Code invokes the first one available in the Muse session with the full message.
60-
A thread's first message and follow-up steering messages send skill mentions as
61-
text, which Muse loads only for skills the model may invoke.
60+
Follow-up steering messages stay as text.
6261

6362
Forking a Muse conversation starts a new session with a copy of the conversation
6463
context. Conversation rewind is unavailable.

‎packages/provider-muse/src/server/adapter.test.ts‎

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -386,30 +386,23 @@ const approval = (turnId: string) => ({
386386
vi.mock("node:fs/promises", { spy: true });
387387

388388
describe("MuseAdapterV2", () => {
389-
const afterFirstTurn = Effect.fnUntraced(function* (
390-
fake: Effect.Success<ReturnType<typeof makeFakeMuse>>,
391-
text: string,
392-
) {
393-
const harness = yield* makeHarness(fake);
394-
const first = yield* startConversation(harness, fake);
395-
yield* fake.emit("turn/completed", { turnId: first.nativeId, terminal: "completed" });
396-
yield* harness.takeEvent("turn.terminal");
397-
const base = yield* turnInput(harness.providerThread, 2);
398-
const input = { ...base, message: { ...base.message, text } };
399-
yield* harness.runtime.startTurn(input);
400-
return { input, call: yield* fake.takeCall("turn/start") };
401-
});
402-
403389
it.effect("invokes only the first live skill with the unchanged request as arguments", () =>
404390
Effect.gen(function* () {
405391
const fake = yield* makeFakeMuse();
406392
fake.queueResponse("skill/list", {
407393
skills: [{ selector: "architect" }, { selector: "ai-ugc:ugc-mode" }],
408394
});
409-
const { input, call } = yield* afterFirstTurn(
410-
fake,
411-
"Please $nope then $ai-ugc:ugc-mode tidy $architect $ai-ugc:ugc-mode",
412-
);
395+
const harness = yield* makeHarness(fake);
396+
const base = yield* turnInput(harness.providerThread);
397+
const input = {
398+
...base,
399+
message: {
400+
...base.message,
401+
text: "Please $nope then $ai-ugc:ugc-mode tidy $architect $ai-ugc:ugc-mode",
402+
},
403+
};
404+
yield* harness.runtime.startTurn(input);
405+
const call = yield* fake.takeCall("turn/start");
413406
const parts = call.params.input as Array<{
414407
type: string;
415408
selector?: string;
@@ -427,29 +420,26 @@ describe("MuseAdapterV2", () => {
427420
}).pipe(Effect.scoped, Effect.provide(testLayer)),
428421
);
429422

430-
it.effect("keeps first-turn, plain and unavailable skill requests as text", () =>
423+
it.effect("keeps plain and unavailable skill requests as text", () =>
431424
Effect.gen(function* () {
432-
for (const [text, response, firstTurn] of [
433-
["$git tidy", { skills: [{ selector: "git" }] }, true],
434-
["Tidy the changes", { skills: [{ selector: "git" }] }, false],
435-
["$git tidy $nope", { skills: [{ selector: "architect" }] }, false],
436-
["$git tidy $nope", new Error("listing failed"), false],
425+
for (const [text, response] of [
426+
["Tidy the changes", { skills: [{ selector: "git" }] }],
427+
["$git tidy $nope", { skills: [{ selector: "architect" }] }],
428+
["$git tidy $nope", new Error("listing failed")],
437429
] as const) {
438430
const fake = yield* makeFakeMuse();
439431
fake.queueResponse("skill/list", response);
440-
let call;
441-
if (firstTurn) {
442-
const harness = yield* makeHarness(fake);
443-
const base = yield* turnInput(harness.providerThread);
444-
yield* harness.runtime.startTurn({ ...base, message: { ...base.message, text } });
445-
call = yield* fake.takeCall("turn/start");
446-
} else call = (yield* afterFirstTurn(fake, text)).call;
432+
const harness = yield* makeHarness(fake);
433+
const base = yield* turnInput(harness.providerThread);
434+
const input = { ...base, message: { ...base.message, text } };
435+
yield* harness.runtime.startTurn(input);
436+
const call = yield* fake.takeCall("turn/start");
447437
const parts = call.params.input as Array<{ type: string; text?: string }>;
448438
assert.isTrue(parts.every((part) => part.type === "text"));
449-
assert.strictEqual(parts.at(-1)?.text, text);
439+
assert.strictEqual(parts.at(-1)?.text, input.message.text);
450440
assert.strictEqual(
451441
fake.calls.filter((call) => call.method === "skill/list").length,
452-
text.startsWith("$") && !firstTurn ? 1 : 0,
442+
text.startsWith("$") ? 1 : 0,
453443
);
454444
}
455445
}).pipe(Effect.scoped, Effect.provide(testLayer)),

‎packages/provider-muse/src/server/adapter.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,8 +2031,6 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
20312031
);
20322032
});
20332033
const resolveSkillSelector = Effect.fnUntraced(function* (text: string) {
2034-
// Muse fails a structured skill on a thread's first turn; that turn keeps the text form.
2035-
if (thread?.firstRunOrdinal == null) return undefined;
20362034
const mentions = [...text.matchAll(SKILL_MENTION_PATTERN)];
20372035
if (!mentions.length) return undefined;
20382036
// An optional catalog timeout must not close the host needed for the text fallback.

0 commit comments

Comments
 (0)