8000 fix: explicit subagent models and AbovePrompt composition (0.4.2) by dominicrico · Pull Request #10 · dominicrico/jev-router · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jev-router",
"version": "0.4.1",
"version": "0.4.2",
"description": "Asks TypeSafe Jev before each task which Claude model and effort fit best, then runs the turn on it",
"types": "./types/index.d.ts",
"userConfig": {
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to jev-router are documented here.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses [Semantic Versioning](https://semver.org/).

## [0.4.2] - 2026-10-12

### Fixed
- An explicit model on a subagent's Agent call is now kept for its whole life. Before, the subagent's first step asked Jev and replaced it. Every spawn outcome (explicit model, routed pick, failed pick) is now recorded, so a subagent never asks Jev again behind a decision made at spawn.
- The band no longer drops what other plugins draw above the prompt: it composes with them (theirs above, the band last, right above the input), also when routing is off.

## [0.4.1] - 2026-10-10

### Fixed (documentation, corrected measurements)
Expand Down Expand Up @@ -64,6 +70,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
- Benchmarks: routing fit, cost, stability, overhead and cache stickiness over 30 tasks, plus real token usage and cost per mode against no plugin.
- Ponytail-style README with logo, hero art and benchmark charts.

[0.4.2]: https://github.com/dominicrico/jev-router/compare/v0.4.1...v0.4.2
[0.4.1]: https://github.com/dominicrico/jev-router/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/dominicrico/jev-router/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/dominicrico/jev-router/compare/v0.2.0...v0.3.0
Expand Down
26 changes: 25 additions & 1 deletion hooks/band.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const PROPS = {
} as any

// Only what a routed turn needs: a Jev answer, the session model and the turn bottom.
function stubs(on: On, failJev = false) {
function stubs(on: On, failJev = false, below: unknown = { type: 'Box' }) {
mock.clock(on)
on('ui.render', { component: 'AbovePrompt' } as any, async () => below as any) // what is drawn beneath the band: nothing, or another plugin's row
on('http.fetch', async () => ({
value: failJev ? { headers: {}, ok: false, status: 500, text: 'boom' } : {
headers: {},
Expand Down Expand Up @@ -88,3 +89,26 @@ test('the band shows the session model after a Jev failure instead of waiting',
expect(band).not.toContain('waiting for the first task')
await ui.unmount()
})

const other = { type: 'Text', children: ['OTHER PLUGIN ROW'] }

test('another plugin AbovePrompt row survives next to the band', OPTS, async ($, on) => {
stubs(on, false, other)
const ui = await mountBand($)
const band = JSON.stringify(await ui.drawn())
expect(band).toContain('JEV')
expect(band).toContain('OTHER PLUGIN ROW')
expect(band.indexOf('OTHER PLUGIN ROW')).toBeLessThan(band.indexOf('JEV')) // the band stays last, right above the prompt
await ui.unmount()
})

test('the other row survives with routing off too', OPTS, async ($, on) => {
stubs(on, false, other)
mock.store(on)
await $.command.run({ command: 'jev', args: 'off' } as any)
const ui = await mountBand($)
const band = JSON.stringify(await ui.drawn())
expect(band).toContain('off')
expect(band).toContain('OTHER PLUGIN ROW')
await ui.unmount()
})
20 changes: 20 additions & 0 deletions hooks/register.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,23 @@ test('the preset option sets the starting limits', { options: { apiKey: 'k-test'
expect(w.steps[0].model).toBe('claude-sonnet-5-5')
expect(w.steps[0].effort).toBe('medium')
})

test('an explicit subagent model survives its first step, with no Jev call', OPTS, async ($, on) => {
const w = world(on, jev('haiku', 'low'))
on('agent.spawn', async (_$, e) => ({ model: e.model ?? '', agentId: 'agent-5' }) as any)
on('agent.list', async () => ({ value: [{ id: 'agent-5', description: 'find importers', type: 'Explore' }] }))
await $.agent.spawn({ prompt: 'List the importers', description: 'find importers', subagentType: 'Explore', model: 'opus' } as any)
await step($, 't1', 'agent-5')
expect(w.bodies.length).toBe(0)
expect(w.steps[0].model).toBe('claude-sonnet-5-5') // the engine's own model is left alone
})

test('a subagent whose spawn pick failed does not ask Jev again at its first step', OPTS, async ($, on) => {
const w = world(on, () => ({ ok: false, status: 500, text: 'boom' }))
on('agent.spawn', async (_$, e) => ({ model: e.model ?? '', agentId: 'agent-6' }) as any)
on('agent.list', async () => ({ value: [{ id: 'agent-6', description: 'find importers', type: 'Explore' }] }))
await $.agent.spawn({ prompt: 'List the importers', description: 'find importers', subagentType: 'Explore' } as any)
expect(w.bodies.length).toBe(1) // the spawn's own attempt
await step($, 't1', 'agent-6')
expect(w.bodies.length).toBe(1)
})
26 changes: 20 additions & 6 deletions hooks/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ async function record($: EngineInterface, cfg: Config, u: (StepUsage & { model:
await $.store.set('savings', totals)
}

// An empty Box is what "nothing drawn here" looks like, so only real content is composed with.
const hasContent = (t: any) => !!t && (t.type !== 'Box' || (t.children?.length ?? 0) > 0)

const usage = (cmd: string, list: readonly string[]) => ({ text: `Usage: /jev ${cmd} ${list.join(' | ')}` })
const applied = (name: string, v: string) => ({ text: `Jev ${name}: ${v}. Applies from the next task.` })

Expand Down Expand Up @@ -534,23 +537,25 @@ export const register: Register = (on, options) => {

// Pick the subagent's model at spawn and show it in the subagent list.
on('agent.spawn', async ($, e, next) => {
if (!cfg.routeSubagents || !(await read($, enabledAtom)) || e.model) return next(e) // an explicit model on the Agent call wins
const pick = await routeSubagent($, cfg, `spawn ${e.subagentType}: ${e.description}`, `Subagent task (${e.subagentType}): ${e.description}\n\n${e.prompt}`, e.parentModel)
if (!pick) return next(e)
const res = await next({ ...e, model: pick.alias, description: `${e.description} · ${pick.alias}/${pick.effort}` })
if (!cfg.routeSubagents || !(await read($, enabledAtom))) return next(e)
// Every outcome is recorded for the agent's lifetime, so its steps never ask Jev again behind a decision made here:
// an explicit model on the Agent call wins, and a failed pick leaves the engine's own model (null = no override).
const pick = e.model ? null : await routeSubagent($, cfg, `spawn ${e.subagentType}: ${e.description}`, `Subagent task (${e.subagentType}): ${e.description}\n\n${e.prompt}`, e.parentModel)
const res = await next(pick ? { ...e, model: pick.alias, description: `${e.description} · ${pick.alias}/${pick.effort}` } : e)
if (res.agentId) agents.set(res.agentId, Promise.resolve(pick)) // its steps reuse the pick (and its effort)

return res
})

on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey) return next(e)
const below = await next(e) // whatever other plugins draw here stays; ours goes last, right above the prompt
if (e.props.hasSurvey) return below
const { Box, Text } = $.ui.resolve(e)
const segs: Seg[] = (await read($, enabledAtom))
? segments(await currentMode($, cfg), await read($, lastAtom), e.props.isWorking ? await read($, frameAtom) : null, await cacheLabel($, cfg), isPaused(await $.clock.now()), await read($, ranAtom))
: [{ text: 'JEV ▏off▕', color: '#64748b' }, ...((await read($, ranAtom)) ? [{ text: ` ${(await read($, ranAtom))!.alias} (session model)`, color: '#475569' }] : [])]

return (
const row = (
<Box>
<Text>
{segs.map(x => (
Expand All @@ -561,6 +566,15 @@ export const register: Register = (on, options) => {
</Text>
</Box>
)

return hasContent(below) ? (
<Box flexDirection="column">
{below}
{row}
</Box>
) : (
row
)
})

on('session.start', async ($, e, next) => {
Expand Down
Loading
0