sipeed/picoclaw · error

channel manager not initialized

Error message

channel manager not initialized

What it means

The SwitchChannel runtime hook found al.channelManager == nil: the agent loop was built without a channel manager, so channel switching is impossible. This mirrors the cfg==nil guard style used elsewhere — a wiring/initialization defect rather than a user input problem.

Source

Thrown at pkg/agent/agent_command.go:269

			})
			return toolInfos, nil
		},
		GetEnabledChannels: func() []string {
			if al.channelManager == nil {
				return nil
			}
			return al.channelManager.GetEnabledChannels()
		},
		GetActiveTurn: func() any {
			info := al.GetActiveTurn()
			if info == nil {
				return nil
			}
			return info
		},
		SwitchChannel: func(value string) error {
			if al.channelManager == nil {
				return fmt.Errorf("channel manager not initialized")
			}
			if _, exists := al.channelManager.GetChannel(value); !exists && value != "cli" {
				return fmt.Errorf("channel '%s' not found or not enabled", value)
			}
			return nil
		},
	}
	rt.StopActiveTurn = func() (commands.StopResult, error) {
		if opts == nil {
			return commands.StopResult{}, fmt.Errorf("process options not available")
		}
		return al.stopActiveTurnForSession(opts.Dispatch.SessionKey)
	}
	if agent != nil && agent.ContextBuilder != nil {
		rt.ListSkillNames = agent.ContextBuilder.ListSkillNames
	}
	rt.ReloadConfig = func() error {
		if al.reloadFunc == nil {

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. If you embed the runtime, construct/inject the channel manager before exposing SwitchChannel
  2. Hide or disable the /channel command when no channels are wired
  3. File a bug if this occurs in the stock CLI — the command should not be reachable in that state
Defensive patterns

Strategy: type-guard

Validate before calling

if al.channelManager == nil { /* hide /channel command or warn at startup */ }

Type guard

func channelsReady(al *AgentLoop) bool { return al.channelManager != nil }

Try / catch

err := rt.SwitchChannel(name)
if err != nil && strings.Contains(err.Error(), "channel manager not initialized") {
    // wiring bug: do not retry; report and disable the channel command
}

Prevention

When it happens

Trigger: Calling /channel <name> in an embedded/test AgentLoop constructed without channel wiring; a headless integration that skipped channel setup; startup race where the command arrives before channel manager injection.

Common situations: Custom embeddings of pkg/agent that pass minimal options; unit tests exercising the command table directly; a code path that intentionally disables channels but still exposes the command.

Related errors


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