sipeed/picoclaw · error

hook aborted turn during after_llm

Error message

hook aborted turn during after_llm: %s

What it means

Hook-policy error in askSideQuestion's after_llm phase: the model already answered the side question, but a post-response hook returned HookActionAbortTurn or HookActionHardAbort, so the (possibly modified) response is discarded and an error returned instead. The %s is the hook's Reason or the generic default — the answer existed but policy suppressed it.

Solutions

  1. Inspect the hook's reason to identify the vetoing rule
  2. If the answer was valid, adjust the post-LLM hook's conditions
  3. Callers should not retry — the same hook will likely discard the next answer too
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

Thrown at pkg/agent/turn_coord.go:613

				Source:      "askSideQuestion",
				TracePath:   "turn.llm.response",
				turnContext: cloneTurnContext(turnCtx),
			},
			Context:  cloneTurnContext(turnCtx),
			Model:    llmModel,
			Response: resp,
		})
		switch decision.normalizedAction() {
		case HookActionContinue, HookActionModify:
			if llmResp != nil && llmResp.Response != nil {
				resp = llmResp.Response
			}
		case HookActionAbortTurn, HookActionHardAbort:
			reason := decision.Reason
			if reason == "" {
				reason = "hook requested turn abort"
			}
			return "", fmt.Errorf("hook aborted turn during after_llm: %s", reason)
		}
	}
	if sideSuppressReasoning {
		resp.Reasoning = ""
		resp.ReasoningContent = ""
		resp.ReasoningDetails = nil
	}

	return sideQuestionResponseContent(resp), nil
}

func (al *AgentLoop) isolatedSideQuestionProvider(
	agent *AgentInstance,
	baseModelName string,
	candidate providers.FallbackCandidate,
) (providers.LLMProvider, string, *config.ModelConfig, func(), error) {
	if agent == nil {
		return nil, "", nil, func() {}, fmt.Errorf("isolatedSideQuestionProvider: no agent available for /btw")

View on GitHub (pinned to 49183d7e8d)