Skip to content

fix(runtime): stop resending an empty truncated turn; raise the cap once, then fail with the cause (RR8.1) - #198

Merged
lg2m merged 5 commits into
mainfrom
fix/eng-953-rr8-empty-truncation
Sep 28, 2026
Merged

lg2m merged 5 commits into
mainfrom
fix/eng-953-rr8-empty-truncation

Conversation

@lg2m

@lg2m lg2m commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

RR8.1: an empty truncated turn is a budget failure, not a continuation

Spec: docs/plans/run-reliability.md (RR8) Linear: ENG-953 Stack: 1/4

What changed

  • A turn cut at the output limit with nothing visible streamed (no text, refusal, or completed call: the cap went to hidden reasoning) is no longer continued with OUTPUT_TRUNCATED_CONTINUE_NOTICE. There is nothing to continue and the resend was byte-identical.
  • Instead the loop doubles the request's max_output_tokens toward the resolved model's ceiling once (MAX_EMPTY_OUTPUT_RETRIES = 1). If the cap is already at the ceiling, or the retry is empty again, the run settles provider_output_truncated at once with a message naming the cause (reasoning) and both remedies (max_output_tokens, reasoning_effort). Previously: 4 identical ~220 s turns, then a generic failure.
  • The in-run summarizer fails its step the same way instead of continuing an empty reply.
  • Visible-content truncations continue exactly as before.

How verified

  • an_empty_truncated_turn_raises_the_cap_once_then_completes (caps 256 → 512, one request each, no continuation notice appended)
  • an_empty_truncated_turn_at_the_ceiling_fails_at_once_naming_the_cause (1 provider call, not 4)
  • Existing truncated_turns_are_committed_and_continued_within_the_cap / truncation_past_the_cap_settles_with_a_typed_failure unchanged.

Docs

  • docs/design/architecture.md § output truncation.

Compatibility

  • No protocol, descriptor, or schema change. RuntimeEvent::OutputTruncated is reused for the cap-raise (1-based like every other continuation).

Evidence

Operator store, read-only: two provider_output_truncated runs on litellm/us.anthropic.claude-fable-5-1 (2026-09-23, 2026-09-25). Every failing turn persisted assistant_content_json = [] with output_tokens = 16384; every continuation request had input_tokens = 2 uncached (byte-identical resend). Route-wide since 09-10: 3 935 turns, 49 truncated, 31 empty, ≈ 671 k output tokens and ≈ 2 h wall producing nothing.

Review round (Codex)

  • Fixed: IncompleteReason was discarded, so an Anthropic pause_turn with no text hit the empty-retry branch and failed at the model ceiling instead of resuming (CI-confirmed). Only OutputTokens takes the empty-retry path now, in the run loop and the summarizer.
  • Fixed: the cap-raise retry emitted continuation: 0; the field is 1-based and the client rendered continuing (0/3).
  • Fixed (round 2): a turn that streamed a complete tool call and then hit the cap with no text was classified as all-reasoning (cleanup drops pending calls before the check); it is continued like any truncation. Test: a_truncated_turn_that_streamed_a_tool_call_is_continued_not_failed.
  • Fixed (round 2): an empty truncated turn is persisted as truncated but the live run sent neither it nor a notice; replay appended both. Replay now skips it. Test: an_empty_truncated_turn_replays_without_the_continuation_notice.
  • Fixed (round 3): after three visible truncations an empty one raised the cap past the shared continuation cap (continuation: 4, a fifth turn); it now settles. Test: an_empty_truncation_after_the_continuation_cap_does_not_spend_another_turn.
  • Fixed (round 3): the summarizer's empty check trims like has_content.
  • Declined (round 2): clamping the compaction cap-raise to the remaining window (the summarizer input is selected against an 8 192 reserve; overflow needs a transcript already at the edge).
  • Declined: recording the raised cap in the run's ResolvedModel (per-turn Prepared.weight already records the effective cap); summarizer usage on the new empty-failure path (pre-existing on the sibling path); gating the retry on output_token_control (one bounded extra turn on Codex, which never hits this shape).

