sipeed/picoclaw · error

no agent available for session

Error message

no agent available for session %q

What it means

Lookup guard in AgentLoop.Continue: steering messages were dequeued for the session and the turn-state claim is held, but agentForSession returned no AgentInstance for that sessionKey — the session has no registered agent (never started, or was cleaned up). The active-turn claim is deleted before returning so the session is not wedged.

Solutions

  1. Start/initialize a session (send a first message) before issuing Continue
  2. Ensure the session was not removed by cleanup while steering messages were pending
  3. Register the agent instance for the session key before enqueueing steering messages
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/agent/steering.go:406 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/35a0f8b9a766b5ef. Report an issue: GitHub.

Appendix: source

Thrown at pkg/agent/steering.go:406

	if err := al.ensureHooksInitialized(ctx); err != nil {
		al.activeTurnStates.Delete(sessionKey)
		return "", err
	}
	if err := al.ensureMCPInitialized(ctx); err != nil {
		al.activeTurnStates.Delete(sessionKey)
		return "", err
	}

	steeringMsgs := al.dequeueSteeringMessagesForScopeWithFallback(sessionKey)
	if len(steeringMsgs) == 0 {
		al.activeTurnStates.Delete(sessionKey)
		return "", nil
	}

	agent := al.agentForSession(sessionKey)
	if agent == nil {
		al.activeTurnStates.Delete(sessionKey)
		return "", fmt.Errorf("no agent available for session %q", sessionKey)
	}

	if tool, ok := agent.Tools.Get("message"); ok {
		if resetter, ok := tool.(interface{ ResetSentInRound(sessionKey string) }); ok {
			resetter.ResetSentInRound(sessionKey)
		}
	}

	var scope *session.SessionScope
	if metaStore, ok := agent.Sessions.(session.MetadataAwareSessionStore); ok {
		scope = metaStore.GetSessionScope(sessionKey)
	}

	return al.continueWithSteeringMessages(ctx, agent, sessionKey, channel, chatID, scope, steeringMsgs)
}

func (al *AgentLoop) InterruptGraceful(hint string) error {
	ts := al.getAnyActiveTurnState()

View on GitHub (pinned to 49183d7e8d)