Skip to content

fix: harden AI notes + Ask-this-series against provider quirks#97

Merged
pratikbodkhe merged 2 commits into
mainfrom
audit-openrouter-notes-enhancer
Jun 5, 2026
Merged

fix: harden AI notes + Ask-this-series against provider quirks#97
pratikbodkhe merged 2 commits into
mainfrom
audit-openrouter-notes-enhancer

Conversation

@pratikbodkhe

Copy link
Copy Markdown
Contributor

Audit of the OpenRouter notes enhancer plus the live /ask 502 fix.

Root cause

minimax-m3 (a) wraps its JSON in markdown ```json fences despite json_object mode, and (b) returns Ask-this-series citations as bare id strings rather than objects. Both made /ask (and intermittently `/enhance-notes`) return 502 on parse.

Changes

  • Shared stripJsonFences helper; applied in both /ask and /enhance-notes before JSON.parse.
  • Coerce bare-string citations to objects; drop malformed citations instead of throwing the whole answer.
  • Enhance route: auth check precedes provider-config check; prompt hardening; tighter typing.
  • Contract verifier: added coverage for fenced JSON, string citations, dropped malformed citations, and a real-backend /ask path.

Verified: contract verifier green, lint clean, live OpenRouter output reproduced and confirmed parseable.

minimax-m3 wraps responses in markdown code fences and returns Ask-this-series
citations as bare id strings, which made /ask and /enhance-notes 502 on parse.
Strip code fences before JSON.parse (shared helper), coerce string citations to
objects, and drop malformed citations instead of rejecting the whole answer.
Adds contract coverage for fenced JSON, string citations, and dropped citations.
…lite

The three AI routes hardcoded minimax/minimax-m3 and ignored the AI_MODEL env
that infra already plumbed. Add getAiModel() (OPENROUTER_MODEL || AI_MODEL ||
default) and use it everywhere; set the default and .env/compose to
google/gemini-3.1-flash-lite. Contract + e2e assert config-driven resolution.
@pratikbodkhe pratikbodkhe merged commit 03e1bb1 into main Jun 5, 2026
18 checks passed
pratikbodkhe added a commit that referenced this pull request Jun 5, 2026
fix: harden AI notes + Ask-this-series against provider quirks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant