Skip to content

[recipes] Fix typed-edge-classifier model routing for OpenRouter - #374

Open
hadolphs wants to merge 1 commit into
NateBJones-Projects:mainfrom
hadolphs:contrib/hadolphs/typed-edge-classifier-openrouter-models
Open

[recipes] Fix typed-edge-classifier model routing for OpenRouter#374
hadolphs wants to merge 1 commit into
NateBJones-Projects:mainfrom
hadolphs:contrib/hadolphs/typed-edge-classifier-openrouter-models

Conversation

@hadolphs

Copy link
Copy Markdown

Problem

recipes/typed-edge-classifier/classify-edges.mjs ships with Anthropic's canonical model names as defaults (claude-haiku-4-5-20251001 for the filter, claude-opus-4-7 for classify). When the provider is OpenRouter — the recipe's recommended provider — resolveModel() only prepends anthropic/, producing slugs like anthropic/claude-haiku-4-5-20251001 that don't exist on OpenRouter. OpenRouter exposes these models under dotted slugs (anthropic/claude-haiku-4.5, anthropic/claude-opus-4.7).

The result is that every Haiku-filter and Opus-classify call fails, so a default run writes nothing:

[classify-edges] status counts: { filter_error: 3 }
[classify-edges] estimated spend: $0.0000 of $0.50 cap

Fix

Add an explicit OPENROUTER_MODEL_MAP and consult it in resolveModel() before falling back to the bare anthropic/ prefix, mapping the names OB1 ships as defaults to their OpenRouter slugs.

  • Anthropic-direct path unchanged — guarded by provider !== "openrouter".
  • Cost cap unaffectedestimateCost() / assertPricingKnown() are always called with the raw, pre-resolve names, which remain keys in PRICING. No PRICING changes and no default-model changes.
  • Docstring + README updated to describe mapping rather than prefixing.

Verification

With OpenRouter configured, the same run now classifies and writes edges:

[classify-edges] status counts: { inserted: 2, filter_rejected: 1 }
[classify-edges] estimated spend: $0.0541 of $1.00 cap
  [ok] inserted   conf=0.85  ... -[evolved_into]-> ...
  [ok] inserted   conf=0.75  ... -[related_to]-> ...

Rows confirmed present in public.thought_edges.

@github-actions github-actions Bot added the recipe Contribution: step-by-step recipe label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Hey @hadolphs — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

The classifier defaults to Anthropic dated/dashed model names
(claude-haiku-4-5-20251001, claude-opus-4-7). On OpenRouter resolveModel
only added an 'anthropic/' prefix, producing slugs that 404 because
OpenRouter uses dotted slugs (anthropic/claude-haiku-4.5,
anthropic/claude-opus-4.7). Result: every filter/classify call failed
with filter_error for the repo's recommended provider.

Add an explicit OPENROUTER_MODEL_MAP in resolveModel so the shipped
defaults route correctly out of the box. The Anthropic-direct path is
unchanged (provider guard), and cost estimation is unaffected because
estimateCost() is always called with the raw pre-resolve names that
remain in PRICING. Docs updated to match.
@hadolphs
hadolphs force-pushed the contrib/hadolphs/typed-edge-classifier-openrouter-models branch from 24adf3f to b233360 Compare September 3, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Contribution: step-by-step recipe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant