agent_with_budget

command
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Example demonstrating per-run budget enforcement with WithBudget.

Two scenarios are shown:

  1. BudgetStopRun: the run stops immediately and returns ErrBudgetExceeded when the configured token or cost limit is reached.
  2. BudgetWaitForApproval: the run pauses when the limit is reached; the approval handler decides whether to continue or stop.

Run:

go run ./agent_with_budget
go run ./agent_with_budget "Your custom prompt here"

Set SHOW_LLM_USAGE=true to print token usage at the end of each run. The budget limits in this example are set very low so they trigger on most prompts. Raise them to realistic values (e.g. MaxTokens: 100_000) for production use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL