Spaces:
Paused
Paused
icebear0828 Claude Opus 4.6 commited on
Commit ·
be3ca8e
1
Parent(s): 6c4df8c
fix: support thinking.type "adaptive" for latest Claude Code
Browse filesClaude Code now sends thinking.type: "adaptive" (with optional
budget_tokens) instead of always "enabled"/"disabled". Added the
new variant to the Zod schema and translation logic.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
src/translation/anthropic-to-codex.ts
CHANGED
|
@@ -19,6 +19,10 @@ function mapThinkingToEffort(
|
|
| 19 |
thinking: AnthropicMessagesRequest["thinking"],
|
| 20 |
): string | undefined {
|
| 21 |
if (!thinking || thinking.type === "disabled") return undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
return budgetToEffort(thinking.budget_tokens);
|
| 23 |
}
|
| 24 |
|
|
|
|
| 19 |
thinking: AnthropicMessagesRequest["thinking"],
|
| 20 |
): string | undefined {
|
| 21 |
if (!thinking || thinking.type === "disabled") return undefined;
|
| 22 |
+
if (thinking.type === "adaptive") {
|
| 23 |
+
// adaptive: use budget_tokens if provided, otherwise let Codex decide
|
| 24 |
+
return thinking.budget_tokens ? budgetToEffort(thinking.budget_tokens) : undefined;
|
| 25 |
+
}
|
| 26 |
return budgetToEffort(thinking.budget_tokens);
|
| 27 |
}
|
| 28 |
|
src/types/anthropic.ts
CHANGED
|
@@ -59,6 +59,11 @@ const AnthropicThinkingDisabledSchema = z.object({
|
|
| 59 |
type: z.literal("disabled"),
|
| 60 |
});
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
export const AnthropicMessagesRequestSchema = z.object({
|
| 63 |
model: z.string(),
|
| 64 |
max_tokens: z.number().int().positive(),
|
|
@@ -77,7 +82,11 @@ export const AnthropicMessagesRequestSchema = z.object({
|
|
| 77 |
})
|
| 78 |
.optional(),
|
| 79 |
thinking: z
|
| 80 |
-
.union([
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
.optional(),
|
| 82 |
// Tool-related fields (accepted for compatibility, not forwarded to Codex)
|
| 83 |
tools: z.array(z.object({
|
|
|
|
| 59 |
type: z.literal("disabled"),
|
| 60 |
});
|
| 61 |
|
| 62 |
+
const AnthropicThinkingAdaptiveSchema = z.object({
|
| 63 |
+
type: z.literal("adaptive"),
|
| 64 |
+
budget_tokens: z.number().int().positive().optional(),
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
export const AnthropicMessagesRequestSchema = z.object({
|
| 68 |
model: z.string(),
|
| 69 |
max_tokens: z.number().int().positive(),
|
|
|
|
| 82 |
})
|
| 83 |
.optional(),
|
| 84 |
thinking: z
|
| 85 |
+
.union([
|
| 86 |
+
AnthropicThinkingEnabledSchema,
|
| 87 |
+
AnthropicThinkingDisabledSchema,
|
| 88 |
+
AnthropicThinkingAdaptiveSchema,
|
| 89 |
+
])
|
| 90 |
.optional(),
|
| 91 |
// Tool-related fields (accepted for compatibility, not forwarded to Codex)
|
| 92 |
tools: z.array(z.object({
|