{"record":{"id":"0254c7820c2f50df","repo":"sipeed/picoclaw","slug":"no-default-agent-for-system-message","errorCode":null,"errorMessage":"no default agent for system message","messagePattern":"no default agent for system message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/agent/agent_message.go","lineNumber":292,"sourceCode":"\tif idx := strings.Index(content, \"Result:\\n\"); idx >= 0 {\n\t\tcontent = content[idx+8:] // Extract just the result part\n\t}\n\n\t// Skip internal channels - only log, don't send to user\n\tif constants.IsInternalChannel(originChannel) {\n\t\tlogger.InfoCF(\"agent\", \"Subagent completed (internal channel)\",\n\t\t\tmap[string]any{\n\t\t\t\t\"sender_id\":   msg.SenderID,\n\t\t\t\t\"content_len\": len(content),\n\t\t\t\t\"channel\":     originChannel,\n\t\t\t})\n\t\treturn \"\", nil\n\t}\n\n\t// Use default agent for system messages\n\tagent := al.GetRegistry().GetDefaultAgent()\n\tif agent == nil {\n\t\treturn \"\", fmt.Errorf(\"no default agent for system message\")\n\t}\n\n\t// Use the origin session for context\n\tsessionKey := session.BuildMainSessionKey(agent.ID)\n\tdispatch := DispatchRequest{\n\t\tSessionKey:  sessionKey,\n\t\tUserMessage: fmt.Sprintf(\"[System: %s] %s\", msg.SenderID, msg.Content),\n\t}\n\tif originChannel != \"\" || originChatID != \"\" {\n\t\tdispatch.InboundContext = &bus.InboundContext{\n\t\t\tChannel:  originChannel,\n\t\t\tChatID:   originChatID,\n\t\t\tChatType: \"direct\",\n\t\t\tSenderID: msg.SenderID,\n\t\t}\n\t}\n\n\treturn al.runAgentLoop(ctx, agent, processOptions{","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/agent/agent_message.go#L274-L310","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure at least one agent exists in config (agents.list) and check startup logs for agent construction failures","Verify provider credentials — agents cannot be built without a working provider/model","If system messages come from an integration, gate the publisher on the agent registry being non-empty","Retry delivery after fixing config; the message can be re-published once an agent exists"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if al.GetRegistry().GetDefaultAgent() == nil {\n    // do not publish system messages; park or drop them until an agent exists\n    log.Print(\"system message dropped: no default agent registered\")\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Publishers on the internal bus should check the registry before sending system messages","Alert on 'no default agent' errors — they indicate agent construction failed at startup","Keep at least one always-on agent in config for infra/system traffic"],"tags":["go","picoclaw","agents","registry","message-bus","system-messages"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}