Skip to content

[Perf] Run consecutive read-only built-in tools concurrently (#1750) - #2094

Open
ayaangazali wants to merge 1 commit into
kyegomez:masterfrom
ayaangazali:perf/autonomous-loop-readonly-batch
Open

[Perf] Run consecutive read-only built-in tools concurrently (#1750)#2094
ayaangazali wants to merge 1 commit into
kyegomez:masterfrom
ayaangazali:perf/autonomous-loop-readonly-batch

Conversation

@ayaangazali

Copy link
Copy Markdown
Contributor

Closes #1750. Replaces #1772.

What is wrong

The autonomous loop executes every built-in tool call serially. A model response asking for four file reads pays four sequential round trips, even though reads have no ordering constraint against one another.

What this does

Consecutive read-only built-ins are buffered and flushed together through a thread pool. Ordering safety comes from when the buffer is flushed, not from inspecting arguments:

  • before any mutating tool (create_file, run_bash, ...) runs
  • before any control-flow tool (subtask_done, ...) runs
  • at the tail of the response

So a read can never be reordered past a write, and a tool that is not on the read-only list never joins a batch.

Why this replaces #1772

I force-pushed that branch to rebase it, which moves the diff under anyone already reading it. Opening a fresh PR instead and closing that one. Same change, rebased on current master, no history rewritten.

tests/structs/test_agent.py: 88 passed.

…urrently] (kyegomez#1750)

The loop executed every built-in tool call serially, so a model response asking
for four file reads paid four sequential round trips. Reads have no ordering
constraint against each other, only against writes.

Consecutive read-only built-ins are now buffered and flushed together through a
thread pool. The buffer is flushed before any mutating or control-flow tool
runs, and again at the end of the response, so a read can never be reordered
past a write.

Replaces kyegomez#1772, which I force-pushed. Opening fresh rather than rewriting that
branch again so the diff a reviewer already looked at is not moved under them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Projects

None yet

2 participants