Skip to content

fix(provider): Bedrock compaction works after a tool call; tool_dispatch bench completes again - #242

Merged
lg2m merged 3 commits into
feat/eng-1000-ap3b-stall-reportfrom
fix/eng-1002-compaction-tool-history
Oct 5, 2026
Merged

lg2m merged 3 commits into
feat/eng-1000-ap3b-stall-reportfrom
fix/eng-1002-compaction-tool-history

Conversation

@lg2m

@lg2m lg2m commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Linear: ENG-1002, ENG-1003 · Base: #240 (AP3b), on #238.

What changes for users

On native bedrock/, compaction now works in sessions that have used a tool. On main, both /compact and automatic in-run compaction fail as soon as the session has made one tool call:

provider response failed: ValidationException: The toolConfig field must be defined when using toolUse and toolResult content blocks.

A long Bedrock session therefore could not recover once its context filled.

Verified live on 2026-10-02: one read_file call, then CompactSession over qq serve, with isolated data and runtime directories.

Route main this PR
bedrock/us.anthropic.claude-haiku-4-5… compaction failed (the error above) compaction completed
bedrock-mantle/anthropic.claude-sonnet-5 not tested on main compaction completed (no codec change: Mantle's Anthropic path accepts tool blocks without tools)

The tool_dispatch benchmark runs again (ENG-1003). It has hung since #196.

Design

  • ENG-1002. Both summarizers send the session's tool history with no tools declared: the between-run /compact (claim.rs with .without_tools()) and the in-run summary (CompiledAgentPlan::summarize).
    • The fix is in the Bedrock codec only: a request that declares no tools renders its tool blocks as text, e.g. [tool call: read_file {"path":"config.ron"}], [tool result from read_file] and [tool error from …]. The model reads the same history and cannot call anything.
    • Requests with tools keep their native blocks, so the cached prefix is unchanged. The other codecs are untouched.
    • I rejected declaring the run's tools on the summary with ToolChoice::None: that would charge tool-schema bytes to every summarizer request on every provider, and the summarizer budget would have to reserve them.
  • ENG-1003. The bench fixture answered the turn after a tool result with a bare unmetered Completed. Since fix(runtime): treat an empty completion after tool results as a provider fault #196 the run loop retries that shape as a swallowed gateway fault, so the bench never finished.
    • The fixture now answers with text.
    • It moves to tests/support/read_tool.rs, shared via #[path] (the same pattern as turn_overhead) with a new integration test that runs one bench iteration under a 10 s timeout. A fixture that stops completing now fails CI instead of silently hanging the bench.

Verification

  • Codec: a_request_without_tools_sends_its_tool_history_as_text. With no tools, every block is text, labels match their calls, an unmatched result id is handled, and the cache point is kept. With tools, the same history keeps its native blocks.
  • Core: both summarizer paths are pinned to the shape the codec handles (no tools, tool blocks present):
    • between-run: compact_session_is_refused_while_active…;
    • in-run: one_run_spanning_several_windows….
  • Bench: the_tool_dispatch_bench_run_completes times out with the old fixture and passes with the new one. cargo bench -p qq-core --bench tool_dispatch reports read_tool_loop: ~62 µs/iteration.
  • Checks:
    • cargo test --workspace: 2068 passed;
    • the minimal profile (qq-provider --no-default-features --features test-support): 210 passed;
    • clippy (--all-targets --all-features -D warnings) and fmt are clean.
  • Live: the table above.

Review

An independent read-only review approved. Its should-fixes are done:

  • the docs placement;
  • Mantle, checked live;
  • stale comments;
  • first-call labels;
  • a between-run shape assertion.

First-party Anthropic is not checked live (no key in this environment). If it ever rejects tool blocks without tools, the same rendering applies.

Compatibility

  • No protocol, store or descriptor change.
  • Bedrock wire bodies change only for requests that declare no tools and carry tool history. Every such request was rejected before this change.

Retained live evidence — 2026-10-04

The earlier live results above are the original author's report. This readiness pass found no raw provider request/response or session receipt in the PR comments, associated Linear issue attachments/comments, or the plan ledger; they have not been independently reproduced. No paid provider call or new Devin session was made. First-party Anthropic remains unverified; the old “no key” note describes the author's environment, not a current credential diagnosis. The implemented Converse-only text rendering is the documented choice over ENG-1002's initial declare-tools option.

Feature flow

flowchart LR
  A["Compaction history includes tool blocks"] --> B{"Bedrock request declares tools?"}
  B -->|No| C["Render tool history as labelled text"]
  B -->|Yes| D["Keep native tool blocks and cache shape"]
  C --> E["Summarizer request"]
  D --> E
Loading

lg2m added 3 commits October 2, 2026 10:10
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
…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
…ssage; 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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@lg2m
lg2m added this pull request to stack #241 October 2, 2026 19:10
@lg2m
lg2m merged commit e34673c into main Oct 5, 2026
4 checks passed
@lg2m
lg2m deleted the fix/eng-1002-compaction-tool-history branch October 5, 2026 02:56
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