From be6cf4510bd3686b036f56f409d0dc923c50a448 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sat, 20 Jun 2026 09:57:05 +0800 Subject: [PATCH] test(tool-bash): make the notice fake's agentId differ from its session token (Codex review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex flagged (C) a test-sufficiency gap: the completion-notice fake had `agent.id === session.header.id`, so the notice test could not distinguish the code matching on the registry KEY (agentId) from matching on the session TOKEN (session.header.id). The production code deliberately matches on `session.header.id` because a config agent has `agentId !== sessionId` — but a same-value fake passes either way (the "hits the line but not the scenario" trap). Give the registered fake a distinct agentId (`agent-`). Verified the notice test now FAILS if the match is regressed to `a.id` and passes on `a.session.header.id` — so it actually pins the discriminating behavior. --- packages/tool-bash/tests/tools.spec.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/tool-bash/tests/tools.spec.ts b/packages/tool-bash/tests/tools.spec.ts index 53e3448b13..e94cf108a9 100644 --- a/packages/tool-bash/tests/tools.spec.ts +++ b/packages/tool-bash/tests/tools.spec.ts @@ -37,7 +37,13 @@ async function setup() { */ const fakeAgentDisposers = new Map void)[]>() function registerFakeAgent(ctx: Context, sessionId: string, inject: (...args: unknown[]) => void): Agent { - const agent = { id: sessionId, inject, session: { header: { version: 1, id: sessionId, createdAt: 0 } } } as unknown as Agent + // The registry KEY (agent.id) is deliberately DIFFERENT from the session + // token (session.header.id) — a config agent has `agentId !== sessionId`. The + // owner token IS the session id, so the notice path must find the agent by + // `session.header.id`, NOT the registry key. Using distinct values here makes + // the test fail if a regression matched on the wrong field (a same-value fake + // would pass either way — the "hits the line but not the scenario" trap). + const agent = { id: `agent-${sessionId}`, inject, session: { header: { version: 1, id: sessionId, createdAt: 0 } } } as unknown as Agent const dispose = ctx.agents.register(agent) const list = fakeAgentDisposers.get(ctx) ?? [] list.push(dispose)