Repository navigation
π± tokens: cap promptsrc at 64 KiB and reject oversize whole instead of truncating - #12151
Conversation
β¦f truncating DefaultMaxPromptBytes = 64 KiB (largest shipped template ~28 KiB, >2x headroom, pinned by TestShippedTemplatesFitUnderCap), overridable via HIVE_PROMPT_SOURCE_MAX_BYTES. A body over the cap is rejected whole: Resolve falls back to the cached copy, then the caller's inline chain, logging repo/path/size/cap; FetchOnce returns ErrPromptTooLarge so the dashboard refuses to bake a half-policy. Documented in operator-reference, env-vars and agent-configuration. Closes #12130 Refs #12134 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at c9f1586. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #12130
Refs #12134
What
pkg/promptsrc:maxPromptBytes = 512 KiB(memory bound) βDefaultMaxPromptBytes = 64 KiB(token budget), a named exported constant. Measured against every shipped template insrc/policies/andsrc/pkg/policies/defaults/(83 files): the largest isscanner-automerge.mdat 27,890 bytes, so 64 KiB is 2.3Γ headroom.TestShippedTemplatesFitUnderCapwalks both trees and fails if any template drops under 2Γ headroom, naming the file.HIVE_PROMPT_SOURCE_MAX_BYTES(bytes, orKiB/MiBsuffix); unparseable/non-positive keeps the default.Resolver.SetMaxBytesfor programmatic override.Resolvelogsprompt from GitHub exceeds size cap; REJECTED whole (not truncated), falling backwithrepo,path,ref,size_bytes,cap_bytes,override_env, then serves the last-known-good cached copy if any, else returnsOk=false, Source:"oversize"so the scheduler takes the next resolution step (kick_templateβ pack β convention β embedded default). The rejected body is never cached.FetchOncereturns a wrappedErrPromptTooLargenaming source, size and cap, so the dashboard's bake/save flow refuses rather than writing a cut-off policy to/data/policies.operator-reference.md(Notable fields),env-vars.md,agent-configuration.md; changelog fragment.Constraints from the issue
*_TruncatesOversizeBodytests are replaced by reject/fallback/log tests.Validation
gofmt -lclean on touched files;go build ./...,go vet ./pkg/promptsrc/... ./pkg/dashboard/ ./pkg/scheduler/,go test ./pkg/promptsrc/... ./pkg/config/...green locally.cc @mrbobbytables