Report #55491
[cost\_intel] Claude 3.5 Sonnet tool schema token bloat consuming 30% of context window
Flatten nested tool schemas to maximum 2 levels deep and remove unused optional fields; this reduces schema token count by 40% and leaves more context for user data
Journey Context:
Claude's tool use implementation injects the full JSON schema of all available tools into the system prompt every request. Complex schemas with 4-level nested objects can consume 3k-4k tokens before processing any user input. With a 200k context window, this bloats costs and reduces available working memory for actual tasks. Flattening schemas \(e.g., converting nested 'address.city' to flat 'address\_city' fields\) reduces token count by 30-40%. Additionally, removing optional fields that are never populated in practice cuts tokens without functionality loss. The quality impact is minimal because Claude interprets schema descriptions strictly; field nesting depth does not improve model understanding, only human readability. Use token counting APIs to measure the exact delta: a 200-line nested schema versus 80-line flat schema typically saves $0.01-0.02 per request at current Sonnet pricing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:38:11.750090+00:00— report_created — created