Repository navigation
fix(runtime): treat an empty completion after tool results as a provider fault - #196
Merged
lg2m merged 2 commits intoSep 26, 2026
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f501d3a7a
ℹ️ 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".
lg2m
added a commit
that referenced
this pull request
Sep 26, 2026
…tions (ENG-952) Review follow-ups on #196. Steering or a checkpoint correction joins the request as a user message after the tool results, so `messages.last()` missed them and a bare terminal event still settled `completed`; the fault predicate now scans every user message since the last assistant turn. Whitespace-only deltas before that event counted as content although `has_content` trims them out of the transcript; the predicate trims too. Tests: the regression runs with no prelude, "\n", and " \n\t"; an "ok" prelude still completes in two sends; a new test queues steering so the empty turn's request ends in a user message. Both new checks fail on 3f501d3. Ledger RR4.1 and the ADR-0040 paragraph in architecture.md record the behaviour.
…der fault (ENG-952)
A gateway that swallows an upstream failure returns a bare terminal event:
no text, no tool call, no usage. The run loop treated that as a finished
answer and settled `completed`, so the user saw only the empty-turn
placeholder and had to re-prompt; two production runs on 2026-09-25/26 lost
their in-flight work this way, each right after delivering ~17 KB of fresh
tool results.
Silence in reply to tool results is not an answer. When a completed turn
carries no content, no calls, and no usage, and the previous message holds
tool results, the loop now records the same transient fault a stream cut
short does: bounded re-issue with backoff, then `Paused`, never
`completed`. An empty reply to the prompt itself (turn one, no results)
still completes; the placeholder keeps that transcript well-formed.
Five test providers that used a bare `Completed { usage: None }` as their
"done" signal after tool results now say "done", which is what a real model
does.
Regression: `an_empty_completion_without_usage_is_a_transient_fault_not_an_answer`
(read → empty reply → MAX_TURN_RETRIES re-issues → Paused; the same reply
with usage present completes once). Fails on the previous code.
…tions (ENG-952) Review follow-ups on #196. Steering or a checkpoint correction joins the request as a user message after the tool results, so `messages.last()` missed them and a bare terminal event still settled `completed`; the fault predicate now scans every user message since the last assistant turn. Whitespace-only deltas before that event counted as content although `has_content` trims them out of the transcript; the predicate trims too. Tests: the regression runs with no prelude, "\n", and " \n\t"; an "ok" prelude still completes in two sends; a new test queues steering so the empty turn's request ends in a user message. Both new checks fail on 3f501d3. Ledger RR4.1 and the ADR-0040 paragraph in architecture.md record the behaviour.
lg2m
force-pushed
the
fix/eng-952-empty-turn-fault
branch
from
September 26, 2026 19:03
919c6a8 to
b123ed3
Compare
lg2m
added a commit
that referenced
this pull request
Oct 5, 2026
…tch bench completes again (#242) * fix(bench): tool_dispatch completes again; a test runs its fixture The bench's provider answered the turn after a tool result with a bare unmetered completion. Since #196 the run loop treats that as a swallowed gateway fault and retries it, so the bench never finished. The fixture now answers with text. It moves to tests/support/read_tool.rs, shared with a new integration test that runs one bench iteration under a 10 s timeout, so a fixture that stops completing fails CI instead of hanging the bench. Linear: ENG-1003 * fix(provider): Bedrock compaction no longer fails once a session has used a tool Converse rejects any request holding tool-use or tool-result blocks unless it declares tools: "The toolConfig field must be defined when using toolUse and toolResult content blocks". Both compaction summarizers send exactly that: the session's tool history, with no tools. So on native bedrock/, neither /compact nor automatic in-run compaction worked for a session that had made one tool call, and long sessions failed once the context filled. The Bedrock codec now renders tool blocks as text on a request that declares no tools, for example "[tool call: read_file {...}]" and "[tool result from read_file]". The model reads the same history and cannot call anything. Requests with tools keep their blocks, so the cached prefix is unchanged. The other codecs are untouched: those APIs accept tool blocks without tools. Verified live on bedrock/ Claude Haiku 4.5: one read_file call, then CompactSession over qq serve. main fails the compaction run with the error above; this completes it. Linear: ENG-1002 * docs(provider): place the tool-history rule after the budget-final passage; review nits (ENG-1002) Review follow-up: the compaction sentence sat inside the budget-final passage, so its next sentence read as if it applied to summaries. Stale 'dropping the tools is rejected' reasoning in bedrock.rs and the ToolChoice doc now names the cached prefix and native tool blocks. Result labels take the first call with an id. The between-run /compact test asserts the summary still carries tool blocks. Mantle's Anthropic path, checked live, accepts tool blocks without tools. Linear: ENG-1002
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.
Fixes ENG-952. Stacked on #195 (ENG-940); merge that first, then this rebases to one commit.
User-visible behavior
A run no longer settles
completedwhen the provider answers fresh tool results with nothing. Two production runs on 2026-09-25/26 did exactly that after a LiteLLM gateway returned a bare[DONE](no text, no calls, no usage); the user saw only the empty-turn placeholder and had to re-prompt, losing the in-flight work twice.Cause
ProviderEvent::Completed { usage: None }with no preceding events was classified as a finished answer. The transient-fault path (bounded re-issue →Paused) exists but was never entered.Design
When a completed turn carries no content, no calls, and no usage, and the previous message holds tool results, the loop records the same transient fault a stream cut short does: retry with backoff up to
MAX_TURN_RETRIES, thenPaused, nevercompleted. Scoped deliberately: an empty reply to the prompt itself (turn one, no results) still completes so the existing placeholder keeps that transcript well-formed, and a reply with usage is a real (if useless) answer and completes once. No schema or protocol change.Five test providers used a bare
Completed { usage: None }as their "done" signal after tool results; they now say "done", which is what a real model does.Verification
an_empty_completion_without_usage_is_a_transient_fault_not_an_answer: read → empty reply → 5 re-issues →Pausedwith the fault message; the same reply with usage present completes once. Fails on the base commit (settlescompletedafter one call).cargo test --workspacegreen (736 qq-core). One headless test (hard_cost_budget_cancels_an_unmetered_looping_child) flaked once under full-workspace load and passed 5/5 in isolation on both this branch and the base; unrelated 2 s timeout.-D warningsclean; fmt clean.Performance
None: one extra boolean check per completed turn, no allocation.