feat(agent-sdk): context-bundle contract + token budgeter (F1)#35
Merged
officialCodeWork merged 1 commit intoJul 15, 2026
Merged
Conversation
New ContextBundle type + buildBundle (TRACKER step 5.2), bundled into ui-lineage: - Sections: match (instances + evidence), lineage (per-instance data sources), journeys (slice around the match, depth 2), blastRadius / tests / history (empty until 5.3/5.4/5.6), and warnings (staleness, incomplete flags, trims). - Budgeter: a deterministic ~4-chars-per-token estimate; when over budgetTokens, sections are emptied in reverse priority (history → tests → journeys → blastRadius → lineage; match reduced to top-1 last), each trim logged to warnings. - JSON Schema (schemas/context-bundle.schema.json) committed + drift-gated, mirroring the core schema setup. CLI `bundle <text> --budget N` emits the JSON bundle; lib re-exports buildBundle/ContextBundle. Tests: agent-sdk budget compliance at 2k/4k/8k + trim order + decline; parser-react integration over a real scanned graph. 41 core + 14 agent-sdk + 3 vision + 107 parser tests pass; eval green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 5.2 — Context-bundle contract
Failure mode F1 (wrong-sized output blows the agent's context window). The
ContextBundleis the budgeted payloadresolveContextproduces.match(instances + evidence),lineage(per-instance data sources),journeys(slice around the match, depth 2),blastRadius/tests/history(empty until 5.3 / 5.4 / 5.6), andwarnings(staleness, incomplete flags, trims).budgetTokens, sections are emptied in reverse priority (history → tests → journeys → blastRadius → lineage;matchis never dropped, only reduced to top-1), and each trim is logged towarnings.schemas/context-bundle.schema.json) committed + drift-gated, mirroring the core schema setup.CLI
Tests
Verification
41 core + 14 agent-sdk + 3 vision + 107 parser tests pass;
pnpm evalgreen; bundle has no leaked@coderadarimports.🤖 Generated with Claude Code