@@ -2631,12 +2631,15 @@ export function makeClaudeUserMessage(input: {
26312631 readonly text: string;
26322632 readonly priority?: SDKUserMessage["priority"];
26332633 readonly skills?: ReadonlyMap<string, ClaudeSkillTarget>;
2634+ readonly skillMentionsFrom?: number;
26342635 readonly uuid?: SDKUserMessage["uuid"];
26352636}): SDKUserMessage {
26362637 // Claude expands a skill only when `/name` starts the last text block.
26372638 // Keep the whole request before that block; see ClaudeSkillDispatch.
26382639 const dispatch =
2639- input.skills === undefined ? undefined : planClaudeSkillDispatch(input.text, input.skills);
2640+ input.skills === undefined
2641+ ? undefined
2642+ : planClaudeSkillDispatch(input.text, input.skills, input.skillMentionsFrom);
26402643 // Claude runs `/goal` only when it opens the prompt, so a goal stays one block.
26412644 const isGoalCommand = parseGoalCommand({ text: input.text }) !== null;
26422645 return {
@@ -2801,11 +2804,15 @@ const makeClaudeUserMessageWithAttachments = Effect.fnUntraced(function* (input:
28012804 readonly fileSystem: FileSystem.FileSystem;
28022805 readonly pdfReservation: Effect.Success<ReturnType<typeof reserveClaudePdfBudget>>;
28032806 readonly skills?: ReadonlyMap<string, ClaudeSkillTarget>;
2807+ readonly skillMentionsFrom?: number;
28042808}) {
28052809 if (input.attachments.length === 0) {
28062810 const message = makeClaudeUserMessage({
28072811 text: input.text,
28082812 ...(input.skills === undefined ? {} : { skills: input.skills }),
2813+ ...(input.skillMentionsFrom === undefined
2814+ ? {}
2815+ : { skillMentionsFrom: input.skillMentionsFrom }),
28092816 ...(input.priority === undefined ? {} : { priority: input.priority }),
28102817 ...(input.uuid === undefined ? {} : { uuid: input.uuid }),
28112818 });
@@ -2829,7 +2836,7 @@ const makeClaudeUserMessageWithAttachments = Effect.fnUntraced(function* (input:
28292836 const dispatch =
28302837 input.skills === undefined
28312838 ? undefined
2832- : planClaudeSkillDispatch(textWithAttachmentPaths, input.skills);
2839+ : planClaudeSkillDispatch(textWithAttachmentPaths, input.skills, input.skillMentionsFrom );
28332840 const content: Array<ClaudeUserContentBlock> = [];
28342841 // Base64 adds a third to the payload. Leave room below Anthropic's 32 MB
28352842 // request limit for text, instructions, and SDK framing. The SDK does not
@@ -12422,15 +12429,24 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1242212429 pdfBudgets.get(nativeThreadId)!,
1242312430 persistAttachmentBudget(nativeThreadId),
1242412431 );
12432+ const promptText = applyClaudePromptEffortPrefix(
12433+ turnInput.message.text,
12434+ compileClaudeModelSelection(turnInput.modelSelection, modelCatalog).promptEffort,
12435+ );
1242512436 const userMessage =
1242612437 promptUuid === null
1242712438 ? null
1242812439 : yield* makeClaudeUserMessageWithAttachments({
12429- text: applyClaudePromptEffortPrefix(
12430- turnInput.message.text,
12431- compileClaudeModelSelection(turnInput.modelSelection, modelCatalog)
12432- .promptEffort,
12433- ),
12440+ text: promptText,
12441+ // Mentions in inline handoff history are history, not this turn's skill.
12442+ ...(turnInput.inlineContextLength === undefined
12443+ ? {}
12444+ : {
12445+ skillMentionsFrom:
12446+ promptText.length -
12447+ turnInput.message.text.slice(turnInput.inlineContextLength).trimEnd()
12448+ .length,
12449+ }),
1243412450 attachments: turnInput.message.attachments,
1243512451 attachmentsDir,
1243612452 fileSystem,
0 commit comments