Cost And Token Budget Optimizer For Agent Loops
Analyzes an agent workflow and proposes concrete changes to cut token cost and step count without losing task quality.
Prompt
ROLE: You are a performance engineer optimizing the cost and latency of LLM agent loops. CONTEXT: My agent does [WORKFLOW]. Current behavior: average [N_STEPS] steps, [TOKENS] tokens per run, model [MODEL]. The biggest cost driver appears to be [SUSPECTED_DRIVER]. Quality must not drop below [QUALITY_BAR]. TASK: Produce an optimization plan. 1. Map where tokens and steps are spent across the loop (context bloat, redundant tool calls, over-long reasoning, re-reading state). 2. Propose targeted optimizations: context pruning/summarization, caching, batching tool calls, cheaper model routing for sub-tasks, and earlier stop conditions. 3. For each optimization, estimate the expected savings and the quality risk. 4. Recommend which sub-tasks can be downgraded to a smaller/cheaper model and which must stay on the strong model. 5. Define a guardrail metric to detect if an optimization silently hurt quality. OUTPUT FORMAT: A findings list, an optimization table (Change | Est. Savings | Quality Risk | Effort), a recommended rollout order, and the quality guardrail metric. CONSTRAINTS: Never trade away correctness to save tokens below [QUALITY_BAR]. Prefer reversible, measurable changes. Be specific about where in the loop each change applies.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Asks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.
Learn this techniquePins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueAssigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in AI Agents & Autonomous Workflows
Autonomous Agent System Prompt Architect
Designs a complete, production-grade system prompt for an autonomous agent including persona, tool contracts, guardrails, and stop conditions.
ReAct Loop Reasoning Trace Designer
Builds a strict ReAct-style Thought/Action/Observation loop with explicit formatting and self-correction rules for tool-using agents.
Multi-Agent Orchestration Blueprint
Plans a coordinated multi-agent team with roles, hand-off contracts, shared memory, and conflict resolution for a complex objective.
Agent Tool Definition And Schema Writer
Writes precise tool/function definitions with JSON schemas, descriptions, and usage hints that minimize wrong-tool and bad-argument errors.