sipeed/picoclaw · error
subturn panicked
Error message
subturn panicked: %v
What it means
Panic-recovery wrap in spawnSubTurn's deferred cleanup: the spawned SubTurn goroutine panicked mid-execution; recover() captured the value, RecoverPanicNoExit logged it without killing the process, and this error converts the panic into a normal error return so the parent turn receives it. The result is nil'd and the deferred delivery/end-event path still runs.
Solutions
- Read the panic value and stack in the logs to find the crashing code path
- Guard the inputs that triggered the panic (nil agent, nil provider, malformed messages)
- Add tests covering the panicking sub-turn scenario
- Treat the sub-turn result as failed and let the parent decide to retry or continue
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pkg/agent/subturn.go:458 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/15173329ed082942.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/agent/subturn.go:458
parentTS.mu.Lock()
parentTS.childTurnIDs = append(parentTS.childTurnIDs, childID)
parentTS.mu.Unlock()
// 6. Emit Spawn event
al.emitEvent(runtimeevents.KindAgentSubTurnSpawn,
childTS.eventMeta("spawnSubTurn", "subturn.spawn"),
SubTurnSpawnPayload{
AgentID: childTS.agentID,
Label: childID,
ParentTurnID: parentTS.turnID,
},
)
// 7. Defer cleanup: deliver result (for async), emit End event, and recover from panics
defer func() {
if r := recover(); r != nil {
logger.RecoverPanicNoExit(r)
err = fmt.Errorf("subturn panicked: %v", r)
result = nil
logger.ErrorCF("subturn", "SubTurn panicked", map[string]any{
"child_id": childID,
"parent_id": parentTS.turnID,
"panic": r,
})
}
// Result Delivery Strategy (Async vs Sync)
if cfg.Async {
deliverSubTurnResult(al, parentTS, childID, result)
}
status := "completed"
if err != nil {
status = "error"
}
al.emitEvent(runtimeevents.KindAgentSubTurnEnd,View on GitHub (pinned to 49183d7e8d)