fix(dream): drop ANTHROPIC_API_KEY gate from patterns phase#2279
Open
brettdavies wants to merge 1 commit into
Open
fix(dream): drop ANTHROPIC_API_KEY gate from patterns phase#2279brettdavies wants to merge 1 commit into
brettdavies wants to merge 1 commit into
Conversation
Synthesize phase already removed its hardcoded `process.env.ANTHROPIC_API_KEY` cheap-skip; the makeJudgeClient docstring at synthesize.ts:804 documents why: non-Anthropic stacks (litellm/codex-proxy, deepseek, openrouter, ollama, etc.) reach their upstream through the gateway recipe machinery, not an env-var presence check. The patterns phase still carried the legacy gate, so on a codex-proxy stack `gbrain dream --phase patterns` short-circuited with `ANTHROPIC_API_KEY unset; pattern detection skipped` even though synthesize in the same cycle drained 800+ reflection subagents via litellm:gpt-5.5 without issue. Removing the gate is the matching change. The subagent submission below uses the same gateway routing synthesize already proves works on this stack, and when the gateway IS misconfigured the subagent dispatch surfaces a clear AIConfigError rather than a silent "skipped: no_api_key" verdict that misclassifies the failure. Verified end-to-end on a production-shaped brain: 834 reflections available for pattern mining, patterns phase wrote 5 pattern pages including `areas/patterns/bounded-subagents-and-orchestrator-writes`.
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 #2278
Summary
The bug.
gbrain dream --phase patternsreturns{ status: 'skipped', reason: 'no_api_key' }on any non-Anthropic stack (litellm-proxy, codex-proxy, ollama, openrouter, any openai-compat deployment) regardless of howmodels.dream.patternsresolves. The phase never reaches its subagent submission below, which would have routed through the gateway and dispatched correctly.The fix. Drop the
if (!process.env.ANTHROPIC_API_KEY)short-circuit insrc/core/cycle/patterns.ts. The subagent submission below already uses the same gateway model-tier resolver that synthesize uses; when the gateway is misconfigured, dispatch surfaces a clearAIConfigErrorper-call rather than a misclassifiedskipped: no_api_keyverdict.Diagnosis
src/core/cycle/patterns.ts:67-69(pre-patch) short-circuits whenANTHROPIC_API_KEYis unset:ts if (!process.env.ANTHROPIC_API_KEY) { return skipped('no_api_key', 'ANTHROPIC_API_KEY unset; pattern detection skipped'); }The submission immediately below the gate calls
submitSubagent(...), which routes throughgateway.toolLoop()via the recipe registered for whichever model the resolver selected. That path already supports every non-Anthropic recipe (litellm, ollama, openrouter, openai, claude-cli, …).The sibling synthesize phase removed its equivalent gate (see the
makeJudgeClientdocstring atsrc/core/cycle/synthesize.ts:804, which "preserves the legacy 'no ANTHROPIC_API_KEY' cheap-skip semantics" while delegating real auth probing to the gateway recipe'sauth_env.requiredmachinery).The patterns phase carries the same pattern in its body but never had the gate updated when the rest of the cycle moved to gateway-routed dispatch.
Reproduction
ANTHROPIC_API_KEYin env, paid traffic routed through any non-Anthropic recipe.gbrain config set models.dream.patterns litellm:gpt-5.4(or any non-anthropic:*model).gbrain dream --phase patterns --json.{ status: 'skipped', reason: 'no_api_key' }.Tests
models.dream.patterns = litellm:gpt-5.4and noANTHROPIC_API_KEYin env: pre-patch returned theskippedverdict; post-patch dispatched through the litellm route and returned pattern detections.ANTHROPIC_API_KEYis unset if the maintainer prefers.Adjacent observation (follow-up, not in this PR)
Other phases / commands may carry similar stale
ANTHROPIC_API_KEYchecks that pre-date the gateway-routed dispatch. Worth arg -n 'ANTHROPIC_API_KEY' src/core/cycle src/commandssweep to catch siblings. The synthesize phase is already clean; patterns is the one this PR fixes. Anything else found would be a separate small PR per site.