Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By RyanKim17920v0.3.0MITIn 1 marketplace
Tracks each agent's context size and warns as it grows. Past the threshold main writes its handoff file and is compacted in place, then reads that file first; a subagent writes its handoff brief and stops.
Code that runs inside Claude Code on every session, as you, unsandboxed.
Claude Code asks for these when you enable the plugin. Sensitive values are stored in your system keychain.
Main's handoff folderhandoffDir
Absolute folder (or one under ~/) main's handoff goes under, as <handoffDir>/<sessionId>/main.md, overwritten each cycle. Empty means handoffs in Claude's config folder: $CLAUDE_CONFIG_DIR/handoffs, else ~/.claude/handoffs.
stringdefault
Show the status line entryshowStatus
1 critical to review before installing
JavaScript or TypeScript that runs inside Claude Code as you, unsandboxed. Read from its source, it sees, changes or blocks tool calls; runs programs; reads files; reads environment variables (CLAUDE_CONFIG_DIR, HOME); reads or rewrites your prompts; sends prompts on its own.
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Show the largest live subagent's size in the status line. Display only: tracking and notes run the same either way.
booleandefault true
Show toastsshowToasts
Toast at the warning, at the handoff threshold, and when main cannot be compacted. Display only: tracking and notes run the same either way.
booleandefault true
Warn at (tokens)warnTokens
Toast once when an agent's context first reaches this size. Capped at 60% of the point where the engine would auto-compact that agent.
numberdefault 300000
Track the main threadincludeMain
Track the main thread too: past the threshold it writes its handoff file and is compacted in place, as often as it fills up, never rotated to a new session.
booleandefault true
Repeat the handoff note every (tokens)repeatTokens
After the first handoff note, repeat it once per this much further growth until a compaction resets the count.
numberdefault 50000
Hand off at (tokens)rotateTokens
Past this size main refreshes its handoff file and is compacted in place when its turn ends; a subagent is told to write its handoff brief and stop. Capped at 75% of the point where the engine would auto-compact that agent, so the handoff always comes first.
numberdefault 400000
Add the rotation rule to spawned agentsaddRuleToSpawns
Append one standing sentence to every spawned agent's prompt telling it to follow an [agent-budget] note. Without it an agent may treat the note as untrusted and ignore it.
booleandefault true
Remove main's handoffs older than (days)handoffMaxAgeDays
Once per load, after a compaction of main, other sessions' <handoffDir>/<sessionId>/main.md files older than this are removed, and each folder left empty with them. 0 keeps every file.
numberdefault 30
Tracks each agent's context size, from the token usage of its latest model request, and warns as it grows.
<handoffDir>/<sessionId>/main.md. When its turn ends it is compacted in place; it is never moved to a new session. After any compaction of main, the summary and main's next turn point it at that file.[agent-budget] note./agent-budget lists every tracked agent by size. The status line names the largest live subagent.After adding the marketplace (see Install in the main README):
claude plugin install agent-budget@ryk-claude-mods
Or add the marketplace and install in one step:
claude plugin install agent-budget --marketplace RyanKim17920/ryk-claude-mods
The handoff has to come before the engine's own auto-compaction, or main compacts with no handoff written. On a 200k window that point is about 167k, so a flat 400k would never be reached. Each agent is therefore held to the lower of the set value and a share of its own auto-compact point:
min(warnTokens, 60% of the point)min(rotateTokens, 75% of the point)The 25% left is room for main to finish its step and write the handoff before the engine would compact.
| Window | Auto-compact point | Warning | Handoff |
|---|---|---|---|
| 200k | about 167k | 100k | 125k |
| 1M | about 967k | 300k (set value) | 400k (set value) |
| unknown | taken as a 200k window: 160k | 96k | 120k |
Where the point comes from:
$.session.usage({ breakdown: 'summary' }) gives the engine's own autoCompactThreshold, which already reflects autoCompactWindow, CLAUDE_CODE_AUTO_COMPACT_WINDOW and the percent override. It is read once per window size (a model switch reads it again); the free $.session.usage() call each step notices the switch. With auto-compaction off, the point is the window itself, so main still hands off before it runs out.contextWindowSize from $.agent.list()), not its threshold. The point is estimated as 80% of that window, which is at or below where the engine compacts a 200k window and well below on a 1M one, so the estimate errs early, never late. A compaction window set for the session lowers it, as it lowers a subagent's.A set warnTokens or rotateTokens is honoured up to that cap, never past it, so no setting can push the handoff past auto-compaction. /agent-budget shows each agent's own handoff point.
Set these in /plugin (config) or under pluginConfigs in settings. A bad value (not a number, 0 or negative where a positive number is needed) falls back to the default.
| Option | Default | What it does |
|---|---|---|
warnTokens | 300000 | Toast once when an agent first reaches this size. Capped at 60% of the agent's auto-compact point. |
rotateTokens | 400000 | Past this size, main hands off and is compacted in place, and a subagent hands off and stops. Capped at 75% of the agent's auto-compact point. |
repeatTokens | 50000 | Repeat the handoff note every this much further growth. |
includeMain | true | Track main too. Off, main is never noted or compacted by this mod. |
handoffDir | empty | Absolute folder (or one under ~/) for main's handoff. Empty means handoffs in Claude's config folder: $CLAUDE_CONFIG_DIR/handoffs when that variable is set, else ~/.claude/handoffs. A relative path or one with .. falls back to that default. |
handoffMaxAgeDays | 30 | Remove other sessions' main.md handoffs older than this. 0 keeps every file. |
addRuleToSpawns | true | Append the standing rule to every spawned agent's prompt (never to a workflow's agent). |
showStatus | true | Show the status-line entry. Display only. |
showToasts | true | Show toasts. Display only: tracking and notes run the same. |
npx claudepluginhub ryankim17920/ryk-claude-mods --plugin agent-budgetPlugins from other owners that cover similar ground
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.