Skip to content

[FEATURE]: Add configurable spending limit / "Kill Switch" per session #4559

Closed

Description

@mathe00

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Is your feature request related to a problem? Please describe.
Currently, there is no built-in mechanism in opencode to stop the agent based on accrued costs. This poses a significant risk: if the agent enters a loop, hallucinates, or performs a very long task without supervision, it can rapidly drain API credits without the user noticing until it's too late.

Describe the solution you'd like
I would like to be able to set a hard monetary limit (e.g., "max cost per session").
This could be implemented via:

  1. Configuration: A key in .opencode.json (e.g., "max_session_cost": 2.0).
  2. Environment Variable: A standard variable like OPENCODE_MAX_COST=2.0 that sets a global cap for any session running in that environment.
  3. Behavior: If the session cost exceeds this limit, the agent should immediately pause or terminate execution and prompt the user for confirmation to proceed.

Additional context
This is a crucial safety feature for autonomous agents to prevent "runaway" billing.
Other tools (like Kilo Code) already offer similar cost-control mechanisms to protect users.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 20, 2025
  2. rekram1-node commented on Nov 20, 2025

    @rekram1-node
    Contributor

    Yeah that makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionUsed for feature requests, proposals, ideas, etc. Open discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions