{"record":{"id":"cb24ec80e15ead75","repo":"sipeed/picoclaw","slug":"no-active-turn-state-found-for-session-s","errorCode":null,"errorMessage":"no active turn state found for session %s","messagePattern":"no active turn state found for session (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/agent/steering.go","lineNumber":514,"sourceCode":"\t\tdefault:\n\t\t\treturn results\n\t\t}\n\t}\n}\n\n// ====================== Hard Abort ======================\n\n// HardAbort immediately cancels the running agent loop for the given session,\n// cascading the cancellation to all child SubTurns. This is a destructive operation\n// that terminates execution without waiting for graceful cleanup.\n//\n// Use this when the user explicitly requests immediate termination (e.g., \"stop now\", \"abort\").\n// For graceful interruption that allows the agent to finish the current tool and summarize,\n// use Steer() instead.\nfunc (al *AgentLoop) HardAbort(sessionKey string) error {\n\ttsInterface, ok := al.activeTurnStates.Load(sessionKey)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no active turn state found for session %s\", sessionKey)\n\t}\n\n\tts, ok := tsInterface.(*turnState)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid turn state type for session %s\", sessionKey)\n\t}\n\n\tif strings.HasPrefix(ts.turnID, \"pending-\") {\n\t\treturn fmt.Errorf(\"turn is still initializing for session %s\", sessionKey)\n\t}\n\n\tlogger.InfoCF(\"agent\", \"Hard abort triggered\", map[string]any{\n\t\t\"session_key\":            sessionKey,\n\t\t\"turn_id\":                ts.turnID,\n\t\t\"depth\":                  ts.depth,\n\t\t\"initial_history_length\": ts.initialHistoryLength,\n\t})\n","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/agent/steering.go#L496-L532","documentation":"Lookup guard in AgentLoop.HardAbort(sessionKey): no entry for the given sessionKey exists in the active-turn map, so there is no running loop to cancel. Either the session's turn already finished/was aborted, or it never started — the session-scoped variant fails fast rather than guessing like the deprecated InterruptHard.","triggerScenarios":"Thrown at pkg/agent/steering.go:514 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No-op if the turn is genuinely finished; treat 'nothing to abort' as success at the call site","Verify the sessionKey matches the one used to start the turn","If a turn should be running, check that it started and registered turn state"],"exampleFix":null,"handlingStrategy":"validation","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"}