How They Use AI  |  Newest

<< Home  |  Tech

Cut token usage by 82.4% and response time by 92.8%

AreaTech
AI usedGPT-4o-mini
Sourcer/AI_Agents
Posted2025-12-01

The move

Pass tool outputs by reference using named variables like $var_name instead of re-writing raw JSON data across agent turns.
When this worksWhen it doesn't
Multi-turn AI agents calling tools that return thousands of rows of JSON (e.g. 10,000 rows) or passing large documents to sub-agents where the model re-types data token-by-token.Single-turn tasks, small tool payloads where variable resolution overhead isn't needed, or setups without an orchestrator wrapper to intercept and resolve variable references.

Key details

Prompt for your AI

You are an AI agent executing tool calls across multiple turns. Goal: Pass data by reference using named variables instead of repeating raw data in tool inputs or streaming output. Rules: 1. Every tool output is automatically saved by the orchestrator as a named variable starting with $, such as $last_query_result or $weekly_visits. 2. When calling a tool or passing data to sub-agents, never re-write raw JSON rows, documents, or large arrays token-by-token. 3. Reference saved variables directly using $var_name or dot notation like $var.field in tool arguments. 4. Aim for minimal output (~20 tokens instead of 40,000 tokens) when passing data between tools. Decision points: - If a tool requires data from a previous tool output, use its assigned variable name (e.g., analyze_cohort(users: $weekly_visits)). - If you need a specific property from a tool output, access it with dot notation (e.g., $customers_california.user_ids). - If no variable reference exists yet for the required data, execute the data fetching tool first to generate one. Guardrails: Never copy-paste or output large JSON payloads manually when a variable reference can be used. Before you give me the final result, check with me: - Verify tool outputs are automatically assigned variable names ($var_name) by the orchestrator. - Ensure system prompt includes 1-2 few-shot examples of calling tools with $var syntax. - Confirm the orchestrator wrapper resolves $var_name and $var.field to real data before executing the tool. - Check that token count per turn drops to ~20 tokens for data-passing steps.

What happened

In a 3-turn cohort analysis task using GPT-4o-mini, an agent called analyze_cohort using $weekly_visits instead of printing 10,000 JSON rows. Total tokens dropped from 79,440 to 14,004 (-82.4%) and response time decreased from 263 seconds to 19 seconds (-92.8%).

Give it to your agent

Read https://howtheyuse.ai/p/82-4-fewer-tokens-and-92-8-faster-response-time.md and help me do this.

Sources



Last updated November 26, 2026.