Skip to content

fix: document --budget item-boundary semantics and announce oversized items - #63

Merged
yusukebe merged 1 commit into
mainfrom
fix/budget-semantics
Aug 4, 2026
Merged

fix: document --budget item-boundary semantics and announce oversized items#63
yusukebe merged 1 commit into
mainfrom
fix/budget-semantics

Conversation

@yusukebe

@yusukebe yusukebe commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #60, taking all three asks:

  1. Document the semantics--help, README, and src/agent-context.txt now state that --budget cuts at item boundaries, never splits an item, and always emits at least one, so a single oversized item can exceed the budget.
  2. Announce the overflow — when the emitted item alone exceeds the budget (the only way past it: with 2+ items shown their sum already fits), stderr gets ax: note: emitted item is ~N tokens — over --budget (…). This fires in --json-envelope mode too: continuation info lives in meta, but this is a warning, so never-silent wins. The issue's --offset 1 --budget 1 repro — previously byte-for-byte silent at ~1600x over — now announces.
  3. Fix JSON sizing — budget items are now measured with JSON.stringify(v, null, 2), the pretty-printed form actually written, instead of the compact form that systematically undercounted.

The always-emit-one behavior itself is unchanged — an empty result for a small budget would be useless, and #40's resume tests pin it.

meta is untouched: the envelope contract gains no fields.

Tests

One new CLI test pinning: the previously-silent --offset overflow announces, no note when items fit, and the warning reaches stderr in envelope mode with meta.state still complete. bun test test/: 159 pass. tsc --noEmit and oxfmt --check clean.

🤖 Generated with Claude Code

… items

--budget cuts at item boundaries and always emits at least one item, so a
single oversized item can exceed the budget — intentional, but undocumented,
and with --offset leaving nothing after that item the overflow was completely
silent. Announce it on stderr (including in envelope mode), measure JSON
budgets against the pretty-printed form that is actually written, and state
the semantics in --help, README, and the agent context.

Closes #60

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yusukebe
yusukebe merged commit b2bcb39 into main Aug 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--budget cuts on item boundaries and always emits one item, but docs describe it as a cap

1 participant