Fix #283: token budget + graceful degradation for /deep-research#316
Open
ericleepi314 wants to merge 1 commit into
Open
Fix #283: token budget + graceful degradation for /deep-research#316ericleepi314 wants to merge 1 commit into
ericleepi314 wants to merge 1 commit into
Conversation
A verbose model burned ~888k tokens in Search+Verify with no ceiling and no warning. - engine: a workflow's meta may declare default_budget, applied when the caller set no budget (explicit budget_total and inherited parent Budgets win; nested workflow() children unaffected). Per-workflow env override CLAWCODEX_<NAME>_TOKEN_BUDGET — deep-research reads exactly CLAWCODEX_DEEP_RESEARCH_TOKEN_BUDGET (0 disables) - deep-research declares default_budget=400000 and degrades instead of dying: the Verify fan-out only launches as many verifiers as the remaining budget affords (estimated from the observed Search spend, Synthesize reserve held back); unaffordable claims pass through UNVERIFIED with a log line; a None verdict (crashed verifier or ceiling trip) keeps its claim instead of silently dropping it; and if the already-launched waves overshot the whole budget, Synthesize falls back to returning the raw surviving claims rather than failing after full spend - per-stage spend surfaced via log lines (the progress UI narrator) Closes #283 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
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.
Closes #283
Summary
/deep-researchhad no token ceiling — a verbose model (deepseek) burned ~888k tokens in Search+Verify before the user saw anything.Engine
meta.default_budget— a workflow may declare its own ceiling, applied only when the caller set no budget (explicitbudget_totaland inherited parentBudgets win; nestedworkflow()children share the parent's budget and are unaffected).CLAWCODEX_<NAME>_TOKEN_BUDGET— deep-research reads exactly the env var the issue names,CLAWCODEX_DEEP_RESEARCH_TOKEN_BUDGET(0disables; malformed values ignored).deep-research script (
default_budget: 400000)Noneverdicts keep their claims (crashed verifier or ceiling trip) instead of silently dropping them — a pre-existing bug fixed along the way.log()lines (the progress-UI narrator).Test plan
error is None, exactly 4 agent callsFollow-ups noted in review (non-gating): chunked verify waves with budget recomputation, exposing workflow error classes in the sandbox builtins, a user-facing budget parameter on the Workflow tool.
🤖 Generated with Claude Code