PromptisePromptise
Docs
GitHub
Promptise - AI Framework LogoPromptise

The foundation layer for agentic intelligence. Build, secure and operate autonomous AI systems with Promptise Foundry.

pip install promptise

[01] Foundry

  • MCPcast
  • The Promptise Agent
  • Reasoning Engine
  • MCP
  • Agent Runtime
  • Prompt Engineering
  • Execution Engine
  • Agent Identity

[02] Resources

  • Documentation
  • GitHub
  • Guides
  • Learning Paths
  • Questions

[03] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

Open source · Python

← Guides> Topic

Cost control and rate limits

An agent's cost is hard to predict because the model decides how many steps to take. A loop that should take three calls can take thirty, and a busy client can drive up spend for everyone. Cost control puts limits where the spending happens: on tokens and calls per run, on requests per client, and on how much context goes into each call.

These guides start with budgets that stop a run before it overspends. Rate limiting per client keeps one caller from using up shared capacity on your MCP servers. Semantic caching reuses earlier answers to similar questions, caching and circuit breakers on tool servers avoid paying for repeated or failing calls, and trimming the tool list cuts the tokens spent on tool descriptions in every request.

[n.01/02]> 11 guides, in order
  1. 01AI Agent Cost Control: Budgets That Stop Runaway SpendHow to control AI agent costs: per-run and daily budgets that refuse tool calls before they run, token caps, iteration limits, and what each one misses.Intermediate · 18 minOct 18, 2026
  2. 02LLM Tool Rate Limiting: Per-Client Limits for MCP ServersRate limit LLM tool calls per client, tenant and tool on a Python MCP server: a real load test, the error the agent sees, and how to retry it.Intermediate · 14 minOct 11, 2026
  3. 03LLM Semantic Cache and Model Fallback in PythonReduce LLM API costs with a semantic cache and survive provider outages with model fallback. Real hits, tokens and a simulated outage, in Python.Intermediate · 23 minOct 11, 2026
  4. 04MCP Server Caching, Timeouts and Circuit Breakers in PythonKeep an MCP server fast when its API is flaky: caching, retries with backoff, timeouts, a circuit breaker and limits, with real before and after numbers.Intermediate · 23 minOct 11, 2026
  5. 05Too Many MCP Tools? LLM Tool Selection, MeasuredWhat 122 tools do to an LLM agent's accuracy, tokens and latency, measured, and how semantic tool selection fixes it in Python, with honest limits.Intermediate · 18 minOct 11, 2026
  6. 06AI Agent Cost Tracking: Tokens and Cost per Run and UserTrack AI agent token usage and cost per model call, run, user and agent: price tables, cost ledgers, alerts and limits. Runnable code with real output.Intermediate · 16 minOct 18, 2026
  7. 07AI Agent Stuck in a Loop? How to Detect and Stop ItWhy AI agents get stuck in loops and how to stop them: detect repeated tool calls, cap tool calls per run, and write tool results that end the loop.Intermediate · 18 minOct 18, 2026
  8. 08Context Engineering for AI Agents: Context Window ManagementContext engineering for AI agents in Python: keep what matters in long runs, trim the rest, and cut input tokens 18x. Real token counts per step.Intermediate · 26 minOct 11, 2026
  9. 09LLM Routing: When to Use a Small vs Large ModelLLM routing explained: rules, LLM routers, learned routers and cascades to send each request to the cheapest model that works. A real router misroute.Intermediate · 7 minOct 18, 2026
  10. 10MCP vs CLI for AI Agents: Tokens, Security, When to Use EachMCP vs CLI tools for AI agents: where the tokens go, prompt caching, per-user security and when to use each or both, with runnable code and real output.Intermediate · 20 minOct 18, 2026
  11. 11Prompt Compression: LLMLingua and Lost in the MiddlePrompt compression techniques compared: selection, LLMLingua, summaries. Fix lost in the middle with reordering. Real example: 15,900 tokens cut to 1,400.Advanced · 9 minOct 18, 2026
[n.02/02]> go further

In the documentation

  • Budgetsdocs ↗
  • Semantic cachedocs ↗
  • Tool optimizationdocs ↗

Other topics

  • Building AI agents in Python→
  • Models and providers→
  • Tools and the Model Context Protocol (MCP)→
  • Memory, context and RAG→
  • Agent reasoning patterns→
  • Multi-agent systems→
  • Guardrails and security→
  • Human approvals (human-in-the-loop)→
  • Observability and debugging→
  • Testing and evals→
  • Runtime, triggers and deployment→
  • Frameworks and comparisons→

Build it with Promptise Foundry.

The code in these guides runs on Promptise Foundry, an open-source Python framework for AI agents and MCP servers.

QuickstartAll guides