{"record":{"id":"d1c5fa2f1728993d","repo":"micro/go-micro","slug":"agent-pending-unsupported-agent-implementation-t","errorCode":null,"errorMessage":"agent pending: unsupported agent implementation %T","messagePattern":"agent pending: unsupported agent implementation %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/agent.go","lineNumber":339,"sourceCode":"\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif chunk == nil || chunk.Reply == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif err := stream.Send(&pb.ChatResponse{Reply: chunk.Reply, Agent: a.opts.Name}); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n}\n\n// Pending returns checkpointed agent runs that have not completed. It mirrors\n// flow.Pending for startup recovery loops that drain durable agent work.\nfunc Pending(ctx context.Context, ag Agent) ([]flow.Run, error) {\n\ta, ok := ag.(*agentImpl)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"agent pending: unsupported agent implementation %T\", ag)\n\t}\n\treturn a.pending(ctx)\n}\n\n// ResumePending resumes every checkpointed agent run that has not completed\n// yet, in the same oldest-first order returned by Pending.\n//\n// It is a convenience for service startup and recovery loops: after recreating\n// an agent with the same checkpoint store, call ResumePending to drain the\n// durable backlog without listing and resuming each run manually. If any run\n// fails again, ResumePending stops and returns that run id with the error so\n// callers can log, alert, or retry later without hiding the failing run.\nfunc ResumePending(ctx context.Context, ag Agent) (string, error) {\n\ta, ok := ag.(*agentImpl)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"agent resume pending: unsupported agent implementation %T\", ag)\n\t}\n\truns, err := a.pending(ctx)","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/agent/agent.go#L321-L357","documentation":"agent.Pending (agent/agent.go:339) only supports the internal *agentImpl concrete type. If you pass any other implementation of the Agent interface (a custom wrapper, mock, or decorator), Pending refuses it with this error because it needs access to unexported checkpoint internals that only *agentImpl has.","triggerScenarios":"Calling agent.Pending(ctx, ag) where ag is an Agent interface value that is not the *agentImpl returned by the library's constructor — e.g. a wrapped/decorated agent, a test fake, or a proxy.","commonSituations":"Wrapping an agent in middleware/decorators for logging or tracing and then passing the wrapper to Pending; using a mock Agent in tests; mixing agents from different library versions where the concrete type differs.","solutions":["Pass the original un-wrapped agent instance returned by the library constructor to Pending","Keep a reference to the concrete agent before wrapping it, and call Pending on that reference","Add the pending capability to your wrapper by delegating internally to the concrete agent","If you own a custom implementation, use the library's agentImpl instead of a bespoke Agent type"],"exampleFix":"// before\nag := loggingWrapper{inner: agent.New(...)}\nruns, err := agent.Pending(ctx, ag) // unsupported implementation\n// after\nag := agent.New(...)\nruns, err := agent.Pending(ctx, ag) // pass the concrete *agentImpl\n","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isConcreteAgent(ag agent.Agent) bool {\n    _, ok := ag.(interface {\n        Agent\n        pending(context.Context) ([]flow.Run, error)\n    })\n    return ok\n}\n// or simply: _, ok := ag.(*agentImpl); use ok before calling Pending","tryCatchPattern":"runs, err := agent.Pending(ctx, ag)\nif err != nil && strings.Contains(err.Error(), \"unsupported agent implementation\") {\n    return fmt.Errorf(\"pass the concrete agent, not a wrapper: %w\", err)\n}","preventionTips":["Never pass wrapped/decorated agents to package-level Pending/Resume helpers","Store the concrete agent reference before applying decorators","Avoid custom Agent implementations unless you also implement pending support","Document that Pending requires the library's concrete agent type"],"tags":["go","agent","type-assertion","api-misuse"],"backgroundTag":"unsupported-implementation-type","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}