sipeed/picoclaw · error

turn is still initializing for session

Error message

turn is still initializing for session %s

What it means

Initialization guard in the deprecated InterruptHard: getAnyActiveTurnState returned a turn, but its turnID still carries the 'pending-' prefix, meaning the turn was claimed but its real loop has not started — abort machinery (and a stable turn id) does not exist yet. The sessionKey in the message names the session whose turn is still spinning up.

Solutions

  1. Retry the abort after the turn finishes initializing
  2. Use HardAbort(sessionKey), which handles pending turns correctly
  3. Delay user-facing abort wiring until the turn reports as started
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/agent/steering.go:454 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/41b02e98cdef1ea5. Report an issue: GitHub.

Appendix: source

Thrown at pkg/agent/steering.go:454

			Kind:    InterruptKindGraceful,
			HintLen: len(hint),
		},
	)

	return nil
}

// InterruptHard aborts an arbitrary active turn. In parallel mode this may
// target the wrong session. Prefer HardAbort(sessionKey) instead.
//
// Deprecated: Use HardAbort(sessionKey) for session-safe aborts.
func (al *AgentLoop) InterruptHard() error {
	ts := al.getAnyActiveTurnState()
	if ts == nil {
		return fmt.Errorf("no active turn")
	}
	if strings.HasPrefix(ts.turnID, "pending-") {
		return fmt.Errorf("turn is still initializing for session %s", ts.sessionKey)
	}
	if !ts.requestHardAbort() {
		return fmt.Errorf("turn %s is already aborting", ts.turnID)
	}

	al.emitEvent(
		runtimeevents.KindAgentInterruptReceived,
		ts.eventMeta("InterruptHard", "turn.interrupt.received"),
		InterruptReceivedPayload{
			Kind: InterruptKindHard,
		},
	)

	return nil
}

// ====================== SubTurn Result Polling ======================

View on GitHub (pinned to 49183d7e8d)