Use this prompt when you are building an agent or automated workflow that must call external APIs with published rate limits, and naive sequential execution would trigger HTTP 429 errors, throttling, or temporary bans. The core job-to-be-done is generating a multi-step execution plan that respects a known rate limit budget, schedules requests to stay under that budget, and defines explicit backoff behavior when limits are exceeded. The ideal user is an AI engineer or backend developer integrating an LLM-based planner into a production system where API costs, reliability, and predictable execution timing matter. Required context includes the target API's rate limit rules (requests per second, per minute, or per day), the list of planned API calls with their expected endpoints and methods, and any hard deadlines or priority ordering for those calls.
Prompt
Plan Generation with Rate Limit Awareness Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Plan Generation with Rate Limit Awareness prompt.
Do not use this prompt when the target API has no documented rate limits, when the execution environment can handle retries transparently through a client library or API gateway, or when the number of API calls is trivially small (fewer than five) and unlikely to trigger throttling. This prompt is also inappropriate for workflows where the primary constraint is monetary cost rather than request frequency; use the Plan Generation with Budget Constraints prompt for token or dollar-budgeted plans. If your system already has a robust queue-and-backoff middleware, this prompt adds unnecessary planning overhead—instead, let the middleware handle rate limits and focus the planner on task decomposition and tool selection.
Before adopting this prompt, confirm that you can programmatically enforce the plan's rate limit schedule in your execution harness. The prompt produces a plan with timing and backoff instructions, but the harness is responsible for respecting those instructions, pausing execution, and handling cases where the model underestimates burst risk. If you cannot enforce delays or queue requests in your runtime, the generated plan will not prevent throttling. Start by testing the prompt against a known rate-limited sandbox API, measure whether the generated schedule stays within the declared budget, and add eval checks for missing retry-after handling and burst patterns before deploying to production.
Use Case Fit
Where this prompt works and where it does not. Plan generation with rate limit awareness is a specialized capability for agents calling throttled APIs. It is not a general-purpose planning prompt.
Good Fit: Rate-Limited API Orchestration
Use when: an agent must call APIs with documented rate limits (e.g., 60 requests/minute, 1000 tokens/second) and naive sequential execution would trigger 429 errors or bans. Guardrail: Provide the exact rate limit spec, window size, and current usage state as input variables so the model can budget accurately.
Bad Fit: Simple Sequential Workflows
Avoid when: the agent calls internal tools or APIs with no rate limits, or the task involves fewer than 5 API calls where backoff is trivial. Guardrail: Use a standard plan generation prompt instead. Adding rate limit awareness to unconstrained workflows adds unnecessary complexity and token overhead.
Required Inputs: Rate Limit Spec and Current State
What to watch: The prompt cannot guess rate limits. Missing or stale rate limit state causes plans that either waste capacity or still trigger throttling. Guardrail: Always pass [RATE_LIMIT_SPEC] (limits per endpoint, window size) and [CURRENT_USAGE_STATE] (tokens consumed, requests remaining) as explicit inputs. Validate these are non-null before plan generation.
Operational Risk: Stale Rate Limit State
What to watch: If the agent generates a plan based on rate limit state from 30 seconds ago, the plan may exceed limits by the time execution starts. Guardrail: Re-check rate limit state immediately before plan execution begins. If state has changed beyond a threshold, trigger replanning. Log state staleness as a metric.
Operational Risk: Burst Pattern Blindness
What to watch: The model may schedule requests evenly across a window but fail to account for burst limits (e.g., max 10 requests/second even if the minute budget is 600). Guardrail: Include burst limit constraints in [RATE_LIMIT_SPEC] and add a harness check that validates no sub-window in the generated plan exceeds burst thresholds.
Operational Risk: Missing Retry-After Handling
What to watch: The plan may assume fixed backoff intervals but real APIs return Retry-After headers with dynamic wait times. Guardrail: The plan must include a step that reads Retry-After from 429 responses and adjusts scheduling dynamically. The harness should test that the plan references this header, not just a static backoff.
Copy-Ready Prompt Template
A reusable prompt that generates a rate-limit-aware execution plan from a goal, tool list, and API constraints.
This template is the core instruction set you will send to the model. It forces the planner to treat rate limits as first-class constraints—not afterthoughts—by requiring explicit budget allocation, backoff strategy selection, and request scheduling before any tool call is approved. The square-bracket placeholders let you inject the specific goal, available tools, rate limit profiles, and output schema without rewriting the planning logic each time.
textYou are a planning agent that generates execution plans for API-dependent workflows. Your plans must respect rate limits, avoid burst patterns that trigger throttling, and include explicit backoff and scheduling strategies. ## INPUTS - Goal: [GOAL_DESCRIPTION] - Available Tools: [TOOL_LIST_WITH_ENDPOINTS] - Rate Limit Profiles: [RATE_LIMIT_SPECS] - Max Execution Budget: [MAX_BUDGET_IN_SECONDS] - Output Schema: [OUTPUT_SCHEMA] ## PLANNING RULES 1. For every tool call, calculate the estimated request count and compare it against the provided rate limit profile. 2. If a step would exceed a rate limit window, insert a wait step with the exact duration derived from the `Retry-After` header behavior or the documented reset period. 3. Never schedule more than [MAX_CONCURRENT_REQUESTS] requests in parallel against the same rate-limited endpoint. 4. For endpoints with burst limits, spread requests evenly across the available window rather than front-loading. 5. Include an explicit backoff strategy for 429 responses: exponential backoff with jitter, starting at [INITIAL_BACKOFF_SECONDS] seconds, capped at [MAX_BACKOFF_SECONDS] seconds. 6. If the total estimated execution time exceeds the max budget, insert a checkpoint step that reports progress and requests budget extension before continuing. 7. Flag any step that lacks a documented rate limit as `risk: high` and insert a conservative wait between those calls. ## OUTPUT FORMAT Return a JSON object matching the provided output schema. Each step must include: - `step_id`: unique identifier - `tool_call`: the exact tool and endpoint - `estimated_requests`: number of API calls this step requires - `rate_limit_budget_consumed`: how much of the window budget this step uses - `wait_before_seconds`: delay before executing this step (0 if none) - `backoff_strategy`: the backoff parameters for this specific endpoint - `risk_level`: low | medium | high - `fallback_step_id`: which step to execute if this one fails due to rate limiting ## CONSTRAINTS - Do not propose plans that exceed the documented rate limits. - Do not omit backoff strategies for any rate-limited endpoint. - If the goal cannot be achieved within the rate limits and budget, return a plan that completes as much as possible and explicitly marks remaining work as `deferred`.
To adapt this template, replace each bracketed placeholder with concrete values from your application context. [RATE_LIMIT_SPECS] should include the window size, request cap, and whether the API returns a Retry-After header. [TOOL_LIST_WITH_ENDPOINTS] must map each tool to its specific endpoint so the planner can group calls by rate limit domain. If your execution engine cannot handle dynamic wait insertion, add a constraint that all waits must be expressed as explicit sleep tool calls with validated durations. Before deploying, run this prompt against a set of goals that are known to be impossible within the rate limits—the model should produce a partial plan with deferred markers rather than an impossible full plan or a hallucinated workaround.
Prompt Variables
Required inputs for the Plan Generation with Rate Limit Awareness prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to verify the input is well-formed and safe.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[GOAL] | The user's objective to be decomposed into a rate-limit-aware plan | Generate a daily summary report for all active customer accounts by calling the accounts API and the transactions API | Must be a non-empty string. Check for ambiguity; if the goal implies multiple API families, confirm all are listed in [AVAILABLE_TOOLS] |
[AVAILABLE_TOOLS] | JSON array of tool definitions with their rate limit profiles | [{"name": "get_accounts", "rate_limit": {"requests_per_minute": 60, "burst_limit": 10, "retry_after_header": true}}] | Validate JSON parse. Each tool must have a rate_limit object with requests_per_minute. burst_limit and retry_after_header are optional but recommended. Reject if any tool is missing rate_limit |
[RATE_LIMIT_POLICY] | Organizational policy for how aggressively to use available capacity | Conservative: use at most 70% of rate limit, insert 200ms delay between bursts, never exceed burst_limit | Must be one of Conservative, Balanced, or Aggressive. If Aggressive, require explicit approval flag. Validate against [CONSTRAINTS] for contradictions |
[CONSTRAINTS] | Hard boundaries on execution: total time budget, max requests, required completion criteria | Complete within 120 seconds. Maximum 500 total API calls. All accounts must be processed. Do not retry 429 responses more than 3 times per endpoint. | Parse for numeric limits. Check that time budget and max requests are compatible with rate limits in [AVAILABLE_TOOLS]. Flag if constraints are mutually unsatisfiable |
[OUTPUT_SCHEMA] | Expected structure of the generated plan | {"plan_id": "string", "steps": [{"step_id": "string", "tool": "string", "arguments": {}, "rate_limit_budget": {"max_requests": int, "min_interval_ms": int}, "backoff_strategy": "string", "depends_on": ["string"]}]} | Validate as JSON Schema. Required fields: plan_id, steps[].step_id, steps[].tool, steps[].rate_limit_budget, steps[].backoff_strategy. Reject if schema allows unbounded arrays without pagination or limits |
[CONTEXT] | Additional runtime information: current rate limit state, prior partial progress, known outages | {"current_window_usage": {"get_accounts": 12, "get_transactions": 45}, "window_reset_in_seconds": 23, "partial_progress": null} | Validate JSON parse. current_window_usage keys must match tool names in [AVAILABLE_TOOLS]. If partial_progress is provided, verify step IDs are consistent with prior plan version. Null allowed for initial planning |
[FAILURE_MODE_PREFERENCES] | Ordered list of preferred degradation strategies when rate limits prevent full completion | ["partial_results_with_summary", "extend_deadline", "escalate_to_human"] | Must be a non-empty array. Valid values: partial_results_with_summary, extend_deadline, abort_and_report, escalate_to_human, retry_with_exponential_backoff. Reject if array contains unknown strategies |
Implementation Harness Notes
How to wire the rate-limit-aware plan generation prompt into an agent's planning module with validation, retries, and observability.
The rate-limit-aware plan generation prompt is designed to be called by an agent's planning module before execution begins. It expects a clarified goal, a list of available tools with their documented rate limits, and any known scheduling constraints. The prompt should be treated as a pre-execution planning step—not a runtime decision-maker. Its output is a structured plan that the execution engine will follow, so the harness must validate the plan's schema, rate-limit budgets, and backoff strategies before any API call is made.
Wire the prompt into your application with a validate-then-execute pattern. After receiving the model's plan output, run a schema validator that checks for required fields: steps[], each with tool, arguments, estimated_cost, rate_limit_budget_used, backoff_strategy, and retry_after_handling. Then run domain-specific checks: confirm that no step exceeds the tool's documented rate limit, that burst patterns (e.g., three steps calling the same API within a 1-second window) are flagged, and that every step touching a rate-limited tool includes a retry-after header handler. If validation fails, retry the prompt once with the validation errors injected into [CONSTRAINTS]. If it fails again, escalate to a human operator with the invalid plan and validator output. For model choice, use a capable planning model (e.g., GPT-4o, Claude 3.5 Sonnet) with a low temperature (0.1–0.2) to reduce creative variance in budget allocation. Do not use this prompt with models that lack strong instruction-following for structured outputs.
Log every plan generation call with: the input goal, the tool definitions and their rate limits, the raw model output, the validation result, and whether the plan was accepted, retried, or escalated. This trace is essential for debugging when execution stalls due to rate limiting. Common failure modes include the model ignoring retry-after headers, underestimating burst costs, or producing plans that look valid but exceed rate limits when executed concurrently. Your harness should simulate the plan's rate-limit consumption in a dry-run mode before live execution—multiply each step's rate_limit_budget_used by the expected concurrency factor and compare against the API's documented limits. If the dry run fails, reject the plan and request regeneration with the specific violation details added to [CONSTRAINTS].
For production deployments, integrate this prompt into a planning microservice that exposes a /generate-plan endpoint. The service should accept a goal, tool manifest, and rate-limit policies; return a validated plan or an error; and emit structured logs for your observability stack. Never execute a plan directly from the model output without validation. Rate-limit violations in production trigger throttling, bans, or cascading failures across unrelated agent workflows—the harness is your safety boundary.
Expected Output Contract
Validate the plan object returned by the prompt. Each field must be present, correctly typed, and pass the specified rule before the plan is handed to an execution engine.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
plan_id | string (UUID v4) | Must match UUID v4 regex. Reject if missing or malformed. | |
goal_summary | string | Length between 10 and 500 characters. Must not be identical to raw user input. | |
steps | array of objects | Array length >= 1. Each element must have id, action, tool_name, and depends_on fields. | |
steps[].id | string (kebab-case) | Must match pattern ^step-[a-z0-9-]+$. Must be unique within the array. | |
steps[].tool_name | string | Must exactly match a tool name in the provided [AVAILABLE_TOOLS] list. Reject hallucinated tools. | |
steps[].depends_on | array of step IDs | Each ID must reference another step.id in the plan. No self-references. No cycles allowed. | |
rate_limit_budget | object | Must contain total_requests, window_seconds, and per_step_allocation fields. | |
rate_limit_budget.per_step_allocation | array of objects | Length must equal steps array length. Each object must have step_id matching a step.id and max_requests as positive integer. | |
backoff_strategy | object | Must contain base_delay_ms (integer > 0), max_retries (integer >= 0), and retry_on_status (array of integers, e.g. [429, 503]). |
Common Failure Modes
Rate-limit-aware plans fail in predictable ways. These are the most common failure modes when generating execution plans for rate-limited APIs, along with practical mitigations to embed in your prompt harness.
Burst Scheduling Despite Rate Limit Awareness
What to watch: The plan acknowledges rate limits in text but still schedules requests in tight bursts that exceed the per-second or per-minute budget. The model understands the constraint conceptually but fails to translate it into correctly spaced execution steps. Guardrail: Require the plan to include explicit inter-request delays in milliseconds or seconds between each step. Validate the output by parsing scheduled timestamps and flagging any gap smaller than the minimum interval derived from the rate limit specification.
Missing Retry-After Header Handling
What to watch: The plan includes retry logic but ignores the Retry-After header value from 429 responses. Instead, it uses a fixed backoff that either wastes time waiting too long or retries too soon and triggers additional throttling. Guardrail: Explicitly instruct the prompt to extract and obey Retry-After header values, with a fallback exponential backoff only when the header is absent. Add a test case where the simulated API returns a 429 with Retry-After: 30 and verify the plan schedules the retry at exactly that offset.
Token Budget Exhaustion Before Completion
What to watch: The plan allocates rate-limit budget correctly for the first N steps but fails to reserve capacity for final aggregation, validation, or reporting steps. The agent runs out of allowed requests before the workflow finishes. Guardrail: Require the plan to include a budget allocation table that reserves capacity for every step, including post-processing. Add a harness check that sums allocated requests and confirms the total does not exceed the stated limit, with explicit headroom for error-recovery retries.
Silent Assumption of Unlimited Parallelism
What to watch: The plan parallelizes requests assuming the rate limit applies per-request rather than per-account or per-IP. Concurrent requests all hit the limit simultaneously, causing a cascade of 429 errors. Guardrail: Prompt the model to treat the rate limit as a shared global budget, not a per-thread allowance. Require the plan to specify a concurrency cap and serialize requests that would exceed it. Validate by checking that no two steps are scheduled within the same rate-limit window unless the combined count stays under budget.
Plan Ignores Rate Limit Scope Mismatch
What to watch: The model generates a plan assuming a per-minute limit when the actual API enforces per-second and per-day limits simultaneously. The plan satisfies one constraint but violates another, leading to mid-execution throttling. Guardrail: Include all applicable rate limit dimensions (per-second, per-minute, per-hour, per-day) in the prompt input. Require the plan to validate against every dimension and flag conflicts. Add eval cases that test each dimension independently and in combination.
No Graceful Degradation When Limits Are Reached
What to watch: The plan treats rate-limit exhaustion as a hard failure and aborts entirely, rather than switching to a degraded mode that completes the highest-priority work within the remaining budget. Guardrail: Instruct the prompt to include a priority-ordered step list and a degradation policy that specifies which steps can be skipped, deferred, or replaced with cached results when the budget is exhausted. Test with a scenario where the budget is 50% of what the full plan requires and verify the output prioritizes correctly.
Evaluation Rubric
Criteria for testing whether the generated plan correctly handles rate limits, backoff, and scheduling before shipping to production.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Rate limit budget allocation | Plan includes explicit per-step or per-window token/call budgets that sum to less than the known API limit | Plan contains no budget fields, budgets exceed the documented limit, or budgets are missing for rate-limited tools | Parse plan for budget fields; sum per-window allocations; assert total <= [RATE_LIMIT_THRESHOLD] |
Backoff strategy specification | Plan defines a backoff strategy (exponential, constant, or decorrelated jitter) with base delay and max retries for each rate-limited tool | Plan mentions retry without backoff parameters, uses immediate retry, or omits backoff entirely for tools with known 429 responses | Search plan for backoff keywords; assert presence of base_delay_ms, max_retries, and strategy fields per rate-limited step |
Retry-After header handling | Plan includes logic to parse Retry-After headers and adjust scheduling dynamically rather than using fixed delays | Plan uses only static sleep intervals without reference to Retry-After or X-RateLimit-Reset headers | Inject mock 429 response with Retry-After; verify plan output references header parsing or dynamic wait adjustment |
Request scheduling and pacing | Plan sequences requests to avoid bursts, with explicit inter-request delays or token-bucket pacing when multiple steps target the same API | Plan schedules all rate-limited calls in immediate succession without delays, or parallelizes calls that share a rate limit bucket | Simulate plan execution trace; assert no two rate-limited calls to same endpoint occur within [MIN_INTERVAL_MS] |
Burst pattern detection | Plan identifies and warns when requested operations would exceed burst limits, proposing split or delayed execution | Plan accepts all requested operations without checking burst capacity, producing a schedule that triggers immediate throttling | Feed plan a goal requiring [BURST_COUNT] calls within [BURST_WINDOW]; assert plan output contains burst warning or step splitting |
Graceful degradation on quota exhaustion | Plan defines behavior when rate limit budget is fully consumed: pause, escalate, or return partial results with clear status | Plan either hangs indefinitely, retries without bound, or silently drops remaining steps when quota is exhausted | Exhaust simulated quota mid-plan; assert plan produces DEGRADED or PARTIAL status with unconsumed steps flagged, not infinite retry |
Tool-specific rate limit awareness | Plan references the documented rate limits for each tool and tailors scheduling to per-endpoint constraints, not a single global limit | Plan applies one flat rate limit to all tools, ignores per-endpoint limits, or assumes unlimited access | Provide tool manifest with varied rate limits; assert plan output contains distinct budget or delay values per endpoint |
Idempotency and safe retry design | Plan marks retryable steps as idempotent or includes idempotency keys where the API supports them, preventing duplicate side effects on retry | Plan retries non-idempotent writes without idempotency keys, risking double-charges or duplicate resource creation | Identify write steps in plan; assert each retryable write includes idempotency_key field or is marked read-only |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a single rate-limited API. Replace [RATE_LIMIT_SPEC] with hardcoded values (e.g., 10 requests per minute). Skip budget tracking and backoff simulation—just check that the generated plan mentions rate limits and spaces requests.
code[RATE_LIMIT_SPEC]: 10 requests per minute, 429 response includes Retry-After header
Watch for
- Plans that acknowledge rate limits but don't actually schedule around them
- Missing Retry-After handling in the plan text
- Overly complex scheduling logic that can't be validated without a harness

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us