Skip to content

v0.50.0.1 feat(ai): OpenRouter xAI (x-ai/) routes may drive the subagent loop — live abort/retry pin - #5035

Open
danpal35 wants to merge 1 commit into
garrytan:masterfrom
danpal35:feat/openrouter-xai-subagent-loop
Open

v0.50.0.1 feat(ai): OpenRouter xAI (x-ai/) routes may drive the subagent loop — live abort/retry pin#5035
danpal35 wants to merge 1 commit into
garrytan:masterfrom
danpal35:feat/openrouter-xai-subagent-loop

Conversation

@danpal35

Copy link
Copy Markdown

What

openrouter:x-ai/* models (Grok 4.6 etc.) can now drive the subagent loop. x-ai/ joins anthropic/ and deepseek/ in OPENROUTER_SUBAGENT_FAMILIES, so classifyCapabilities() accepts the model and the handler auto-routes the job through gateway.toolLoop(). Every other OpenRouter family stays refused, as before.

Why

The families registry says a proxied family is admitted only once it has a live abort/retry pin proving its tool-call envelope survives an abort mid-loop and a resume byte-identically. Anthropic and DeepSeek have one; xAI did not, so a brain configured with openrouter:x-ai/grok-4.6 as its subagent model was refused even though the OpenAI-compatible envelope OpenRouter uses for xAI replays cleanly (the gateway keys replay on gbrain_tool_use_id, not the provider id).

test/e2e/openrouter-xai-subagent-replay.live.test.ts is that pin, a sibling of the DeepSeek one: first turn calls the tool once, the job aborts after the observation, the resume finishes with end_turn without re-executing the tool, and the persisted assistant content_blocks are identical across the resume. Skip-gated on OPENROUTER_API_KEY.

I have been running Grok 4.6 as the subagent model on a Postgres brain with this one-line change carried as a local patch since 2026-09-01 (dream / autopilot subagent jobs), with no replay problems.

Discrimination test (required for every fix — #3665)

Discrimination test: reverted src/core/ai/openrouter-families.ts to merge-base, ran test/model-config.serial.test.ts → 45 pass / 1 fail. Restored → all pass.

Discrimination test: reverted src/core/ai/openrouter-families.ts to merge-base, ran test/e2e/openrouter-xai-subagent-replay.live.test.ts → 0 pass / 1 fail. Restored → all pass.

Tests

  • GBRAIN_TEST_KEEP_PROVIDER_KEYS=1 OPENROUTER_API_KEY=… bun test test/e2e/openrouter-xai-subagent-replay.live.test.ts → 1 pass, 7 expect() calls, ~4s against live OpenRouter x-ai/grok-4.6. Run twice, both green.
  • bun test test/model-config.serial.test.ts → 46 pass (adds isOpenRouterSubagentFamily('openrouter:x-ai/grok-4.6') → true).
  • bun run typecheck clean.
  • Docstrings in src/core/ai/recipes/openrouter.ts that enumerate the allowed families updated to include xAI.

🤖 Generated with Claude Code

… live abort/retry pin

Add `x-ai/` to OPENROUTER_SUBAGENT_FAMILIES so `openrouter:x-ai/*` models
(Grok 4.6 etc.) are accepted by classifyCapabilities() and auto-routed
through gateway.toolLoop(), the same way anthropic/ and deepseek/ are.

The admission ticket for a family is a live abort/retry pin proving the
proxied tool-call envelope survives an abort mid-loop and a resume
byte-identically. test/e2e/openrouter-xai-subagent-replay.live.test.ts is
that pin for xAI: first turn calls the tool once, the job aborts after the
observation, the resume finishes with end_turn without re-executing the tool
and the persisted assistant content_blocks are identical across the resume.
Skip-gated on OPENROUTER_API_KEY like the Anthropic and DeepSeek pins.

Also pins the family in the deterministic model-config unit test and updates
the recipe docstrings that enumerate the allowed families.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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