Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(cli): amp — sub-agents checked on a real pane, and a duplicate tool card

0xken15d618e34ff96a
diff --git a/cli/src/engines/amp/normalizer.spec.ts b/cli/src/engines/amp/normalizer.spec.ts
index 2904047a1..f7c790511 100644
--- a/cli/src/engines/amp/normalizer.spec.ts
+++ b/cli/src/engines/amp/normalizer.spec.ts
@@ -108,6 +108,16 @@ describe('amp tool names', () => {
expect(ampToolName('Task')).toBe('Task')
})
+ it("uses Amp's own display table for the tools a medium session does not advertise", () => {
+ // Read out of the binary (`todo_write` → "Update TODOs", `Task` → "Subagent", …), not inferred.
+ expect(ampToolName('run_terminal_command')).toBe('Bash')
+ expect(ampToolName('read_file')).toBe('Read')
+ expect(ampToolName('ripgrep')).toBe('Grep')
+ expect(ampToolName('edit_file')).toBe('Edit')
+ // The device matches this string literally to build its checklist — a near-miss shows no list at all.
+ expect(ampToolName('todo_write')).toBe('TodoWrite')
+ })
+
it('leaves an unmeasured tool title-cased rather than guessing at it', () => {
// `oracle` and `finder` are real Amp tools whose behaviour was never observed here. A wrong shared
// name would draw a confidently wrong card; a title-cased one is merely plain.
diff --git a/cli/src/engines/amp/normalizer.ts b/cli/src/engines/amp/normalizer.ts
index 302d63c8f..7b161a869 100644
--- a/cli/src/engines/amp/normalizer.ts
+++ b/cli/src/engines/amp/normalizer.ts
@@ -55,8 +55,28 @@ const TOOL_NAMES: Record<string, string> = {
apply_patch: 'Edit',
web_search: 'WebSearch',
read_web_page: 'WebFetch',
- // Amp's sub-agent tool already carries the shared name.
+ // Amp's sub-agent tool already carries the shared name — and its own display map confirms the meaning
+ // ("Task" → "Subagent"). MEASURED end to end: `Task` fires as an ordinary client tool whose RESULT is
+ // the child's answer, so the row opens on tool_start and closes on tool_end. Nothing here needs to emit
+ // `subagent_finished`, and no row is left holding `turn_ended` open the way muse's did.
Task: 'Task',
+ // The rest come from Amp's OWN display-name table, found in the binary — not from analogy with another
+ // engine. None appeared in the 33 tools a medium-mode session advertises, so they are either legacy or
+ // gated behind a mode or integration this machine has not seen. Mapping them costs nothing and closes
+ // the gap in advance; leaving them out would be the silent-blank-card failure all over again.
+ run_terminal_command: 'Bash',
+ read_file: 'Read',
+ ripgrep: 'Grep',
+ Glob: 'Glob',
+ write_file: 'Write',
+ create_file: 'Write',
+ edit_file: 'Edit',
+ // Amp calls these "Read TODOs"/"Update TODOs". `todo_write` MUST land on exactly `TodoWrite`: the
+ // device builds its checklist by matching that string literally. Amp does not expose the tool today —
+ // asked for a todo list, it wrote a numbered list in PROSE and used no tool at all (measured on a real
+ // pane) — so the checklist stays empty by absence, not by a mis-mapping.
+ todo_write: 'TodoWrite',
+ todo_read: 'TodoRead',
}
export function ampToolName(name: string): string {
diff --git a/cli/src/lib/hooks.ts b/cli/src/lib/hooks.ts
index f7ca7e1bb..a0bcf86fe 100644
--- a/cli/src/lib/hooks.ts
+++ b/cli/src/lib/hooks.ts
@@ -731,12 +731,16 @@ export default function (amp: any) {
amp.on('tool.call', async (event: any, ctx: any) => {
await register(event.thread.id)
- await drain(ctx)
+ // CLAIM THE ID FIRST. \`drain\` runs before this card so a message's prose lands ahead of the tool it
+ // called — but by then the tool_use block for THIS tool is already in the thread, so draining without
+ // claiming wrote the card twice (measured: one Task turn produced two identical \`skill\` cards).
toolCalls.add(String(event.toolUseID))
+ await drain(ctx)
line({ t: 'tool_call', id: event.toolUseID, tool: event.tool, input: event.input })
})
amp.on('tool.result', async (event: any, ctx: any) => {
+ // Same rule as tool.call: claim before draining.
toolResults.add(String(event.toolUseID))
line({
t: 'tool_result',