sipeed/picoclaw · error

askSideQuestion: no agent available for /btw

Error message

askSideQuestion: no agent available for /btw

What it means

Nil-guard in AgentLoop.askSideQuestion: the /btw side-question path was entered with a nil *AgentInstance — no agent instance is bound to the loop for this request, so there is no provider/session to ask the question against. A simple precondition check before the question is trimmed or validated.

Solutions

  1. Ensure the side question is asked within an agent session that has an initialized agent instance
  2. Check upstream wiring: agentForSession/session registry must return an instance before calling
  3. Fail fast in tests/mocks by injecting a non-nil agent
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/agent/turn_coord.go:366 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkg/agent/turn_coord.go:366

	cm, err := factory(al.cfg.Agents.Defaults.ContextManagerConfig, al)
	if err != nil {
		logger.WarnCF("agent", "Failed to create context manager, falling back to legacy", map[string]any{
			"name":  name,
			"error": err.Error(),
		})
		return &legacyContextManager{al: al}
	}
	return cm
}

func (al *AgentLoop) askSideQuestion(
	ctx context.Context,
	agent *AgentInstance,
	opts *processOptions,
	question string,
) (string, error) {
	if agent == nil {
		return "", fmt.Errorf("askSideQuestion: no agent available for /btw")
	}

	question = strings.TrimSpace(question)
	if question == "" {
		return "", fmt.Errorf("askSideQuestion: %w", fmt.Errorf("Usage: /btw <question>"))
	}

	if opts != nil {
		normalizeProcessOptionsInPlace(opts)
		resolved, err := resolveTurnProfileOptions(al.GetConfig(), *opts)
		if err != nil {
			return "", err
		}
		*opts = resolved
	}

	var media []string
	var channel, chatID, senderID, senderDisplayName string

View on GitHub (pinned to 49183d7e8d)