google-gemini/gemini-cli · error
A2AClient getTask Error [${agentName}]: Unexpected error: ${
Error message
A2AClient getTask Error [${agentName}]: Unexpected error: ${String(error)} What it means
Sibling of error 178 from the same getTask catch block, fired when the underlying throw is not an `Error` instance. The manager stringifies it and re-throws a prefixed Error so the operation context is preserved despite the non-standard throw shape.
Source
Thrown at packages/core/src/agents/a2a-client-manager.ts:268
}
/**
* Retrieves a task from an agent.
* @param agentName The name of the agent.
* @param taskId The ID of the task to retrieve.
* @returns The task details.
*/
async getTask(agentName: string, taskId: string): Promise<Task> {
const client = this.clients.get(agentName);
if (!client) throw new Error(`Agent '${agentName}' not found.`);
try {
return await client.getTask({ id: taskId });
} catch (error: unknown) {
const prefix = `A2AClient getTask Error [${agentName}]`;
if (error instanceof Error) {
throw new Error(`${prefix}: ${error.message}`, { cause: error });
}
throw new Error(`${prefix}: Unexpected error: ${String(error)}`);
}
}
/**
* Cancels a task on an agent.
* @param agentName The name of the agent.
* @param taskId The ID of the task to cancel.
* @returns The cancellation response.
*/
async cancelTask(agentName: string, taskId: string): Promise<Task> {
const client = this.clients.get(agentName);
if (!client) throw new Error(`Agent '${agentName}' not found.`);
try {
return await client.cancelTask({ id: taskId });
} catch (error: unknown) {
const prefix = `A2AClient cancelTask Error [${agentName}]`;
if (error instanceof Error) {
throw new Error(`${prefix}: ${error.message}`, { cause: error });View on GitHub (pinned to 5024443c72)
Solutions
- Inspect the stringified payload embedded in the message to recover the original signal.
- Wrap the A2A client (or fetch) so all rejections become Error instances before reaching getTask.
- If you own the client, always throw Error subclasses.
- Log the raw caught value alongside the wrapped message for forensic triage.
Example fix
// before — client rejects with a number
client.getTask = () => Promise.reject(404);
// after — wrap to Error
client.getTask = () => Promise.reject(new Error('404'));
// or, at the call site:
try { await manager.getTask('rev', id); }
catch (e) { /* e.message contains 'Unexpected error: 404' */ } Defensive patterns
Strategy: try-catch
Try / catch
try {
return await manager.getTask(name, taskId);
} catch (e) {
// message embeds String(originalError). Log and surface.
logger.error({ message: (e as Error).message });
// wrap your A2A client so future throws are Error instances.
} Prevention
- Wrap the A2A client so all rejections become Error instances before reaching getTask.
- Log the wrapped message verbatim — non-Error causes can't be inspected otherwise.
- Audit any transport shim for string/number throws during integration.
When it happens
Trigger: The A2A client or an injected transport throws a non-Error value (string, number, plain object) from `getTask`. This is the fallback branch when `error instanceof Error` is false.
Common situations: A third-party client that throws strings; a fetch shim that rejects with a Response or plain object; an interceptor that strips Error prototypes; legacy code paths that reject with status codes as numbers.
Related errors
- [A2AClientManager] sendMessageStream Error [${agentName}]: U
- A2AClient getTask Error [${agentName}]: ${error.message}
- [A2AClientManager] sendMessageStream Error [${agentName}]: $
- A2AClient cancelTask Error [${agentName}]: Unexpected error:
- Task ${taskId} is missing persisted state in metadata.
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/edef107b05e35975.
Report an issue: GitHub.