Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A reply that hits the request's completion cap (
finish_reason="length"below the advertised context window) ends the prompt. In long agentic sessions, a reasoning model sometimes spends one whole turn reasoning until the per-call output cap. The session then ends on a reply that never acted, and all the work before it is lost.Behaviour change
cap_hit_nudge). It tells the model that its last reply hit the output token limit before it acted. It asks the model to act now (make its next tool call or give its final answer) without restating its reasoning. The loop continues.max_tokensor a tree budget is spent.New knob
max_cap_continuations(policy, default2,>= 0) sets how many consecutive cap hits the engine continues from.0gives the previous behaviour: the first cap hit ends the prompt. The knob is in the runtime contract table, in the ACP limits snapshot, and indocs/context.md.Tests
test_cap_hit_reply_is_kept_and_the_model_is_asked_to_act: the cut reply is kept without its tool call, the nudge follows, the cut tool call is not run, and the run continues to its answer.test_cap_hit_continuations_are_bounded_and_reset_by_a_normal_reply: a normal reply resets the count, and the hit past the limit ends the prompt with that reply as the answer.max_cap_continuations=0and still checks that the prompt ends.Test plan
uv run ruff check .anduv run ruff format --check .pass.uv run pytest tests/ --ignore=tests/e2e: 451 passed (tests/e2eneeds a live model). The new tests fail without the engine change.