Repository navigation
feat(turn): run read-only tool-call batches sequentially in one step - #494
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
Owner decision (3 Nov 2026): revisit the no-parallel non-goal with the sequential-batch option from #480. A response whose tool calls are all ReadOnly runs them in model order, each as its own sandwich, inside one step; any other batch keeps first-call-only. See docs/tool-batches.md.
ajianaz
force-pushed
the
feat/sequential-tool-batches
branch
from
November 3, 2026 09:00
ba32f0c to
996ceb1
Compare
| - Interruptible provider calls (#484): a cancel (Esc, `--timeout`, ACP `session/cancel`, serve cancel) now interrupts a provider call already in flight instead of waiting for the provider to answer or the 120 s HTTP timeout. New additive `Provider::complete_with_cancel(&mut self, transcript, &CancelToken)` (default delegates to `complete`, so embedders and mocks are unchanged); `OpenAiProvider` runs the request on a helper thread and re-checks the token every 100 ms, `FailoverProvider` and `Box<P>` forward it, and the turn loop calls it. On cancel the thread is abandoned, nothing is committed for the call, and the turn settles as cancelled as before (resumable). A streaming call also stops reading and stays silent on the live sinks. The abandoned request may still be billed by the provider. Measured: `tole run --timeout 1` against a provider silent for 8 s returned after 8.25 s, now about 1 s, in stream and non-stream modes. | ||
|
|
||
| ### Changed | ||
| <<<<<<< HEAD |
…ve the changelog conflict
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.
What (description of the change)
A response's tool calls now run as a sequential batch in one model step when every call is a registered ReadOnly tool; any non-ReadOnly or unknown call keeps the old first-call-only behavior for that response. Each call runs in model order as its own effect sandwich with its own
ReplaySafety— this is not concurrent execution. Provider-side,ProviderOutputis unchanged; a new defaultedProvider::last_extra_tool_calls()carries the calls after the first (OpenAiProviderfills it in both modes,Box<P>andFailoverProviderforward; the list stops at the first malformed extra). On the wire, the 2nd..Nth intents carry a"batch": truemarker (machine::begin_batch_member) and the transcript flattening merges them into one assistanttool_callsarray with results in call order; unmarked intents flatten exactly as before. Batch members are checked by the loop guard andgate::authorizeindividually; a failed call stops the batch and the remaining calls are recorded as intents settled with "not executed: an earlier call in this batch failed" (every tool_call has a result). Docs:docs/prd.mdnon-goal now reads "no concurrent execution; sequential batches supported",docs/architecture.mdmatching line updated, anddocs/tool-batches.mdrecords the design note. CHANGELOG under [Unreleased].Why (the problem you're solving)
Closes #480. The fleet model emits parallel tool calls routinely (measured in the issue: 22 emitted / 11 dropped / all 11 re-asked; the first response's extra calls alone accounted for 43% of requests and ~32% of wall time). Owner decision 3 Nov 2026: revisit the non-goal with the SEQUENTIAL batch option, v1 restricted to all-ReadOnly batches, no
ProviderOutputshape change.Testing (how you verified this works)
tests/tool_batches.rswith stubs — 3 passed / 5 failed (the read-only batch ran only[1]instead of[1,2,3]; the step-budget test counted 31 intents instead of 93). The two early passes were the fallback and crash-resume guards, which exist before the feature.[1,2,3]in one step; mixed batch falls back to[1]only; a failing call stops the batch with stub results for the rest; step budget counts one step for a 93-call batch; loop guard, cancel mid-batch, crash mid-batch (at most one pending intent, replayed as before, unstarted calls re-asked after resume) all pinned.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --no-fail-fast(944 passed / 0 failed, 52 suites — verified independently on a second full run),cargo test -p tole-core --no-default-features(373 passed / 0 failed),cargo build -p tole-cli --no-default-features: all pass.docs/tool-batches.md: terminal aborts (loop trip, cancel, unknown tool, denial) leave unstarted calls unrecorded (in an all-ReadOnly batch the approver is never consulted, so mid-batch denial is effectively unreachable); observers see one tool_started/finished pair per executed call in order; the poll-tool step refund applies only to the batch's first call; the cache prefix stays append-only.