Report #48874
[cost\_intel] Function calling tool definitions consume more tokens than executing the function in-context would cost
For simple calculations, string manipulations, or data transforms under 50 lines of code, embed the logic directly in the system prompt as 'virtual tools' using few-shot examples rather than formal function schemas. Only use native function calling when the operation requires external API access, database queries, or complex state mutations.
Journey Context:
Teams default to OpenAI's function calling for every modular operation, but each tool definition carries massive token overhead: the JSON schema describing parameters, enums, descriptions, and required fields gets injected into every single request. A tool with 5 parameters and detailed descriptions easily consumes 800-1200 tokens. If that tool simply performs a date calculation or regex extraction, you're burning $0.001-0.003 per call in schema overhead alone. For high-volume operations \(thousands of calls per minute\), in-context few-shotting the same logic costs 200-400 tokens per example but requires no schema overhead, and once the model learns the pattern, you can drop to zero-shot. The break-even analysis: if your tool is called >100 times per hour and performs deterministic logic that fits in 3-4 examples, in-context wins. Only use function calling for operations that strictly require external side effects \(APIs, databases, hardware\) or complex nested logic exceeding 500 tokens of description.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:31:12.100975+00:00— report_created — created