Skip to content

test(agent): lock in aggregate gating of a parallel tool batch (#192) - #214

Open
justrach wants to merge 1 commit into
mainfrom
fix/192-parallel-batch-gate
Open

test(agent): lock in aggregate gating of a parallel tool batch (#192)#214
justrach wants to merge 1 commit into
mainfrom
fix/192-parallel-batch-gate

Conversation

@justrach

Copy link
Copy Markdown
Owner

TL;DR

No code change is needed#192's overflow window is already closed on main by the #193 pre-send gate. This PR adds the regression test the issue asked for (its ask #4) and documents why the gate covers the parallel-batch case.

Why it's already handled

Agent.runTurn()'s loop is:

gate (#193 inputOverCompactThreshold)  ← top of loop
  → request()
  → stepResponses()   ← appends the whole parallel tool batch to self.messages
  → loop back → gate  ← re-estimates over the appended batch
  → continuation request()

The #193 gate sits exactly between the tool batch being appended and the continuation request, and inputOverCompactThresholdfullInputEstimateTokens serializes the full self.messages (including the freshly appended outputs). So a parallel batch that crosses compactAt() only in aggregate triggers compaction before the continuation is sent — which is #192's scenario.

(The #203 prefill baseline, in the in-flight .202 follow-ups, only makes the gate fire earlier / more conservatively; it isn't required to close this window.)

Test (the issue's ask #4)

inputOverCompactThreshold (#192): a parallel tool batch is gated as an aggregate:

  • one function_call_output (~6 KB, individually far under the window and the 16 KB per-output cap) → gate does not fire;
  • a six-output batch (the reported six parallel read_file calls) → aggregate serialized input crosses compactAt() → gate fires.

Verified on main: zig build test green, zig fmt clean.

Closes #192

#192 asked for a pre-send context gate between a parallel tool batch and its
continuation request, plus a regression test. The gate already exists: runTurn's
#193 pre-send check sits at the top of the loop — after stepResponses appends the
whole batch and before the continuation request — and inputOverCompactThreshold
re-estimates over the full messages, including the freshly appended outputs. So a
parallel batch that crosses compactAt() only in aggregate triggers compaction
before it is sent, which is exactly #192's scenario.

This adds the missing regression test (the issue's ask #4): one function_call_output
stays under the window; a six-output batch (each individually under the per-output
cap) crosses compactAt() in aggregate and trips the gate. No code change is needed
on top of #193; the #203 prefill baseline (in the in-flight .202 follow-ups) only
makes the gate fire earlier/more conservatively.

Refs #192

Co-Authored-By: blackfloofie <265516171+blackfloofie@users.noreply.github.com>
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.

Codex can still overflow between a parallel tool batch and its continuation request

1 participant