[BUG] /goal stop hook "Prompt is too long" in long-conversation sessions even with 1M-context model enabled

Resolved 💬 1 comment Opened May 26, 2026 by fdjkgh580 Closed Jun 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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
``

  1. Run a long autonomous session — spawn multiple sub-agents, do extensive tool calls. The conversation naturally grows to several hundred thousand tokens.
  2. Wait for Claude to attempt to stop at a turn boundary.
  3. Observed: Hook evaluator API error: Prompt is too long — Stop is blocked indefinitely.
  4. 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.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