Skip to content

Dream synthesize significance judge hardcodes ANTHROPIC_API_KEY — no fallback for other LLM providers #1348

@justemu

Description

@justemu

Problem

The dream cycle's synthesize phase (src/core/cycle/synthesize.ts) has a significance judge that hardcodes ANTHROPIC_API_KEY as the only authentication mechanism:

function makeHaikuClient(): JudgeClient | null {
  if (!process.env.ANTHROPIC_API_KEY) return null;  // <- hardcoded
  const client = new Anthropic();
  return { create: client.messages.create.bind(client.messages) };
}

When ANTHROPIC_API_KEY is unset, all conversation transcripts are unconditionally marked as worth: false with reason "no ANTHROPIC_API_KEY for significance judge", making the synthesize phase non-functional for users who rely on alternative LLM providers.

This is increasingly common as high-quality, cost-effective models like DeepSeek v4 Flash, Gemini, and local endpoints become viable alternatives to Claude Haiku for lightweight judging tasks.

Impact

  • Users without Anthropic access cannot use the dream synthesize phase at all
  • The significance judge (a lightweight JSON-classification task) does not require the specific capabilities of Claude Haiku — any capable LLM can perform it
  • The hardcoded provider check prevents innovation in the GBrain ecosystem

Suggested solution

Replace makeHaikuClient() with a makeJudgeClient() that:

  1. Tries ANTHROPIC_API_KEY first (preserving original behavior)
  2. Falls back to DEEPSEEK_API_KEY, OPENAI_API_KEY, or OPENROUTER_API_KEY via an OpenAI-compatible fetch adapter
  3. Supports configurable base URLs via DEEPSEEK_BASE_URL / OPENAI_BASE_URL environment variables

I have a working implementation at https://github.com/justemu/gbrain/pull/1 that has been tested with DeepSeek v4 Flash — 3/5 real-world transcripts correctly judged as worth processing, 2/5 correctly filtered as routine operations.

Alternatives considered

  • Configuration-based model routing: More flexible but requires more extensive refactoring of the judge infrastructure. The env-var fallback approach is minimal-risk and backward-compatible.
  • agent.use_gateway_loop: The gbrain doctor suggests this for non-Anthropic setups, but the synthesize judge has a separate code path that ignores this config and hardcodes the Anthropic SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions