{"record":{"id":"f65dac7201285542","repo":"micro/go-micro","slug":"remote-task-s-ended-in-state-q","errorCode":null,"errorMessage":"remote task %s ended in state %q","messagePattern":"remote task (.+?) ended in state %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gateway/a2a/client.go","lineNumber":75,"sourceCode":"\t}\n\treturn &card, nil\n}\n\n// Send sends a text message to the remote agent and returns its reply.\n// If the agent returns a task that isn't yet terminal, Send polls\n// tasks/get until it completes or ctx is done.\nfunc (c *Client) Send(ctx context.Context, text string) (string, error) {\n\ttask, err := c.SendMessage(ctx, Message{\n\t\tRole:      \"user\",\n\t\tKind:      \"message\",\n\t\tMessageID: uuid.New().String(),\n\t\tParts:     []Part{{Kind: \"text\", Text: text}},\n\t})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif task.Status.State != stateCompleted {\n\t\treturn \"\", fmt.Errorf(\"remote task %s ended in state %q\", task.ID, task.Status.State)\n\t}\n\treturn artifactsText(task.Artifacts), nil\n}\n\n// SendMessage sends an A2A message and returns the resulting terminal task.\n// To continue a multi-turn task, pass a Message with TaskID and ContextID set\n// to a prior task's id and context id.\nfunc (c *Client) SendMessage(ctx context.Context, message Message) (*Task, error) {\n\tif message.MessageID == \"\" {\n\t\tmessage.MessageID = uuid.New().String()\n\t}\n\tif message.Kind == \"\" {\n\t\tmessage.Kind = \"message\"\n\t}\n\tif message.Role == \"\" {\n\t\tmessage.Role = \"user\"\n\t}\n\tres, err := c.call(ctx, \"message/send\", sendParams{Message: message})","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/gateway/a2a/client.go#L57-L93","documentation":"Send submits an A2A message and polls the resulting remote task until it reaches a terminal state. The library throws this error when the task finished in a terminal state other than completed (e.g. failed, canceled, rejected), meaning no result text can be returned. The message includes the remote task ID and the actual state string so callers can correlate and diagnose.","triggerScenarios":"Calling SendMessage when the remote agent marks the task 'failed' due to a processing error, 'canceled' by the user or a timeout, or any custom terminal state the agent reports other than the library's stateCompleted value.","commonSituations":"The remote agent rejected the input (invalid parameters, unsupported capability); the task was canceled after a deadline; the agent-side model or tool call crashed mid-task; an operator canceled long-running work.","solutions":["Read the state value in the error; if 'failed', fetch task details or logs from the remote agent for the underlying cause.","Inspect the task status message/artifacts via the task ID to get agent-reported error details.","Retry the send if the failure was transient (upstream model/tool outage); implement idempotency keys if the agent supports them.","Handle 'canceled' explicitly in caller flow (surface to user rather than retrying)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"text, err := c.Send(ctx, msg)\nif err != nil {\n\tvar stateErr *taskStateError // or regex the state from the message\n\tif m := stateRe.FindStringSubmatch(err.Error()); m != nil {\n\t\tswitch m[2] {\n\t\tcase \"canceled\": return errCanceled\n\t\tcase \"failed\": return retryableOrNot(err)\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Parse the quoted state from the error before deciding to retry","Only retry 'failed' tasks with transient causes","Surface canceled state to users instead of auto-retrying","Correlate using the task ID included in the message","Set agent-side timeouts so tasks fail fast rather than hang"],"tags":["a2a","task-state","remote-agent"],"backgroundTag":"remote-task-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}