| ... | ... | @@ -1165,15 +1165,6 @@ function textFromClaudeContent(content: SDKAssistantMessage["message"]["content" |
| 1165 | 1165 | return content.flatMap((part) => (part.type === "text" ? [part.text] : [])).join(""); |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | | // Claude 5.1 and later return the text written ahead of a tool call as a |
| 1169 | | // thinking block, at most one per call, instead of a text block. |
| 1170 | | function claudeWritesUpdatesAsThinking(model: string): boolean { |
| 1171 | | const match = /claude-[a-z]+-(\d+)(?:-(\d{1,2}))?(?!\d)/u.exec(model); |
| 1172 | | if (match === null) return false; |
| 1173 | | const major = Number(match[1]); |
| 1174 | | return major > 5 || (major === 5 && Number(match[2] ?? 0) >= 1); |
| 1175 | | } |
| 1176 | | |
| 1177 | 1168 | // In SDK mode Claude reports `/goal` only through the transcript (its |
| 1178 | 1169 | // `active_goal` event is remote-only): synthetic command output names the |
| 1179 | 1170 | // goal, and each unmet evaluator check returns as Stop hook feedback. |
| ... | ... | @@ -2915,12 +2906,6 @@ interface ActiveClaudeTurnContext { |
| 2915 | 2906 | readonly nextBlockIndex: Map<string, number>; |
| 2916 | 2907 | readonly snapshotBlockIndex: Map<string, number>; |
| 2917 | 2908 | readonly snapshots: Set<string>; |
| 2918 | | // The latest snapshot block, when it was non-empty thinking. |
| 2919 | | lastThinking: { |
| 2920 | | readonly messageId: string; |
| 2921 | | readonly itemId: string; |
| 2922 | | readonly text: string; |
| 2923 | | } | null; |
| 2924 | 2909 | readonly blocks: Map< |
| 2925 | 2910 | string, |
| 2926 | 2911 | { readonly startedAt: DateTime.Utc; readonly ordinal: number; text: string } |
| ... | ... | @@ -6862,23 +6847,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( |
| 6862 | 6847 | // The SDK emits one assistant snapshot per completed content block. |
| 6863 | 6848 | // Count thinking blocks separately so snapshots share the streamed ID. |
| 6864 | 6849 | for (const block of message.message.content) { |
| 6865 | | if (block.type !== "thinking") { |
| 6866 | | const update = context.reasoning.lastThinking; |
| 6867 | | context.reasoning.lastThinking = null; |
| 6868 | | if ( |
| 6869 | | block.type === "tool_use" && |
| 6870 | | update?.messageId === message.message.id && |
| 6871 | | claudeWritesUpdatesAsThinking(message.message.model) |
| 6872 | | ) { |
| 6873 | | // Same item ID, so the update replaces the Thought in place. |
| 6874 | | yield* emitAssistantTextArtifacts({ |
| 6875 | | context, |
| 6876 | | nativeItemId: update.itemId, |
| 6877 | | text: update.text, |
| 6878 | | }); |
| 6879 | | } |
| 6880 | | continue; |
| 6881 | | } |
| 6850 | if (block.type !== "thinking") continue; |
| 6882 | 6851 | const index = context.reasoning.snapshotBlockIndex.get(message.message.id) ?? 0; |
| 6883 | 6852 | context.reasoning.snapshotBlockIndex.set(message.message.id, index + 1); |
| 6884 | 6853 | const itemId = `${message.message.id}:thinking:${index}`; |
| ... | ... | @@ -6890,9 +6859,6 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( |
| 6890 | 6859 | ...(finalText ? { finalText } : {}), |
| 6891 | 6860 | emitEmpty: false, |
| 6892 | 6861 | }); |
| 6893 | | context.reasoning.lastThinking = finalText |
| 6894 | | ? { messageId: message.message.id, itemId, text: finalText } |
| 6895 | | : null; |
| 6896 | 6862 | } |
| 6897 | 6863 | } |
| 6898 | 6864 | |
| ... | ... | @@ -8587,7 +8553,6 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( |
| 8587 | 8553 | streamBlocks: new Map(), |
| 8588 | 8554 | nextBlockIndex: new Map(), |
| 8589 | 8555 | snapshotBlockIndex: new Map(), |
| 8590 | | lastThinking: null, |
| 8591 | 8556 | snapshots: new Set(), |
| 8592 | 8557 | blocks: new Map(), |
| 8593 | 8558 | }, |