Gates (run on the stack tip and on this branch's tip)

  • cargo fmt --all -- --check ✅
  • cargo clippy --workspace --all-targets --all-features -- -D warnings ✅ (every branch tip)
  • cargo test --workspace ✅ all passing at the stack tip; each intermediate tip compiles and passes qq/qq-core/qq-provider on its own.
  • cargo test -p qq-provider --no-default-features --features test-support ✅ 184 passed.
  • wasm32 qq-client build ✅

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T05:18:25.625758Z 4b22028 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lg2m
lg2m added this pull request to stack #202 September 26, 2026 06:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 639bc21044

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04f4476a34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved
…nce, then fail with the cause (RR8.1)

A turn cut at the output limit with nothing visible streamed (the whole cap
spent on hidden reasoning) was continued up to MAX_OUTPUT_CONTINUATIONS
times with a byte-identical request: four 16 384-token turns and ~15 min per
audited run producing nothing. An empty truncation now doubles the request
cap toward the model ceiling once (MAX_EMPTY_OUTPUT_RETRIES) and otherwise
settles provider_output_truncated at once, naming reasoning as the cause and
max_output_tokens / reasoning_effort as the remedies. The summarizer fails
its step the same way instead of continuing an empty reply.

Regressions: an_empty_truncated_turn_raises_the_cap_once_then_completes,
an_empty_truncated_turn_at_the_ceiling_fails_at_once_naming_the_cause.

Linear: ENG-953
…ntinuation from one (RR8.1 review)

The empty-truncation branch discarded IncompleteReason, so an Anthropic
pause_turn that arrived before any visible text was treated as output-token
exhaustion and failed at the model ceiling instead of being resent as the
provider requires (broke a_paused_turn_with_no_text_resumes_from_the_original_prompt).
The run loop and the summarizer now take the empty-retry path only for
OutputTokens; Paused resumes as before.

The cap-raise retry also emitted `continuation: 0`; the field is 1-based and
the client rendered "continuing (0/3)". It now increments the shared counter.

Linear: ENG-953
… truncated turn as nothing (RR8.1 review 2)

Truncation cleanup drops pending calls before the empty-turn check, so a turn
that streamed a complete tool call and then hit the cap with no text was
classified as all-reasoning and, at the model ceiling, failed the run instead
of being continued. The check now remembers whether a call was streamed.

An empty truncated turn is persisted as truncated but the live run neither
appended it nor sent a continuation notice. Context assembly appended both on
replay, telling the model to continue nothing. Replay now skips an empty
truncated turn, matching the request the model saw.

Tests: a_truncated_turn_that_streamed_a_tool_call_is_continued_not_failed,
an_empty_truncated_turn_replays_without_the_continuation_notice.

Linear: ENG-953
@lg2m
lg2m force-pushed the fix/eng-953-rr8-empty-truncation branch from 04f4476 to 7866a1c Compare September 26, 2026 19:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7866a1cc50

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/lib.rs Resolved
Comment thread crates/qq-core/src/lib.rs Resolved
…ation cap (RR8.1 review 3)

After three visible truncations, an empty one entered the cap-raise branch,
incremented the continuation counter past MAX_OUTPUT_CONTINUATIONS (the client
renders it against the advertised cap) and spent a fifth provider turn. The
branch now settles with the ordinary cap failure once the shared cap is spent.
Regression: an_empty_truncation_after_the_continuation_cap_does_not_spend_another_turn
(5 turns → 4, no `continuation: 4`).

The summarizer's empty check trims like `Message::has_content` does, so a
whitespace-only reply is not continued three times.

Linear: ENG-953

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d6bf4c677

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/lib.rs Resolved
…truncation (RR8.1 review 4)

The visible-output check counted any pending call, including one cut
mid-arguments that is dropped from the resend; such a turn was continued at
the same cap up to three times instead of taking the empty-turn path. Only a
call that finished streaming counts. Test:
a_tool_call_cut_mid_arguments_with_no_text_is_an_empty_truncation.

Linear: ENG-953
@lg2m
lg2m merged commit 0c29425 into main Sep 28, 2026
3 of 4 checks passed
@lg2m
lg2m deleted the fix/eng-953-rr8-empty-truncation branch September 28, 2026 05:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b220280cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +704 to +705
turn cut at the output limit with nothing visible streamed (no text, refusal,
or tool call: the whole cap went to hidden reasoning) is not continued, because

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Describe only completed calls as visible output

This design text says that any “tool call” prevents a truncation from being empty, but the final implementation sets streamed_visible_output only when call.completed is true; a call cut while streaming arguments is discarded and follows the empty-truncation path. Since this document describes the system as built, specify “completed tool call” here so the documented contract matches the implementation and its new regression test.

AGENTS.md reference: AGENTS.md:L14-L16

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant