{"record":{"id":"8657b18958bb3b17","repo":"google-gemini/gemini-cli","slug":"agent-agentname-not-found","errorCode":null,"errorMessage":"Agent '${agentName}' not found.","messagePattern":"Agent '(.+?)' not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/a2a-client-manager.ts","lineNumber":206,"sourceCode":"    this.agentCards.clear();\n    debugLogger.debug('[A2AClientManager] Cache cleared.');\n  }\n\n  /**\n   * Sends a message to a loaded agent and returns a stream of responses.\n   * @param agentName The name of the agent to send the message to.\n   * @param message The message content.\n   * @param options Optional context and task IDs to maintain conversation state.\n   * @returns An async iterable of responses from the agent (Message or Task).\n   * @throws Error if the agent returns an error response.\n   */\n  async *sendMessageStream(\n    agentName: string,\n    message: string,\n    options?: { contextId?: string; taskId?: string; signal?: AbortSignal },\n  ): AsyncIterable<SendMessageResult> {\n    const client = this.clients.get(agentName);\n    if (!client) throw new Error(`Agent '${agentName}' not found.`);\n\n    const messageParams: MessageSendParams = {\n      message: {\n        kind: 'message',\n        role: 'user',\n        messageId: uuidv4(),\n        parts: [{ kind: 'text', text: message }],\n        contextId: options?.contextId,\n        taskId: options?.taskId,\n      },\n    };\n\n    try {\n      yield* client.sendMessageStream(messageParams, {\n        signal: options?.signal,\n      });\n    } catch (error: unknown) {\n      const prefix = `[A2AClientManager] sendMessageStream Error [${agentName}]`;","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/a2a-client-manager.ts#L188-L224","documentation":"Thrown by `sendMessageStream` when no client is registered under `agentName` in the `clients` map. The method is a generator; before delegating to the A2A client it looks up `clients.get(agentName)` and refuses to proceed on `undefined`, because there is no transport to stream over.","triggerScenarios":"Calling `sendMessageStream('reviewer', ...)` before `loadAgent('reviewer', ...)` has completed; using a name that was never loaded; a typo in the agent name; the agent was loaded under a different alias than the one being messaged.","commonSituations":"Skipping the loadAgent step in a bootstrap script; an orchestrator that dispatches by name from config but config and registration drift; race where sendMessageStream is invoked before the async loadAgent resolves; casing mismatch (`Reviewer` vs `reviewer`).","solutions":["Ensure `loadAgent(agentName, ...)` has resolved successfully before calling sendMessageStream with that name.","Check `manager.getAgentCard(agentName)` (or `getClient(agentName)`) is non-undefined before sending.","Verify the exact name spelling and casing against the name used at load time.","If loading is async, await it (or guard the send behind its completion) before dispatching messages."],"exampleFix":"// before\nawait manager.loadAgent('reviewer', { url });\nfor await (const r of manager.sendMessageStream('Reviewer', 'hi')) {} // casing typo\n\n// after\nfor await (const r of manager.sendMessageStream('reviewer', 'hi')) {}","handlingStrategy":"validation","validationCode":"function assertAgentLoadedForSend(manager: A2AClientManager, name: string) {\n  if (!manager.getClient(name)) {\n    throw new Error(`Agent '${name}' not loaded. Call loadAgent first.`);\n  }\n}\n\nassertAgentLoadedForSend(manager, 'reviewer');\nfor await (const r of manager.sendMessageStream('reviewer', msg)) {}\n","typeGuard":"function isAgentReadyToSend(manager: { getClient(n: string): unknown }, name: string): boolean {\n  return manager.getClient(name) !== undefined;\n}","tryCatchPattern":"try {\n  for await (const r of manager.sendMessageStream(name, msg)) {}\n} catch (e) {\n  if (e instanceof Error && e.message.endsWith('not found.')) {\n    await manager.loadAgent(name, opts); // lazy load then retry once\n    return;\n  }\n  throw e;\n}","preventionTips":["Bootstrap all required agents in a single init step before serving requests.","Gate sendMessageStream on a getAgentCard/getClient check at the dispatcher.","Verify exact name casing against the registration alias."],"tags":["a2a","agent-loading","validation","naming"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}