openclaw - 💡(How to fix) Fix [Feature]: Add built-in token budget and request limit controls [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58826Fetched 2026-04-08 02:32:16
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Introduce built-in controls for token budgets and request limits at request/session/daily levels to prevent uncontrolled usage.

Root Cause

Introduce built-in controls for token budgets and request limits at request/session/daily levels to prevent uncontrolled usage.

Code Example

{
  "limits": {
    "maxTokensPerRequest": 4000,
    "maxTokensPerSession": 20000,
    "maxTokensPerDay": 100000,
    "maxRequestsPerSession": 50
  }
}
RAW_BUFFERClick to expand / collapse

Summary

Introduce built-in controls for token budgets and request limits at request/session/daily levels to prevent uncontrolled usage.

Problem to solve

OpenClaw currently lacks built-in mechanisms for enforcing token usage limits or request caps.

While external tools such as diagnostics-otel can observe token consumption, they do not provide any form of active control or intervention.

This leads to several issues:

  • No per-request token budget enforcement
  • No per-session or per-user token limits
  • No daily usage caps
  • No automatic stopping when token usage exceeds a threshold
  • No safeguards against infinite recursive or looping agent calls

In failure scenarios (e.g., unsolvable tasks or bad prompts), agents may enter infinite loops, continuously issuing requests and consuming tokens without bound.

Proposed solution

Introduce configurable budget and limit controls, including:

  1. Token budget controls:

    • maxTokensPerRequest
    • maxTokensPerSession
    • maxTokensPerDay (per user or API key)
  2. Request limits:

    • maxRequestsPerSession
    • maxRequestsPerMinute (rate limiting)
  3. Safety mechanisms:

    • Automatic interruption when limits are exceeded
    • Warning hooks (logs/events) before reaching limits
    • Loop detection (e.g., repeated identical tool calls or prompts)
  4. Configuration scope:

    • Global defaults
    • Per-account overrides
    • Optional per-agent overrides

Example:

{
  "limits": {
    "maxTokensPerRequest": 4000,
    "maxTokensPerSession": 20000,
    "maxTokensPerDay": 100000,
    "maxRequestsPerSession": 50
  }
}

This is an example. The specific figures are for reference only.

Alternatives considered

No response

Impact

Affected:

  • All users running agents in production

Severity:

  • High (can lead to uncontrolled cost and system instability)

Frequency:

  • Intermittent but critical

Consequence:

  • Unexpected cost spikes
  • Infinite loops consuming resources
  • Operational instability

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Implementing configurable token budget controls and request limits with automatic interruption and warning mechanisms can prevent uncontrolled usage and token consumption.

Guidance

  • Introduce token budget controls, such as maxTokensPerRequest, maxTokensPerSession, and maxTokensPerDay, to enforce token usage limits.
  • Implement request limits, including maxRequestsPerSession and maxRequestsPerMinute, to prevent excessive requests.
  • Develop safety mechanisms, such as automatic interruption when limits are exceeded and warning hooks, to detect and prevent infinite loops and token consumption.
  • Consider implementing a configuration scope with global defaults, per-account overrides, and optional per-agent overrides to provide flexibility in managing token budgets and request limits.

Example

{
  "limits": {
    "maxTokensPerRequest": 4000,
    "maxTokensPerSession": 20000,
    "maxTokensPerDay": 100000,
    "maxRequestsPerSession": 50
  }
}

This example configuration demonstrates how to set token budget controls and request limits.

Notes

The proposed solution requires careful consideration of the specific token budget and request limit values to ensure they meet the needs of different users and agents.

Recommendation

Apply a workaround by implementing the proposed configurable budget and limit controls to prevent uncontrolled token usage and request consumption, as this will provide a more robust and flexible solution than relying on external tools.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING