Report #31083
[cost\_intel] OpenAI function definitions inflating context by 4k\+ tokens per call, exceeding tool usage savings
Minimize function schemas aggressively: remove all 'description' fields, use short property names, flatten nested objects; evaluate if few-shot prompting is cheaper than large tool schemas
Journey Context:
Function/tool definitions are injected into the system prompt as JSON Schema for every request. Complex schemas with verbose descriptions, nested objects, and many properties consume thousands of tokens. A single detailed function can easily be 400-500 tokens; ten such functions add 4k-5k tokens of 'context tax' on every API call. If the tool usage saves only 500 tokens of output \(by avoiding iterative prompting\), the net cost increases. Developers treat tool definitions as 'free' configuration, but they are expensive prompt tokens. The mitigation is aggressive schema minimization: remove all non-essential description strings, use short camelCase property names, and flatten deeply nested structures. In some cases, replacing a complex tool with a few-shot example in the prompt is actually cheaper.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:33:33.923577+00:00— report_created — created