@devries-cameron20 / t3code-1 / commits / 2b00ab1679
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(claude): mid-sentence skill chips keep the full request (#15253)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Scott Norteman committed Oct 19, 2026 at 14:08 UTC 2b00ab1679449c53eae05b731b0505c439477514
4 files changed +191 -154
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+177 -141
@@ -1601,153 +1601,189 @@ describe("ClaudeAdapterV2 resume compaction", () => {
1601 });
1602
1603 describe("ClaudeAdapterV2 attachments", () => {
1604 - it.effect("forwards images and references generic files on sends and steering", () =>
1605 - Effect.scoped(
1606 - Effect.gen(function* () {
1607 - const fileSystem = yield* FileSystem.FileSystem;
1608 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1609 - const path = yield* Path.Path;
1610 - const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({
1611 - prefix: "t3-claude-v2-attachments-",
1612 - });
1613 - const offeredMessages: Array<SDKUserMessage> = [];
1614 - const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
1615 - instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
1616 - settings: DEFAULT_CLAUDE_SETTINGS,
1617 - environment: {},
1618 - attachmentsDir,
1619 - fileSystem,
1620 - path: yield* Path.Path,
1621 - crypto: yield* Crypto.Crypto,
1622 - idAllocator,
1623 - queryRunner: {
1624 - allocateSessionId: Effect.succeed("native-thread-claude-attachments"),
1625 - open: () =>
1626 - Effect.succeed({
1627 - messages: Stream.never,
1628 - offer: (message) =>
1629 - Effect.sync(() => {
1630 - offeredMessages.push(message);
1631 - }),
1632 - setModel: () => Effect.void,
1633 - applyFlagSettings: () => Effect.void,
1634 - setPermissionMode: () => Effect.void,
1635 - backgroundTasks: () => Effect.succeed(false),
1636 - stopTask: () => Effect.void,
1637 - interrupt: Effect.void,
1638 - close: Effect.void,
1639 - }),
1640 - forkSession: () => Effect.die("unused forkSession"),
1641 - subagentLaunchToolUseId: () => Effect.succeed(null),
1642 - assertComplete: Effect.void,
1643 - },
1644 - });
1645 - const threadId = ThreadId.make("thread-claude-attachments");
1646 - const providerSessionId = ProviderSessionId.make("provider-session-claude-attachments");
1647 - const runtime = yield* adapter.openSession({
1648 - threadId,
1649 - providerSessionId,
1650 - modelSelection: CLAUDE_TEST_MODEL_SELECTION,
1651 - runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
1652 - });
1653 - const providerThread = yield* runtime.ensureThread({
1654 - threadId,
1655 - modelSelection: CLAUDE_TEST_MODEL_SELECTION,
1656 - runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
1657 - });
1658 - const attachment = ChatImageAttachment.make({
1659 - type: "image",
1660 - id: ChatAttachmentId.make(
1661 - "thread-claude-attachments-12345678-1234-1234-1234-123456789abc",
1662 - ),
1663 - name: "diagram.png",
1664 - mimeType: "image/png",
1665 - sizeBytes: 4,
1666 - });
1667 - const document = ChatFileAttachment.make({
1668 - type: "file",
1669 - id: ChatAttachmentId.make(
1670 - "thread-claude-attachments-abcdefab-1234-1234-1234-123456789abc",
1671 - ),
1672 - name: "requirements.pdf",
1673 - mimeType: "application/pdf",
1674 - sizeBytes: 4,
1675 - });
1676 - yield* fileSystem.writeFile(
1677 - path.join(attachmentsDir, attachmentRelativePath(attachment)!),
1678 - Uint8Array.from([1, 2, 3, 4]),
1679 - );
1680 - yield* fileSystem.writeFile(
1681 - path.join(attachmentsDir, attachmentRelativePath(document)!),
1682 - Uint8Array.from([5, 6, 7, 8]),
1683 - );
1684 - const attemptId = RunAttemptId.make("attempt-claude-attachments");
1685 - const now = yield* DateTime.now;
1686 -
1687 - yield* runtime.startTurn(
1688 - makeClaudeTestTurnInput({
1604 + it.effect.each([
1605 + {
1606 + name: "ordinary text",
1607 + prompt: "What’s in this image?",
1608 + expectedText: "Ultrathink:\nWhat’s in this image?",
1609 + command: undefined,
1610 + ultrathink: true,
1611 + },
1612 + {
1613 + name: "mid-sentence skill",
1614 + prompt: "please $implement fixes\n\nThen report the result",
1615 + expectedText: "Ultrathink:\nplease /implement fixes\n\nThen report the result",
1616 + command: "/implement fixes\n\nThen report the result",
1617 + ultrathink: true,
1618 + },
1619 + {
1620 + name: "prompt-leading skill",
1621 + prompt: "$implement fixes",
1622 + expectedText: "/implement fixes",
1623 + command: undefined,
1624 + ultrathink: false,
1625 + },
1626 + ])(
1627 + "preserves $name with images and files on sends and steering",
1628 + ({ prompt, expectedText, command, ultrathink }) =>
1629 + Effect.scoped(
1630 + Effect.gen(function* () {
1631 + const fileSystem = yield* FileSystem.FileSystem;
1632 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
1633 + const path = yield* Path.Path;
1634 + const claudeHome = yield* fileSystem.makeTempDirectoryScoped({
1635 + prefix: "t3-claude-v2-skills-home-",
1636 + });
1637 + yield* fileSystem.makeDirectory(path.join(claudeHome, "skills", "implement"), {
1638 + recursive: true,
1639 + });
1640 + yield* fileSystem.writeFileString(
1641 + path.join(claudeHome, "skills", "implement", "SKILL.md"),
1642 + "---\ndescription: Implement the requested change\n---\nImplement it.\n",
1643 + );
1644 + const modelSelection = {
1645 + ...CLAUDE_TEST_MODEL_SELECTION,
1646 + options: ultrathink ? CLAUDE_TEST_MODEL_SELECTION.options : [],
1647 + };
1648 + const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({
1649 + prefix: "t3-claude-v2-attachments-",
1650 + });
1651 + const offeredMessages: Array<SDKUserMessage> = [];
1652 + const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
1653 + instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
1654 + settings: { ...DEFAULT_CLAUDE_SETTINGS, homePath: claudeHome },
1655 + environment: {},
1656 + attachmentsDir,
1657 + fileSystem,
1658 + path: yield* Path.Path,
1659 + crypto: yield* Crypto.Crypto,
1660 + idAllocator,
1661 + queryRunner: {
1662 + allocateSessionId: Effect.succeed("native-thread-claude-attachments"),
1663 + open: () =>
1664 + Effect.succeed({
1665 + messages: Stream.never,
1666 + offer: (message) =>
1667 + Effect.sync(() => {
1668 + offeredMessages.push(message);
1669 + }),
1670 + setModel: () => Effect.void,
1671 + applyFlagSettings: () => Effect.void,
1672 + setPermissionMode: () => Effect.void,
1673 + backgroundTasks: () => Effect.succeed(false),
1674 + stopTask: () => Effect.void,
1675 + interrupt: Effect.void,
1676 + close: Effect.void,
1677 + }),
1678 + forkSession: () => Effect.die("unused forkSession"),
1679 + subagentLaunchToolUseId: () => Effect.succeed(null),
1680 + assertComplete: Effect.void,
1681 + },
1682 + });
1683 + const threadId = ThreadId.make("thread-claude-attachments");
1684 + const providerSessionId = ProviderSessionId.make("provider-session-claude-attachments");
1685 + const runtime = yield* adapter.openSession({
1686 threadId,
1690 - providerThread,
1691 - now,
1692 - attemptId,
1693 - text: "What's in this image?",
1694 - attachments: [attachment, document],
1695 - }),
1696 - );
1687 + providerSessionId,
1688 + modelSelection,
1689 + runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
1690 + });
1691 + const providerThread = yield* runtime.ensureThread({
1692 + threadId,
1693 + modelSelection,
1694 + runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
1695 + });
1696 + const attachment = ChatImageAttachment.make({
1697 + type: "image",
1698 + id: ChatAttachmentId.make(
1699 + "thread-claude-attachments-12345678-1234-1234-1234-123456789abc",
1700 + ),
1701 + name: "diagram.png",
1702 + mimeType: "image/png",
1703 + sizeBytes: 4,
1704 + });
1705 + const document = ChatFileAttachment.make({
1706 + type: "file",
1707 + id: ChatAttachmentId.make(
1708 + "thread-claude-attachments-abcdefab-1234-1234-1234-123456789abc",
1709 + ),
1710 + name: "requirements.pdf",
1711 + mimeType: "application/pdf",
1712 + sizeBytes: 4,
1713 + });
1714 + yield* fileSystem.writeFile(
1715 + path.join(attachmentsDir, attachmentRelativePath(attachment)!),
1716 + Uint8Array.from([1, 2, 3, 4]),
1717 + );
1718 + yield* fileSystem.writeFile(
1719 + path.join(attachmentsDir, attachmentRelativePath(document)!),
1720 + Uint8Array.from([5, 6, 7, 8]),
1721 + );
1722 + const attemptId = RunAttemptId.make("attempt-claude-attachments");
1723 + const now = yield* DateTime.now;
1724
1698 - const expectedImageBlock = {
1699 - type: "image",
1700 - source: {
1701 - type: "base64",
1702 - media_type: "image/png",
1703 - data: "AQIDBA==",
1704 - },
1705 - } as const;
1706 - const expectedAttachmentPath = path.join(
1707 - attachmentsDir,
1708 - attachmentRelativePath(attachment)!,
1709 - );
1710 - const expectedDocumentPath = path.join(attachmentsDir, attachmentRelativePath(document)!);
1711 - assert.deepEqual(offeredMessages[0]?.message.content, [
1712 - expectedImageBlock,
1713 - {
1714 - type: "text",
1715 - text: `Ultrathink:\nWhat's in this image?\n\n[Attached image "diagram.png" is saved at: ${expectedAttachmentPath}]\n\n[Attached file "requirements.pdf" is saved at: ${expectedDocumentPath}]`,
1716 - },
1717 - ]);
1725 + yield* runtime.startTurn(
1726 + makeClaudeTestTurnInput({
1727 + threadId,
1728 + providerThread,
1729 + now,
1730 + attemptId,
1731 + modelSelection,
1732 + text: prompt,
1733 + attachments: [attachment, document],
1734 + }),
1735 + );
1736
1719 - const providerTurnId = idAllocator.derive.providerTurn({
1720 - driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
1721 - nativeTurnId: `turn:${attemptId}`,
1722 - });
1723 - yield* runtime.steerTurn({
1724 - threadId,
1725 - runId: RunId.make("run-claude-attachments"),
1726 - providerThread,
1727 - providerTurnId,
1728 - message: {
1729 - createdBy: "user",
1730 - creationSource: "web",
1731 - messageId: MessageId.make("message-claude-attachments-steer"),
1732 - text: "Focus on the diagram labels.",
1733 - attachments: [attachment, document],
1734 - },
1735 - });
1737 + const expectedImageBlock = {
1738 + type: "image",
1739 + source: {
1740 + type: "base64",
1741 + media_type: "image/png",
1742 + data: "AQIDBA==",
1743 + },
1744 + } as const;
1745 + const expectedAttachmentPath = path.join(
1746 + attachmentsDir,
1747 + attachmentRelativePath(attachment)!,
1748 + );
1749 + const expectedDocumentPath = path.join(attachmentsDir, attachmentRelativePath(document)!);
1750 + const attachmentNotes = `\n\n[Attached image "diagram.png" is saved at: ${expectedAttachmentPath}]\n\n[Attached file "requirements.pdf" is saved at: ${expectedDocumentPath}]`;
1751 + const requestBlock = { type: "text" as const, text: expectedText + attachmentNotes };
1752 + const expectedContent = command
1753 + ? [
1754 + requestBlock,
1755 + expectedImageBlock,
1756 + { type: "text" as const, text: command + attachmentNotes },
1757 + ]
1758 + : [expectedImageBlock, requestBlock];
1759 + assert.deepEqual(offeredMessages[0]?.message.content, expectedContent);
1760
1737 - assert.equal(offeredMessages[1]?.priority, "now");
1738 - assert.deepEqual(offeredMessages[1]?.message.content, [
1739 - expectedImageBlock,
1740 - {
1741 - type: "text",
1742 - text: `Ultrathink:\nFocus on the diagram labels.\n\n[Attached image "diagram.png" is saved at: ${expectedAttachmentPath}]\n\n[Attached file "requirements.pdf" is saved at: ${expectedDocumentPath}]`,
1743 - },
1744 - ]);
1745 - }).pipe(
1746 - Effect.provide(
1747 - Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
1761 + const providerTurnId = idAllocator.derive.providerTurn({
1762 + driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
1763 + nativeTurnId: `turn:${attemptId}`,
1764 + });
1765 + yield* runtime.steerTurn({
1766 + threadId,
1767 + runId: RunId.make("run-claude-attachments"),
1768 + providerThread,
1769 + providerTurnId,
1770 + message: {
1771 + createdBy: "user",
1772 + creationSource: "web",
1773 + messageId: MessageId.make("message-claude-attachments-steer"),
1774 + text: prompt,
1775 + attachments: [attachment, document],
1776 + },
1777 + });
1778 +
1779 + assert.equal(offeredMessages[1]?.priority, "now");
1780 + assert.deepEqual(offeredMessages[1]?.message.content, expectedContent);
1781 + }).pipe(
1782 + Effect.provide(
1783 + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
1784 + ),
1785 ),
1786 ),
1750 - ),
1787 );
1788
1789 it.effect("rejects unsupported image types before opening a provider query", () =>
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+4 -3
@@ -1596,9 +1596,10 @@ export function makeClaudeUserMessage(input: {
1596 readonly uuid?: SDKUserMessage["uuid"];
1597 }): SDKUserMessage {
1598 // Claude Code expands a skill only from the LAST text block, and only when
1599 - // `/name` is its first character. A `$skill` chip anywhere in the prompt is
1600 - // therefore split into [leading text, "/name trailing text"] so the CLI runs
1601 - // it natively and the prose around it survives.
1599 + // `/name` is its first character. A `$skill` chip anywhere in the prompt
1600 + // therefore becomes [whole request, "/name trailing text"] so the CLI runs
1601 + // it natively and the model still reads the full request. See
1602 + // ClaudeSkillDispatch.
1603 const dispatch =
1604 input.skillNames === undefined
1605 ? undefined
apps/server/src/provider/Drivers/ClaudeSkillDispatch.test.ts
+5 -5
@@ -10,9 +10,9 @@ describe("planClaudeSkillDispatch", () => {
10 expect(planClaudeSkillDispatch("echo $HOME then $unknown", SKILLS)).toBeUndefined();
11 });
12
13 - it("moves a mid-prompt mention into a trailing slash command", () => {
13 + it("keeps the whole request ahead of a mid-prompt slash command", () => {
14 expect(planClaudeSkillDispatch("ok, now $implement all the tickets", SKILLS)).toEqual({
15 - leadingText: "ok, now",
15 + leadingText: "ok, now /implement all the tickets",
16 commandText: "/implement all the tickets",
17 skillName: "implement",
18 });
@@ -28,7 +28,7 @@ describe("planClaudeSkillDispatch", () => {
28
29 it("dispatches a known skill whose name begins with a digit", () => {
30 expect(planClaudeSkillDispatch("use $2spec for this", SKILLS)).toEqual({
31 - leadingText: "use",
31 + leadingText: "use /2spec for this",
32 commandText: "/2spec for this",
33 skillName: "2spec",
34 });
@@ -36,7 +36,7 @@ describe("planClaudeSkillDispatch", () => {
36
37 it("dispatches the last mention and rewrites earlier ones inline", () => {
38 expect(planClaudeSkillDispatch("$review the diff, then $implement the fixes", SKILLS)).toEqual({
39 - leadingText: "/review the diff, then",
39 + leadingText: "/review the diff, then /implement the fixes",
40 commandText: "/implement the fixes",
41 skillName: "implement",
42 });
@@ -50,7 +50,7 @@ describe("planClaudeSkillDispatch", () => {
50 SKILLS,
51 ),
52 ).toEqual({
53 - leadingText: "/review the diff, then",
53 + leadingText: "/review the diff, then /implement the fixes",
54 commandText: "/implement the fixes",
55 skillName: "implement",
56 });
apps/server/src/provider/Drivers/ClaudeSkillDispatch.ts
+5 -5
@@ -15,6 +15,7 @@ const SKILL_MENTION_PATTERN =
15 /(^|\s)\p{Sc}(?![0-9][0-9_]*(?:[kKmMbBtT]|[eE][0-9]+)?(?:\s|$))(?=[a-zA-Z0-9:_-]*[a-zA-Z])([a-zA-Z0-9][a-zA-Z0-9:_-]*)(?=\s|$)/gu;
16
17 export interface ClaudeSkillDispatch {
18 + /** The whole prompt with mentions as `/name`, or `undefined` when the mention opens it. */
19 readonly leadingText: string | undefined;
20 /** `/name` plus the trailing text, ready to be the message's last text block. */
21 readonly commandText: string;
@@ -36,19 +37,18 @@ export function planClaudeSkillDispatch(
37 return undefined;
38 }
39
39 - const leading = prompt.slice(0, last.start);
40 const trailing = prompt.slice(last.end);
41 - const leadingWithInlineSlashes = mentions
42 - .slice(0, -1)
41 + const promptWithInlineSlashes = mentions
42 .reduceRight(
43 (text, mention) =>
44 `${text.slice(0, mention.start)}/${mention.name}${text.slice(mention.end)}`,
46 - leading,
45 + prompt,
46 )
47 .trimEnd();
48
49 return {
51 - leadingText: leadingWithInlineSlashes.length > 0 ? leadingWithInlineSlashes : undefined,
50 + leadingText:
51 + prompt.slice(0, last.start).trim().length > 0 ? promptWithInlineSlashes : undefined,
52 commandText: `/${last.name}${trailing}`.trimEnd(),
53 skillName: last.name,
54 };