Files
ruflo/v3/@claude-flow/cli/__tests__/agent-execute-models.test.ts
T
rUvandReuven 16e59c2613 fix(#1906): agent_execute model aliases → current Claude 4.x ids (not deprecated claude-3.x) (#1908)
`MODEL_MAP` in agent-execute-core.ts mapped haiku/sonnet/opus/inherit to
`claude-3-5-haiku-latest` / `claude-3-5-sonnet-latest` / `claude-3-opus-latest`
— ids the Anthropic API now 404s. Every `agent_execute` call (and the WASM
agent's LLM fallback, which routes through `resolveAnthropicModel`) failed
with HTTP 404 even with a valid key.

Fixed mappings (Claude 4.x family):
  haiku   → claude-haiku-4-5-20251001
  sonnet  → claude-sonnet-4-6
  opus    → claude-opus-4-7
  inherit → claude-sonnet-4-6  (= new DEFAULT_ANTHROPIC_MODEL)

Also replaced the 4 other hardcoded `claude-3-5-sonnet-latest` defaults
(`callAnthropicMessages` fallback, `resolveAnthropicModel` no-input case,
`executeAgentTask` fallback, the doc-comment example) with
`DEFAULT_ANTHROPIC_MODEL`.

## CI coverage (the user's ask: "make sure the ci guard doesn't miss these")

Two layers:
1. Unit test `__tests__/agent-execute-models.test.ts` — picked up by the
   cli package's vitest run in CI. Asserts each alias resolves to the
   right Claude-4.x id, the prefix-strip works, the pass-through works,
   and — critically — `no alias resolves to a claude-3.x id` (the #1906
   regression-class assertion). 8/8 pass.
2. Witness marker `#1906` in the manifest — `claude-sonnet-4-6` must be
   present in `agent-execute-core.js` dist; `witness-verify` fails on
   regression. 104/104 fixes verified.

Closes #1906 · related to #1863 (agent_execute was the path #1863's
comment pointed users at — now it actually works)

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-11 11:02:35 -04:00

38 lines
1.6 KiB
TypeScript

/**
* Regression guard for ruvnet/ruflo#1906 — model aliases must map to
* current (Claude 4.x) model ids, not the deprecated Claude-3.x ids that
* the Anthropic API now 404s.
*/
import { describe, it, expect } from 'vitest';
import { resolveAnthropicModel, DEFAULT_ANTHROPIC_MODEL } from '../src/mcp-tools/agent-execute-core.js';
describe('#1906 — agent_execute model aliases resolve to current Claude 4.x ids', () => {
it('haiku → claude-haiku-4-5-20251001', () => {
expect(resolveAnthropicModel('haiku')).toBe('claude-haiku-4-5-20251001');
});
it('sonnet → claude-sonnet-4-6', () => {
expect(resolveAnthropicModel('sonnet')).toBe('claude-sonnet-4-6');
});
it('opus → claude-opus-4-7', () => {
expect(resolveAnthropicModel('opus')).toBe('claude-opus-4-7');
});
it('inherit → the default (sonnet 4.6)', () => {
expect(resolveAnthropicModel('inherit')).toBe('claude-sonnet-4-6');
expect(DEFAULT_ANTHROPIC_MODEL).toBe('claude-sonnet-4-6');
});
it('undefined → the default', () => {
expect(resolveAnthropicModel(undefined)).toBe(DEFAULT_ANTHROPIC_MODEL);
});
it('anthropic:<id> prefix is stripped', () => {
expect(resolveAnthropicModel('anthropic:claude-opus-4-7')).toBe('claude-opus-4-7');
});
it('a bare model id passes through unchanged', () => {
expect(resolveAnthropicModel('claude-sonnet-4-6')).toBe('claude-sonnet-4-6');
});
it('no alias resolves to a deprecated claude-3.x id (#1906 regression)', () => {
for (const alias of ['haiku', 'sonnet', 'opus', 'inherit', undefined]) {
expect(resolveAnthropicModel(alias as string | undefined)).not.toMatch(/^claude-3[.-]/);
}
});
});