fix(router): only Haiku 4.x takes no effort; Haiku 5.x gets its route's

The no-effort rule was keyed on every claude-haiku id, so Haiku 5.5 ran at the engine default instead of its phase effort (mechanical: low). The guard now names Haiku 4.x; status-reporter pins effort: low.
This commit is contained in:
bchanot committed 2026-10-25 22:19:55 +01:00
1 parent a6b94a4c46
commit 8e93507b19
7 files changed
+165 -12

No files matched your search

+75 -3
View File
@@ -857,7 +857,52 @@ test('cap: a downgrade under the cold-read cap moves main', async (
await $.tool.call({ tool: ROUTE_TOOL, phase: 'mechanical' })
const sent = await stepOn($, rig, FABLE)
expect(sent.model).toBe(HAIKU)
expect(sent.effort).toBe('low')
})
const HAIKU_4 = 'claude-haiku-4-5-20251001'
const HAIKU_4_HOME = { home: { models: { haiku: HAIKU_4 } } }
test('haiku 5: /route show prints the effort, not "takes none"', async (
$, on) => {
await bootRig($, on)
await $.tool.call({ tool: ROUTE_TOOL, phase: 'mechanical' })
const line = mainLine(await route($, 'show'))
expect(line).toContain('effort low')
expect(line).not.toContain('takes none')
})
test('haiku 4: a routed step keeps no effort, show says so', async (
$, on) => {
const rig = await bootRig($, on, FABLE, 1000, newWorld(HAIKU_4_HOME))
await $.tool.call({ tool: ROUTE_TOOL, phase: 'mechanical' })
const sent = await stepOn($, rig, FABLE)
expect(sent.model).toBe(HAIKU_4)
expect(sent.effort).toBeUndefined()
expect(mainLine(await route($, 'show'))).toContain('haiku 4 takes none')
})
test('haiku 5: an unrouted step passes the engine effort', async (
$, on) => {
const rig = await bootRig($, on, HAIKU)
expect(await stepOn($, rig, HAIKU)).toEqual({
model: HAIKU,
effort: 'high',
})
})
test('haiku 5: a plan keyword on a haiku session is xhigh', async (
$, on) => {
const rig = await bootRig($, on, HAIKU)
await $.prompt.submit({
text: 'plan the migration',
wait: false,
origin: { kind: 'composer' },
})
expect(await stepOn($, rig, HAIKU)).toEqual({
model: HAIKU,
effort: 'xhigh',
})
})
test('fallback: a rate limit on fable moves plan to opus max', async (
@@ -3835,7 +3880,8 @@ test('logs: a downgrade is a switch', async ($, on) => {
await route($, 'mechanical')
await runStep($, highStep())
expect(logs).toEqual([
mainWord('fable/high', 'haiku/-', 'mechanical: sticky /route, switch'),
mainWord('fable/high', 'haiku/low',
'mechanical: sticky /route, switch'),
])
})
@@ -4035,13 +4081,14 @@ test('logs: an explicit effort is one line, then silence', async ($, on) => {
expect(logs).toEqual([line])
})
test('logs: a haiku spawn shows no effort, then silence', async ($, on) => {
test('logs: a haiku spawn shows its effort, then silence', async (
$, on) => {
const world = newWorld({
edit: f => { (f.agents as Rec).feater = 'mechanical' },
})
const { logs } = await afterMainStep($, on, { world })
await $.agent.spawn(spawnOf('feater'))
const line = 'main fable/high → agent feater haiku/- ' +
const line = 'main fable/high → agent feater haiku/low ' +
'(row mechanical, row)'
expect(logs).toEqual([line])
await runStep($, { ...highStep('a1'), model: HAIKU })
@@ -4064,6 +4111,31 @@ test('logs: two agent types to one model are two hand-offs', async (
expect(handoffs(logs)).toHaveLength(2)
})
test('logs: a haiku 4 spawn shows no effort, then silence', async (
$, on) => {
const world = newWorld({
...HAIKU_4_HOME,
edit: f => { (f.agents as Rec).feater = 'mechanical' },
})
const { logs } = await afterMainStep($, on, { world })
await $.agent.spawn(spawnOf('feater'))
const line = 'main fable/high → agent feater haiku/- ' +
'(row mechanical, row)'
expect(logs).toEqual([line])
await runStep($, { ...highStep('a1'), model: HAIKU_4 })
expect(logs).toEqual([line])
})
test('logs: an unrowed haiku spawn is silent at its first step', async (
$, on) => {
const { logs } = await afterMainStep($, on)
await $.agent.spawn(spawnOf('unrowed', { model: 'haiku' }))
const line = 'main fable/high → agent unrowed haiku/- (explicit, engine)'
expect(logs).toEqual([line])
await runStep($, { ...highStep('a1'), model: HAIKU })
expect(logs).toEqual([line])
})
test('logs: one agent type to two models is two hand-offs', async (
$, on) => {
const { logs } = await afterMainStep($, on)
+11 -6
View File
@@ -211,6 +211,7 @@ const SKILL_NAME = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/
const ROWS: readonly Row[] = ['skills', 'agents']
const KINDS: readonly Kind[] = ['skills', 'agents', 'phases']
const HAIKU = 'claude-haiku'
const NO_EFFORT = 'claude-haiku-4' // Haiku 4.x takes no effort; 5.x does
const MAX_PATTERN = 200 // chars of a prompt-rule pattern
const MAX_PROMPT_SCAN = 4096 // chars of a prompt a rule is run against
const MAX_CONFIG_BYTES = 65536 // override file size
@@ -1870,9 +1871,9 @@ function standInWord(st: State, v: Verdict): string {
return `${alias} stands in for ${head}`
}
/** Haiku takes no effort: the main line says so when it will run there. */
/** Haiku 4.x takes no effort: the main line says so when it runs there. */
function effortWord(st: State, v: Verdict): string {
if (v.call.model.startsWith(HAIKU)) return '- (haiku takes none)'
if (takesNoEffort(st.cfg, v.call.model)) return '- (haiku 4 takes none)'
const d = standInEffort(st, mainEffort(st, undefined), v)
const word = String(d.effort ?? '-')
return d.standIn ? `${word} (${standInWord(st, v)})` : word
@@ -3678,6 +3679,9 @@ const NAME_CAP = 40 // code points of any name read from outside, in a line
const isHaiku = (cfg: Config, id: string): boolean =>
canonical(cfg, id).startsWith(HAIKU)
const takesNoEffort = (cfg: Config, id: string): boolean =>
canonical(cfg, id).startsWith(NO_EFFORT)
/** The table alias of a model id (a `[1m]` marker kept), else the id. */
function nameOf(cfg: Config, id: string): string {
const bare = canonical(cfg, id)
@@ -3830,7 +3834,7 @@ function handoffOf(
!pinned) {
return undefined
}
const effort = isHaiku(st.cfg, started.model)
const effort = takesNoEffort(st.cfg, started.model)
? undefined
: given ?? route?.effort
return {
@@ -3946,8 +3950,8 @@ async function planStep(
const step: Step = e.agentId === undefined
? await mainPlan($, st, e, signal)
: { plan: agentPlan(st, e) }
// Haiku takes no effort: omit it rather than send a hook-set value.
return step.plan.model.startsWith(HAIKU)
// Haiku 4.x takes no effort: omit it rather than send a hook-set value.
return takesNoEffort(st.cfg, step.plan.model)
? { ...step, plan: { ...step.plan, effort: undefined } }
: step
}
@@ -4235,7 +4239,8 @@ function afterSpawn($: Api, st: State, sp: Spawned): void {
const hand = handoffOf(st, sp, given)
if (hand === undefined) return
// an effort the engine picks is unknown here: the first step tells it
if (hand.effortCause !== 'engine' || isHaiku(st.cfg, hand.to.model)) {
if (hand.effortCause !== 'engine' ||
takesNoEffort(st.cfg, hand.to.model)) {
loop.last = hand.to
}
if (!st.cfg.verbose) return