{"record":{"id":"b255403bbaa800ad","repo":"sipeed/picoclaw","slug":"hook-requested-turn-abort","errorCode":null,"errorMessage":"hook requested turn abort","messagePattern":"hook requested turn abort","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/agent/turn_coord.go","lineNumber":216,"sourceCode":"\t\t\treturn turnResult{}, callErr\n\t\t}\n\t\tmessages = exec.messages\n\t\tpendingMessages = exec.pendingMessages\n\t\tfinalContent = exec.finalContent\n\n\t\tswitch ctrl {\n\t\tcase ControlContinue:\n\t\t\tcontinue\n\t\tcase ControlBreak:\n\t\t\t// Hard abort: delegate to abortTurn (sets TurnEndStatusAborted)\n\t\t\tif exec.abortedByHardAbort {\n\t\t\t\tturnStatus = TurnEndStatusAborted\n\t\t\t\treturn al.abortTurn(ts)\n\t\t\t}\n\t\t\t// Hook abort (HookActionAbortTurn): sets TurnEndStatusError, returns error\n\t\t\tif exec.abortedByHook {\n\t\t\t\tturnStatus = TurnEndStatusError\n\t\t\t\treturn turnResult{}, fmt.Errorf(\"hook requested turn abort\")\n\t\t\t}\n\t\t\t// Ensure empty response falls back to DefaultResponse\n\t\t\tif finalContent == \"\" {\n\t\t\t\tfinalContent = ts.opts.DefaultResponse\n\t\t\t}\n\t\t\tresult, finalizeErr := pipeline.Finalize(ctx, turnCtx, ts, exec, turnStatus, finalContent)\n\t\t\tif finalizeErr != nil {\n\t\t\t\tturnStatus = TurnEndStatusError\n\t\t\t}\n\t\t\treturn result, finalizeErr\n\t\tcase ControlToolLoop:\n\t\t\t// Execute tools via Pipeline\n\t\t\ttoolCtrl := pipeline.ExecuteTools(ctx, turnCtx, ts, exec, iteration)\n\t\t\tswitch toolCtrl {\n\t\t\tcase ToolControlContinue:\n\t\t\t\t// Re-read exec.messages since ExecuteTools may have updated it\n\t\t\t\t// (added tool results/skipped messages) before returning ControlContinue\n\t\t\t\tmessages = exec.messages","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/agent/turn_coord.go#L198-L234","documentation":"Hook-policy error in runTurn's control switch: a before/after hook returned HookActionAbortTurn, and the loop's exec path flagged abortedByHook, so the turn is terminated with TurnEndStatusError and this error propagated to the caller. It is intentional abort-by-policy, not an infrastructure failure — the hook deliberately vetoed the turn (e.g. guardrail or budget rule).","triggerScenarios":"Thrown at pkg/agent/turn_coord.go:216 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the triggering hook's own logging to learn why it aborted the turn","Adjust the hook's condition (budget limits, content rules) if the abort is unwanted","At the caller, treat this error as a clean abort: skip retry and report the reason","Disable or reconfigure the offending hook for workflows that must not be vetoed"],"exampleFix":null,"handlingStrategy":"try-catch","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"}