SLOPSHOPPER

agent-model-badge

Shows each spawned subagent's resolved model and effort beside its row, so a surprise model assignment is visible at a glance.

rowsguardtoast
v0.1.0MITupdated 2026-10-10New-Retr0/claude-dock/agent-model-badge
A shopper browsing a rack in a slop shop
README

Agent Model Badge

See the model and effort every subagent really runs on.

<img src="assets/badge.gif" alt="Three subagents shown without the badge, then with each one labelled sonnet and low" width="900">

When Claude spawns subagents, Claude Code shows what each one is doing, but not which model it runs on. Agent Model Badge adds that. Each subagent's row, its entry in the task list, and its "finished" line carry its model and thinking effort. The task list shows the model the call asked for, or your session's own model when the call names none, with the effort the call asked for or the one that model last ran at in this session. The transcript row then shows the model and effort the agent really runs on, from its first request.

◯ general-purpose  Count lines in cart.js  ·  sonnet  ·  low
◯ general-purpose  Count lines in server.js  ·  sonnet  ·  low
◯ general-purpose  Count lines in cart.test.js  ·  sonnet  ·  low

⏺ Agent "Count lines in cart.js  ·  sonnet  ·  low" finished · 5s

<img src="assets/badge-still.png" alt="The task list with each subagent labelled sonnet and low" width="900">

Surprise models, caught early

If a subagent asks for one model and its first request runs on another family, the badge raises a toast that names both. You can stop the run before it spends the wrong model's budget. A newer version of the same family, like claude-haiku-5-5 for an agent that asked for haiku, counts as a match and stays quiet.

Background agents and workflows

Agents sent to the background get their label in the task list too. The badge never posts under a call that has already closed, so it adds no error lines to your transcript. Agents a workflow starts aren't labelled, because they don't come from an Agent call the badge can see.

What it reads, writes and sends

Nothing leaves your machine. The badge keeps its labels in memory for the session only, writes no files, changes no settings, runs no programs or commands, and makes no network requests. The full privacy policy says the same in one place.

What each hook does:

  • tool.call on Agent: changes one input. It appends · <model> · <effort> to the call's description, the short task name shown in the task list, and changes nothing else. It returns the tool's own result unchanged.
  • turn.step: reads the model and effort of each request. On a subagent's first request it looks the agent up in Claude Code's own agent list to find the Agent call that started it, then raises the mismatch toast if the model family differs. It passes every request on unchanged.
  • ui.render on ToolUse: draws the Agent row exactly as Claude Code does, with the model and effort beside it. Rows of other tools are left alone.

It never changes how an agent is started: the model, prompt, tools and permissions are always the ones Claude asked for.

Where it runs

Claude Code in the terminal only, version 2.1.292 or later. The desktop app, VS Code, claude.ai chat and Cowork aren't supported.

