feat(schema,rpc-output-budget): per-step outputLimit knobs (maxBytes, maxAssistantFinals)#5
Open
ShinonKagura wants to merge 1 commit into
Open
Conversation
… maxAssistantFinals)
Adds an optional `outputLimit: { maxBytes?, maxAssistantFinals? }`
field on graph steps. Both fields clamp the existing package-level
caps (`MAX_STEP_OUTPUT_BYTES`, `MAX_ASSISTANT_FINAL_MESSAGES_PER_STEP`)
downward only; raising above the cap or passing invalid values
silently falls back to the cap.
Surfaces:
- StepOutputLimitSpec interface in types.ts
- StepOutputLimitSchema + outputLimit on StepSchema in schemas.ts
- AssistantOutputBudget constructor accepts AssistantOutputBudgetLimits
- RpcChildController forwards options.outputLimit to AssistantOutputBudget
- Detached run plumbs step.outputLimit to the controller
- planning.resolveStep carries step.outputLimit into TeamStepSpec
Default behavior is unchanged: omitting outputLimit (or all step
configs without it) yields the same package-level caps as before.
Tests (tests/rpc-output-budget.test.ts) verify default fallback,
honored downward limits for both knobs, upward-clamp protection,
and invalid-input fallback (zero, negative, fractional, NaN, Infinity).
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.
Third of three focused PRs splitting out the usable parts of #2 against current
main, as requested in your review. This is the only feature of the three (not a fix) — you mentioned "output-limit knobs as a separate small feature" in #2 as a candidate.What
Adds optional per-step
outputLimit: { maxBytes?, maxAssistantFinals? }field on graph steps. Both fields clamp the existing package-level caps (MAX_STEP_OUTPUT_BYTES = 4 MiB,MAX_ASSISTANT_FINAL_MESSAGES_PER_STEP = 64) downward only.Out-of-range and non-integer values are rejected by schema validation; an additional runtime clamp in
AssistantOutputBudgetserves as defense-in-depth for any caller that bypasses schema validation.Example
{ "id": "tight", "agent": { "ref": "package:scout" }, "task": "Return the top 5 most relevant files as a numbered list. No prose preamble.", "outputLimit": { "maxBytes": 4096, "maxAssistantFinals": 1 } }This step can produce at most 4 KiB of assistant output across at most 1 final message, instead of the 4 MiB / 64 defaults. Useful when you want a hard structural guarantee that a step's output stays inside a known small budget (chat-fit summaries, one-line decisions, bounded JSON returns).
Plumbing chain (verified end-to-end)
GraphStepInput.outputLimit(types.ts)→
resolveStep(planning.ts)→
TeamStepSpec.outputLimit→
new RpcChildController({outputLimit})(detached-run.ts)→
new AssistantOutputBudget({maxBytes, maxAssistantFinals})(rpc-child-controller.ts)Backwards-compatibility
constructor(limits: AssistantOutputBudgetLimits = {})— omittingoutputLimit(or the entire field) yields exactly the package caps.new AssistantOutputBudget()without args still works for existing callers and tests.Tests (+9 new)
tests/rpc-output-budget.test.ts(NEW, 7 tests): default fallback, downward honor for both knobs, upward clamp protection for both knobs, byte-limit path incanAcceptAssistantFinal, invalid-input fallback (0, -1, 1.5, NaN, Infinity) for both knobstests/schemas.test.ts(+1 test, 11 assertions): valid downward, out-of-range rejection, non-integer rejection (multipleOf:1guard), unknown-field rejection (additionalProperties:false)tests/planning.test.ts(+1 test, 2 assertions):resolveSteppropagation with + withoutoutputLimitTotal: 244 baseline tests → 253 with this PR.
Discipline
feat(schema,rpc-output-budget): ...)## UnreleasedonlySKILL.mdpseudo-schema updated (step { ..., outputLimit? }) with explanation paragraphREADME.mdLimits table extended withPer-step outputLimit overriderowskills/pi-multiagent/references/graph-cookbook.mdhas a copyable "Per-step output limit override" snippetgetEffectiveLimits()marked@internalJSDocRequired checks against this branch
npx tsc --noEmitnode --test tests/*.test.tsnode tests/check-source-size.tsnode tests/check-public-docs.tsgit diff --check HEAD~1..HEADRelated
Closes the smallest feature carved out of #2. Companion PRs:
GRAPH_BODY_FIELDStrimThree proposal-issues for the larger features (scheduling, persistent state + reattach, worktree isolation) will be opened separately so we can agree on shape before code, as you requested.