micro/go-micro · error
discover tools: %w
Error message
discover tools: %w
What it means
This error wraps any failure from agent.discoverTools() during the Stream path (agent/agent.go:272). discoverTools calls tools.Discover() on the configured tool source to enumerate the tool list for a run; if that discovery fails (registry unreachable, bad service config, backend error), the agent cannot proceed and the underlying error is surfaced with the 'discover tools:' prefix.
Source
Thrown at agent/agent.go:272
func (a *agentImpl) Ask(ctx context.Context, message string) (*Response, error) {
return a.ask(ctx, message, a.parentRunID)
}
// Stream sends a message and returns a streaming model response. Tool-calling
// agent runs still use Ask; Stream is for chat turns where immediate token
// delivery is more important than tool orchestration.
func (a *agentImpl) Stream(ctx context.Context, message string) (ai.Stream, error) {
a.mu.Lock()
defer a.mu.Unlock()
if err := ctx.Err(); err != nil {
return nil, err
}
if a.model == nil {
a.setup()
}
toolList, err := a.discoverTools()
if err != nil {
return nil, fmt.Errorf("discover tools: %w", err)
}
runID := uuid.New().String()
ctx = ai.WithRunInfo(ctx, ai.RunInfo{
RunID: runID,
ParentID: a.parentRunID,
Agent: a.opts.Name,
})
// Messages carries the history; Prompt carries the turn being answered.
// Providers build their payload as Messages followed by Prompt, so
// appending the current message here would send it to the model twice.
// Memory has not recorded this turn yet (that happens after the stream
// starts), so the copy is passed through untrimmed: a trailing user
// message equal to this one is real prior context, not a duplicate.
messages := append([]ai.Message(nil), a.mem.Messages()...)
stream, err := a.model.Stream(ctx, &ai.Request{
Prompt: message,
SystemPrompt: a.buildPrompt(),
Tools: toolList,View on GitHub (pinned to 24529f1404)
Solutions
- Inspect the wrapped error (%w) to find the underlying discovery failure
- Verify the tool registry/service addresses configured via agent Options are reachable (curl/ping the endpoint)
- Confirm the tool service is started and registered before calling Stream
- Re-check tool service credentials/auth and API version compatibility
- Retry after fixing; discovery is attempted per-run so no agent restart is needed
Example fix
// before
resp, err := agent.Stream(ctx, msg)
// ignore wrapped discovery cause
// after
resp, err := agent.Stream(ctx, msg)
if err != nil && strings.Contains(err.Error(), "discover tools") {
log.Printf("tool discovery failed: %v", errors.Unwrap(err))
// check tool service health before retrying
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: verify the tool source can be discovered
if h, ok := toolSource.(interface{ HealthCheck(context.Context) error }); ok {
if err := h.HealthCheck(ctx); err != nil {
return fmt.Errorf("tool service not ready: %w", err)
}
} Type guard
func isDiscoverToolsErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "discover tools:")
} Try / catch
resp, err := ag.Stream(ctx, msg)
if err != nil {
var base error
if strings.HasPrefix(err.Error(), "discover tools:") && errors.As(err, &base) {
return fmt.Errorf("tool discovery failed, check tool service: %w", base)
}
return err
} Prevention
- Health-check the tool registry before starting runs
- Pin and test tool service endpoints in configuration
- Alert on tool service liveness in the same deployment as the agent
- Retry transient discovery failures with backoff
When it happens
Trigger: Calling Stream (or the run-index commands built on it, e.g. printRunIndex) when a.tools.Discover() returns an error: the tool registry/service is down, a configured service fails to respond, or tool discovery returns a malformed result.
Common situations: Misconfigured tool service endpoints in agent Options, the tool registry microservice not running, network/auth failures reaching a remote tool provider, or a version mismatch where the tool service returns an incompatible response.
Related errors
- agent: StreamAsk unsupported by implementation
- agent: ResumeStreamAsk unsupported by implementation
- agent: ResumeStreamAsk requires a checkpoint
- agent: checkpointed run not found
- agent: checkpointed run is terminal with status
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/dc7c9a0add467fc5.
Report an issue: GitHub.