Source 1 files
hooks/register.ts 169 lines
1import type { EngineInterface, Register, RenderElement } from 'claude-code'
2
3type Badge = {
4  toolUseId: string
5  model: string
6  effort?: string
7}
8
9const SHORT: Record<string, string> = {
10  'claude-fable-5-1': 'fable',
11  'claude-opus-5-5': 'opus',
12  'claude-sonnet-5-5': 'sonnet',
13  'claude-haiku-4-5-20251001': 'haiku',
14}
15
16// agentId → badge; module state resets on reload, which is fine for a live view.
17const byAgent = new Map<string, Badge>()
18
19// The family name, so a new version of a model (claude-haiku-5-5) still reads as the haiku that was asked for.
20const shortModel = (id: string): string =>
21  SHORT[id] ?? /^claude-([a-z]+)/.exec(id)?.[1] ?? id
22
23// One colour per effort level, from the engine's theme keys; the same ones the dock's effort chips use.
24const EFFORT_COLOR: Record<string, 'success' | 'ide' | 'warning' | 'claude' | 'error'> = {
25  low: 'success',
26  medium: 'ide',
27  high: 'warning',
28  xhigh: 'claude',
29  max: 'error',
30}
31
32// A wide middle dot keeps the label clear of the description: "Count lines  ·  sonnet  ·  low". The engine folds
33// any run of whitespace in a task's description, so each side pairs a space with a braille blank (U+2800),
34// which draws as an empty cell but is not whitespace.
35const SEP = ' \u2800·\u2800 '
36const badgeText = (b: Badge): string =>
37  `${shortModel(b.model)}${b.effort ? `${SEP}${b.effort}` : ''}`
38
39// The effort each model family last ran at here, for a spawn whose call names none.
40const effortByFamily = new Map<string, string>()
41
42function refreshNotice($: EngineInterface, toolUseId: string): void {
43  if (!openCalls.has(toolUseId)) return
44  const row = [...byAgent.values()].find(b => b.toolUseId === toolUseId)
45  if (!row) return
46  try {
47    $.ui.notice(toolUseId, `model: ${badgeText(row)}`)
48  } catch {
49    // the call may already be closed (a resumed workflow run); nothing to draw under
50  }
51}
52
53// What each Agent call asked for, by tool_use_id, and which call each labelled description came from: the
54// engine lists a running agent by its description, which is how a subagent's first request finds its call.
55const requested = new Map<string, { model?: string; effort?: string }>()
56// Calls still waiting for their agent, by description, oldest first: two calls with one description take turns.
57const callsByDescription = new Map<string, string[]>()
58// The engine lists a description with every run of whitespace folded to one space, so the queues are keyed by that.
59const slotOf = (description: string): string => description.replace(/\s+/g, ' ').trim()
60// Lookups an agent has failed so far. The engine can list an agent a moment after its first request, so a miss
61// is retried on the next request and given up after a few.
62const misses = new Map<string, number>()
63const MAX_MISSES = 3
64// Agent calls still running. A notice can only sit under an open call: a background agent's call returns at
65// once, and a notice sent after that is dropped with a line in the transcript.
66const openCalls = new Set<string>()
67
68// A subagent's first request: find the Agent call that started it and give its row a badge.
69async function adopt($: EngineInterface, agentId: string, model: string, effort: string | undefined): Promise<void> {
70  if ((misses.get(agentId) ?? 0) >= MAX_MISSES) return
71  const info = (await $.agent.list()).find(a => a.id === agentId)
72  const toolUseId = info ? callsByDescription.get(slotOf(info.description))?.shift() : undefined
73  const ask = toolUseId ? requested.get(toolUseId) : undefined
74  if (!info || !toolUseId || !ask) {
75    misses.set(agentId, (misses.get(agentId) ?? 0) + 1)
76    return
77  }
78  misses.delete(agentId)
79  const label = info.name ?? info.description.split(SEP)[0] ?? info.type
80  byAgent.set(agentId, {
81    toolUseId,
82    model,
83    effort: effort ?? ask.effort ?? effortByFamily.get(shortModel(model)),
84  })
85  if (ask.model && shortModel(model) !== ask.model) {
86    $.ui.toast(`${label}: asked for ${ask.model}, running on ${shortModel(model)}`)
87  }
88  refreshNotice($, toolUseId)
89  $.ui.invalidate('ui.render')
90}
91
92export const register: Register = on => {
93  // The tasks list above the prompt draws the call's description, so the label rides in it: the model the
94  // call names, else the session's own, and the effort the call names, else the one that model last ran at.
95  on('tool.call', { tool: 'Agent' }, async ($, e, next) => {
96    const id = e.tool_use_id
97    if (!id || !e.description) return next(e)
98    // A fork inherits its parent's model and effort, whatever the call names.
99    const named: { model?: string; effort?: string } = e.subagent_type === 'fork' ? {} : { model: e.model, effort: e.effort }
100    const parentModel = e.agentId ? byAgent.get(e.agentId)?.model : undefined
101    const asked = named.model ?? shortModel(parentModel ?? (await $.session.model()))
102    const effort = named.effort ?? effortByFamily.get(shortModel(asked))
103    const input = { ...e, description: `${e.description}${SEP}${asked}${effort ? `${SEP}${effort}` : ''}` }
104    const slot = slotOf(input.description)
105    requested.set(id, named)
106    const queue = callsByDescription.get(slot) ?? []
107    queue.push(id)
108    callsByDescription.set(slot, queue)
109    openCalls.add(id)
110    let done: { deny?: string; isError?: boolean; result?: unknown } | undefined
111    try {
112      const out = await next(input)
113      done = out
114      return out
115    } finally {
116      openCalls.delete(id)
117      // A call that started no agent must not keep its place in the queue; a background launch keeps it for its agent.
118      if (!done || done.deny !== undefined || done.isError || (done.result as { status?: string } | null | undefined)?.status === 'completed') {
119        const waiting = callsByDescription.get(slot)
120        const at = waiting?.indexOf(id) ?? -1
121        if (at >= 0) waiting?.splice(at, 1)
122        requested.delete(id)
123      }
124    }
125  })
126
127  on('turn.step', async function* ($, e, next) {
128    if (e.effort !== undefined) effortByFamily.set(shortModel(e.model), String(e.effort))
129    // A request that reports no effort keeps the one already shown: only a reported level changes it.
130    const effort = e.effort === undefined ? undefined : String(e.effort)
131    if (e.agentId) {
132      const badge = byAgent.get(e.agentId)
133      if (!badge) {
134        try {
135          await adopt($, e.agentId, e.model, effort)
136        } catch {
137          // the agent list is a lookup; the request goes on regardless
138        }
139      } else {
140        const shownEffort = effort ?? badge.effort
141        if (badge.model !== e.model || badge.effort !== shownEffort) {
142          badge.model = e.model
143          badge.effort = shownEffort
144          refreshNotice($, badge.toolUseId)
145          $.ui.invalidate('ui.render')
146        }
147      }
148    }
149    return yield* next(e)
150  })
151
152  // The Agent tool's transcript row: the engine's own drawing, then the badge beside it,
153  // the model in white and the effort in its level's colour.
154  on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
155    if (e.component !== 'ToolUse' || e.props.tool !== 'Agent') return next(e)
156    const badge = [...byAgent.values()].find(b => b.toolUseId === e.props.tool_use_id)
157    if (!badge) return next(e)
158    const { Box, Text } = $.ui.resolve(e)
159    const theirs = await next(e)
160    return h(
161      Box,
162      { flexDirection: 'row', columnGap: 1 },
163      theirs ?? '',
164      h(Text, { bold: true, color: 'text' }, shortModel(badge.model)),
165      badge.effort ? h(Text, { bold: true, color: EFFORT_COLOR[badge.effort] ?? 'text' }, badge.effort) : null,
166    ) as RenderElement
167  })
168}
169