Skip to main content
Reserve output tokens and inspect per-segment budgets so long agent runs don’t exhaust context before the model can reply.
from praisonaiagents import Agent

agent = Agent(name="budget-cli", instructions="Respect output token reserves.")
agent.start("Run a long task without exhausting the context budget.")
The user runs the agent from the CLI and checks /context budget to see segment allocation.

How It Works

Quick Start

1

Run an agent, then inspect budget

from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="Answer helpfully within context limits.",
)

agent.start("Summarise the key points of context budgeting")
From the CLI session:
praisonai chat
> /context budget
2

Increase output reserve for long replies

praisonai chat --context-output-reserve 16000
Default output reserve is 8000 tokens. Raise it when the model truncates final answers.

CLI Flags

FlagDefaultDescription
--context-output-reserve8000Tokens reserved for model output

Interactive Commands

> /context budget   # Allocation breakdown
> /context stats    # Current usage vs budget
Example /context budget output:
Budget Allocation
  Model Limit:     128,000
  Output Reserve:  8,000
  Usable:          120,000

  Segment Budgets:
    System Prompt: 2,000
    History:       84,616
    Tool Outputs:  20,000
    ...

config.yaml

context:
  output_reserve: 8000
  default_tool_output_max: 10000
Environment variable: PRAISONAI_CONTEXT_OUTPUT_RESERVE.

Best Practices

If replies are cut off, increase --context-output-reserve first — compaction may not be the issue.
Tool outputs consume the largest share; stats show which segment is filling fastest.
Use Token Estimation CLI accurate mode when validating budget numbers.

Token Estimation CLI

Configure estimation accuracy

Context Compaction

Automatic overflow protection