{"record":{"id":"988ebb7f01535626","repo":"micro/go-micro","slug":"agent-run-s-paused-for-approval-s","errorCode":null,"errorMessage":"agent run %s paused for approval: %s","messagePattern":"agent run (.+?) paused for approval: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent/agent.go","lineNumber":473,"sourceCode":"\t\t\trun.Steps[0].ErrorKind = string(failureKind)\n\t\t\t_ = a.saveRun(ctx, run)\n\t\t\treturn nil, err\n\t\t}\n\t\tif a.pause != nil && a.opts.Checkpoint != nil {\n\t\t\trun.Status = \"paused\"\n\t\t\trun.State.Stage = agentApprovalStep\n\t\t\trun.State.Data = []byte(message)\n\t\t\tif a.pause.Tool == toolHumanInput {\n\t\t\t\trun.State.Stage = agentInputStep\n\t\t\t\t_ = run.State.Set(inputPause{OriginalMessage: message, Prompt: a.pause.Message})\n\t\t\t}\n\t\t\trun.Steps[0].Status = \"paused\"\n\t\t\trun.Steps[0].Error = a.pause.Message\n\t\t\trun.Steps[0].Result = a.pause.Tool\n\t\t\tif err := a.saveRun(ctx, run); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"agent run %s paused for approval: %s\", run.ID, a.pause.Message)\n\t\t}\n\n\t\tif len(resp.ToolCalls) == 0 {\n\t\t\tif calls, answer, ok := a.executeTextToolCalls(ctx, resp.Reply, toolList); ok {\n\t\t\t\tresp.ToolCalls = calls\n\t\t\t\tif resp.Answer == \"\" {\n\t\t\t\t\tresp.Answer = answer\n\t\t\t\t}\n\t\t\t\ttrimmedReply := strings.TrimSpace(resp.Reply)\n\t\t\t\tif strings.HasPrefix(trimmedReply, \"{\") || strings.HasPrefix(trimmedReply, \"[\") || strings.HasPrefix(trimmedReply, \"```\") {\n\t\t\t\t\tresp.Reply = \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t} else if calls, answer, ok := a.executeAdditionalTextToolCalls(ctx, resp.Reply, toolList, resp.ToolCalls); ok {\n\t\t\tresp.ToolCalls = append(resp.ToolCalls, calls...)\n\t\t\tif answer != \"\" {\n\t\t\t\tif resp.Answer == \"\" {\n\t\t\t\t\tresp.Answer = answer","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/agent/agent.go#L455-L491","documentation":"When a tool call requires human approval, the agent pauses the run (agent/agent.go:473), persists the run with status 'paused', and returns this error naming the run ID and the pause message. It signals that execution stopped awaiting an approval decision, not that the run failed permanently.","triggerScenarios":"A model tool call targets a tool guarded by the approval/pause policy during Ask/Stream; the agent saves the run as paused and returns this error to the caller.","commonSituations":"Workflows with human-in-the-loop approval on dangerous tools (writes, deployments); automated callers that treat every error as fatal instead of detecting the pause and resuming with an approval decision.","solutions":["Parse the run ID from the message and check the checkpointed run status == 'paused'","Use agent.Resume(ctx, ag, runID) with the recorded human input/approval to continue the run","Configure approval policies so expected approvals are pre-authorized if pauses are unwanted","Surface the pause message to a human approver rather than blindly retrying","Auto-retry is useless: the run only proceeds after approval input"],"exampleFix":"// before\nresp, err := ag.Ask(ctx, msg)\nif err != nil { return err } // treats pause as fatal\n// after\nresp, err := ag.Ask(ctx, msg)\nif err != nil && strings.Contains(err.Error(), \"paused for approval\") {\n    runID := extractRunID(err.Error())\n    resp, err = agent.Resume(ctx, ag, runID) // after approval is granted\n}\n","handlingStrategy":"validation","validationCode":"// before calling, check the run's checkpointed status\nrun, ok, _ := checkpoint.Load(ctx, runID)\nif ok && run.Status == \"paused\" {\n    // must resume with human input, not re-Ask\n}","typeGuard":null,"tryCatchPattern":"resp, err := ag.Ask(ctx, msg)\nif err != nil {\n    var pe PauseError\n    if strings.Contains(err.Error(), \"paused for approval\") {\n        runID := extractRunID(err.Error())\n        // notify approver, then: agent.Resume(ctx, ag, runID)\n        return handleApproval(runID, err)\n    }\n    return err\n}","preventionTips":["Always special-case approval-pause errors; never treat them as fatal","Pre-authorize trusted tools to reduce approval pauses","Build an approval UI/queue that feeds decisions back via Resume","Log run IDs from pause errors for later resumption"],"tags":["go","agent","human-in-the-loop","approval","pause"],"backgroundTag":"agent-run-paused-for-approval","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}