# Anthropic and OAuth wire quirks Status: accepted ## Context Anthropic OAuth tokens are accepted only with Claude Code tool-name casing. Tool ids must match `[a-zA-Z0-9_-]` while Codex ids look like `call|item`. Thinking from another provider (no signature, or a Codex reasoning item) is invalid. Cache breakpoints cover tools+system via the system block. The thinking budget counts against max_tokens. The token endpoint wants JSON for Anthropic and form encoding for OpenAI. Claude's login uses the PKCE verifier as state (matching Claude Code); Codex uses a random state. ## Decision Map tool names to Claude Code casing and sanitize ids on the way out; drop foreign thinking blocks; place rolling cache breakpoints on the last message and the user message before it (where the previous request's breakpoint sat, giving a cache read); keep max_tokens above the thinking budget; encode token requests per provider; follow each provider's state convention. ## Consequences Requests are accepted and cache well; conversion code must be kept in sync with these provider rules. Code: crates/hx-ai/src/anthropic.rs (tool names, id sanitizing, foreign thinking, cache breakpoints, thinking budget); crates/hx-ai/src/auth.rs (token request encoding, login state)