sipeed/picoclaw · error

no default agent for system message

Error message

no default agent for system message

What it means

Internal (non-subagent) system messages arriving on the bus are handled by prepending them to the default agent's main session. Like the heartbeat path, this depends on GetDefaultAgent() being non-nil; when the AgentRegistry is empty there is no agent to deliver '[System: sender] content' to, and the handler returns this error.

Source

Thrown at pkg/agent/agent_message.go:292

	if idx := strings.Index(content, "Result:\n"); idx >= 0 {
		content = content[idx+8:] // Extract just the result part
	}

	// Skip internal channels - only log, don't send to user
	if constants.IsInternalChannel(originChannel) {
		logger.InfoCF("agent", "Subagent completed (internal channel)",
			map[string]any{
				"sender_id":   msg.SenderID,
				"content_len": len(content),
				"channel":     originChannel,
			})
		return "", nil
	}

	// Use default agent for system messages
	agent := al.GetRegistry().GetDefaultAgent()
	if agent == nil {
		return "", fmt.Errorf("no default agent for system message")
	}

	// Use the origin session for context
	sessionKey := session.BuildMainSessionKey(agent.ID)
	dispatch := DispatchRequest{
		SessionKey:  sessionKey,
		UserMessage: fmt.Sprintf("[System: %s] %s", msg.SenderID, msg.Content),
	}
	if originChannel != "" || originChatID != "" {
		dispatch.InboundContext = &bus.InboundContext{
			Channel:  originChannel,
			ChatID:   originChatID,
			ChatType: "direct",
			SenderID: msg.SenderID,
		}
	}

	return al.runAgentLoop(ctx, agent, processOptions{

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Ensure at least one agent exists in config (agents.list) and check startup logs for agent construction failures
  2. Verify provider credentials — agents cannot be built without a working provider/model
  3. If system messages come from an integration, gate the publisher on the agent registry being non-empty
  4. Retry delivery after fixing config; the message can be re-published once an agent exists
Defensive patterns

Strategy: validation

Validate before calling

if al.GetRegistry().GetDefaultAgent() == nil {
    // do not publish system messages; park or drop them until an agent exists
    log.Print("system message dropped: no default agent registered")
    return nil
}

Prevention

When it happens

Trigger: A system-sender message (e.g. scheduler, webhook, or internal component publishing to the bus) is processed while the registry has zero registered agents — empty agents.list or failed agent construction.

Common situations: Automation/webhook integrations publishing system messages to a picoclaw instance whose agents failed to load; running with a stripped-down config that omits agents; test harnesses sending bus messages without registering agents.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/0254c7820c2f50df. Report an issue: GitHub.