Spaces:
Paused
Paused
icebear0828 Claude Opus 4.6 commited on
Commit ·
ca7b1cb
1
Parent(s): 2029dd9
fix: support thinking/redacted_thinking content blocks in Anthropic schema
Browse filesClaude Code /compact sends conversation history containing thinking and
redacted_thinking content blocks which were rejected by the Zod schema.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- src/types/anthropic.ts +14 -0
src/types/anthropic.ts
CHANGED
|
@@ -33,11 +33,25 @@ const AnthropicToolResultContentSchema = z.object({
|
|
| 33 |
is_error: z.boolean().optional(),
|
| 34 |
});
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
const AnthropicContentBlockSchema = z.discriminatedUnion("type", [
|
| 37 |
AnthropicTextContentSchema,
|
| 38 |
AnthropicImageContentSchema,
|
| 39 |
AnthropicToolUseContentSchema,
|
| 40 |
AnthropicToolResultContentSchema,
|
|
|
|
|
|
|
| 41 |
]);
|
| 42 |
|
| 43 |
const AnthropicContentSchema = z.union([
|
|
|
|
| 33 |
is_error: z.boolean().optional(),
|
| 34 |
});
|
| 35 |
|
| 36 |
+
// Extended thinking content blocks (sent back in conversation history)
|
| 37 |
+
const AnthropicThinkingContentSchema = z.object({
|
| 38 |
+
type: z.literal("thinking"),
|
| 39 |
+
thinking: z.string(),
|
| 40 |
+
signature: z.string().optional(),
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
const AnthropicRedactedThinkingContentSchema = z.object({
|
| 44 |
+
type: z.literal("redacted_thinking"),
|
| 45 |
+
data: z.string(),
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
const AnthropicContentBlockSchema = z.discriminatedUnion("type", [
|
| 49 |
AnthropicTextContentSchema,
|
| 50 |
AnthropicImageContentSchema,
|
| 51 |
AnthropicToolUseContentSchema,
|
| 52 |
AnthropicToolResultContentSchema,
|
| 53 |
+
AnthropicThinkingContentSchema,
|
| 54 |
+
AnthropicRedactedThinkingContentSchema,
|
| 55 |
]);
|
| 56 |
|
| 57 |
const AnthropicContentSchema = z.union([
|