Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import { applyClaudeCodeCompatibleThinkingDisplay } from "../services/claudeCodeCompatibleThinkingDisplay.ts";
import { hasActiveClaudeThinking } from "../utils/thinkingBudget.ts";
/** Pair active thinking with context management, then apply the native display opt-in. */
export function finalizeClaudeThinkingOptions(
body: Record<string, unknown>,
provider: string,
summarizeThinking: boolean
): void {
if (!hasActiveClaudeThinking(body)) return;
// Preserve the existing native/CC pairing so long sessions retain thinking context.
if (!body.context_management) {
body.context_management = {
edits: [{ type: "clear_thinking_20251015", keep: "all" }],
};
}
if (provider !== "claude") return;
const configuration = body.thinking as Record<string, unknown>;
body.thinking = applyClaudeCodeCompatibleThinkingDisplay(configuration, { summarizeThinking });
}