sipeed/picoclaw · error

hook requested turn abort

Error message

hook requested turn abort

What it means

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).

Solutions

  1. Inspect the triggering hook's own logging to learn why it aborted the turn
  2. Adjust the hook's condition (budget limits, content rules) if the abort is unwanted
  3. At the caller, treat this error as a clean abort: skip retry and report the reason
  4. Disable or reconfigure the offending hook for workflows that must not be vetoed
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/agent/turn_coord.go:216 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/b255403bbaa800ad. Report an issue: GitHub.

Appendix: source

Thrown at pkg/agent/turn_coord.go:216

			return turnResult{}, callErr
		}
		messages = exec.messages
		pendingMessages = exec.pendingMessages
		finalContent = exec.finalContent

		switch ctrl {
		case ControlContinue:
			continue
		case ControlBreak:
			// Hard abort: delegate to abortTurn (sets TurnEndStatusAborted)
			if exec.abortedByHardAbort {
				turnStatus = TurnEndStatusAborted
				return al.abortTurn(ts)
			}
			// Hook abort (HookActionAbortTurn): sets TurnEndStatusError, returns error
			if exec.abortedByHook {
				turnStatus = TurnEndStatusError
				return turnResult{}, fmt.Errorf("hook requested turn abort")
			}
			// Ensure empty response falls back to DefaultResponse
			if finalContent == "" {
				finalContent = ts.opts.DefaultResponse
			}
			result, finalizeErr := pipeline.Finalize(ctx, turnCtx, ts, exec, turnStatus, finalContent)
			if finalizeErr != nil {
				turnStatus = TurnEndStatusError
			}
			return result, finalizeErr
		case ControlToolLoop:
			// Execute tools via Pipeline
			toolCtrl := pipeline.ExecuteTools(ctx, turnCtx, ts, exec, iteration)
			switch toolCtrl {
			case ToolControlContinue:
				// Re-read exec.messages since ExecuteTools may have updated it
				// (added tool results/skipped messages) before returning ControlContinue
				messages = exec.messages

View on GitHub (pinned to 49183d7e8d)