claude-code - 💡(How to fix) Fix /goal Stop hook fails with "Prompt is too long" in long sessions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

In a long-running session, the /goal Stop hook (the session-scoped condition evaluator) fails hard with:

Stop hook error: Hook evaluator API error: Prompt is too long

Once this happens, the hook can no longer evaluate the goal condition, so it neither blocks-with-reason nor auto-clears — it just errors every time the agent tries to stop.

Error Message

Stop hook error: Hook evaluator API error: Prompt is too long

Root Cause

  • The goal feature becomes unusable in exactly the sessions where it's most useful (long, sustained work toward a condition).
  • The condition may already be satisfied, but because the evaluator can't run, the goal won't auto-clear and the user keeps hitting the error until they manually /goal clear.

Code Example

Stop hook error: Hook evaluator API error: Prompt is too long
RAW_BUFFERClick to expand / collapse

Summary

In a long-running session, the /goal Stop hook (the session-scoped condition evaluator) fails hard with:

Stop hook error: Hook evaluator API error: Prompt is too long

Once this happens, the hook can no longer evaluate the goal condition, so it neither blocks-with-reason nor auto-clears — it just errors every time the agent tries to stop.

Repro

  1. Start a session and let it grow large (long multi-hour conversation with lots of tool output).
  2. Set a goal: /goal <some condition>.
  3. Continue working until the transcript is large.
  4. When the agent attempts to stop, the Stop hook evaluator errors with Prompt is too long.

Expected

The goal evaluator should degrade gracefully instead of hard-erroring:

  • Truncate / summarize the transcript before sending to the evaluator, or use a larger-context model for the evaluation call, and/or
  • On evaluator failure, allow the stop to proceed (fail-open) rather than blocking with an error, and/or
  • Surface a clear, actionable message (e.g. "goal evaluation skipped: context too large; goal still active") and let the user /goal clear.

Impact

  • The goal feature becomes unusable in exactly the sessions where it's most useful (long, sustained work toward a condition).
  • The condition may already be satisfied, but because the evaluator can't run, the goal won't auto-clear and the user keeps hitting the error until they manually /goal clear.

Environment

  • Claude Code CLI
  • Long session (several hours, large transcript)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING