{"record":{"id":"15173329ed082942","repo":"sipeed/picoclaw","slug":"subturn-panicked-v","errorCode":null,"errorMessage":"subturn panicked: %v","messagePattern":"subturn panicked: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/agent/subturn.go","lineNumber":458,"sourceCode":"\tparentTS.mu.Lock()\n\tparentTS.childTurnIDs = append(parentTS.childTurnIDs, childID)\n\tparentTS.mu.Unlock()\n\n\t// 6. Emit Spawn event\n\tal.emitEvent(runtimeevents.KindAgentSubTurnSpawn,\n\t\tchildTS.eventMeta(\"spawnSubTurn\", \"subturn.spawn\"),\n\t\tSubTurnSpawnPayload{\n\t\t\tAgentID:      childTS.agentID,\n\t\t\tLabel:        childID,\n\t\t\tParentTurnID: parentTS.turnID,\n\t\t},\n\t)\n\n\t// 7. Defer cleanup: deliver result (for async), emit End event, and recover from panics\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogger.RecoverPanicNoExit(r)\n\t\t\terr = fmt.Errorf(\"subturn panicked: %v\", r)\n\t\t\tresult = nil\n\t\t\tlogger.ErrorCF(\"subturn\", \"SubTurn panicked\", map[string]any{\n\t\t\t\t\"child_id\":  childID,\n\t\t\t\t\"parent_id\": parentTS.turnID,\n\t\t\t\t\"panic\":     r,\n\t\t\t})\n\t\t}\n\n\t\t// Result Delivery Strategy (Async vs Sync)\n\t\tif cfg.Async {\n\t\t\tdeliverSubTurnResult(al, parentTS, childID, result)\n\t\t}\n\n\t\tstatus := \"completed\"\n\t\tif err != nil {\n\t\t\tstatus = \"error\"\n\t\t}\n\t\tal.emitEvent(runtimeevents.KindAgentSubTurnEnd,","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/agent/subturn.go#L440-L476","documentation":"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.","triggerScenarios":"Thrown at pkg/agent/subturn.go:458 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}