claude-code - 💡(How to fix) Fix [BUG] /goal stop hook "Prompt is too long" in long-conversation sessions even with 1M-context model enabled

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…

Error Message

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

Fix Action

Fix / Workaround

  1. Start a session using a 1M-context model (claude-opus-4-7 or equivalent).
  2. Set a short /goal, e.g.:
    /goal Complete the refactor and summarise results in plain language
  3. Run a long autonomous session — spawn multiple sub-agents, do extensive tool calls. The conversation naturally grows to several hundred thousand tokens.
  4. Wait for Claude to attempt to stop at a turn boundary.
  5. Observed: Hook evaluator API error: Prompt is too long — Stop is blocked indefinitely.
  6. Workaround: /goal clear — after clearing, Stop works normally.
  • Session involved ~9 parallel sub-agents dispatched sequentially over ~5 hours; conversation grew well past the evaluator's apparent 200k limit.
  • Workaround confirmed: /goal clear immediately restores normal Stop behaviour.
  • The evaluator seems to be a separate API call with its own (lower) context limit; it does not inherit the 1M window of the parent session. Surfacing the token count at the moment of failure (like #61759 does) would help confirm this hypothesis.
  • If the evaluator must remain limited to 200k, the correct behaviour would be to fall back to a summary of the conversation, or to skip evaluation and log a warning, rather than hard-blocking Stop.

Code Example

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

---

/goal Complete the refactor and summarise results in plain language
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

Related but distinct issues:

  • #58192 — goal text itself is long → evaluator prompt bloat
  • #61759 — conversation exceeds 200k with 1M context window disabled

This report covers the third, uncovered case: short goal text + 1M-context model enabled + long conversation → evaluator still hard-caps at 200k.


What's Wrong?

After a long multi-agent session (many sub-agent spawns, extensive tool calls), the /goal stop hook evaluator fails with Hook evaluator API error: Prompt is too long — even though:

  1. The goal text itself is short (a single Chinese sentence, ~30 tokens)
  2. The active model is claude-opus-4-7[1m] — a 1M-context model with the 1M window explicitly enabled

The evaluator appears to use a hard-coded 200 000-token limit that is independent of the session model's context window. Once the conversation grows past that limit (easy in a long autonomous session), every subsequent Stop event fails identically, and the session cannot exit cleanly.

This is a distinct failure mode from #58192 (where the goal text itself is the cause) and from #61759 (where 1M context is disabled). Here the root problem is that the evaluator does not scale with the active context window of the chosen model.


What Should Happen?

One of:

  • The stop hook evaluator should use the same context-window limit as the active session model (i.e., honour the 1M window when the session is running a 1M-context model).
  • Or, if the evaluator must run against a smaller model, it should compress / summarise the conversation before sending, rather than sending the raw full-length conversation.
  • At minimum, when the evaluator fails due to length, it should warn and skip (let the session exit) rather than blocking Stop entirely.

Error Messages/Logs

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

Steps to Reproduce

  1. Start a session using a 1M-context model (claude-opus-4-7 or equivalent).
  2. Set a short /goal, e.g.:
    /goal Complete the refactor and summarise results in plain language
  3. Run a long autonomous session — spawn multiple sub-agents, do extensive tool calls. The conversation naturally grows to several hundred thousand tokens.
  4. Wait for Claude to attempt to stop at a turn boundary.
  5. Observed: Hook evaluator API error: Prompt is too long — Stop is blocked indefinitely.
  6. Workaround: /goal clear — after clearing, Stop works normally.

Note: The bug is independent of the goal text length. A single-sentence goal triggers it once the conversation is sufficiently long. The failure recurs on every Stop attempt until the goal is cleared.


Claude Model

Opus (claude-opus-4-7[1m], 1M-context variant)


Is this a regression?

I don't know


Last Working Version

No response


Claude Code Version

2.1.150


Platform

Anthropic API


Operating System

macOS


Terminal/Shell

Terminal.app (macOS)


Additional Information

  • Session involved ~9 parallel sub-agents dispatched sequentially over ~5 hours; conversation grew well past the evaluator's apparent 200k limit.
  • Workaround confirmed: /goal clear immediately restores normal Stop behaviour.
  • The evaluator seems to be a separate API call with its own (lower) context limit; it does not inherit the 1M window of the parent session. Surfacing the token count at the moment of failure (like #61759 does) would help confirm this hypothesis.
  • If the evaluator must remain limited to 200k, the correct behaviour would be to fall back to a summary of the conversation, or to skip evaluation and log a warning, rather than hard-blocking Stop.

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

claude-code - 💡(How to fix) Fix [BUG] /goal stop hook "Prompt is too long" in long-conversation sessions even with 1M-context model enabled