feat(core): enable contiguous parallel admission for Kind.Agent tools (#20583)

This commit is contained in:
Abhi
2026-02-27 16:08:10 -05:00
committed by GitHub
parent ca13458412
commit 966b9059d0
2 changed files with 95 additions and 4 deletions
+9 -3
View File
@@ -29,6 +29,7 @@ import { PolicyDecision } from '../policy/types.js';
import {
ToolConfirmationOutcome,
type AnyDeclarativeTool,
Kind,
} from '../tools/tools.js';
import { getToolSuggestion } from '../utils/tool-utils.js';
import { runInDevTraceSpan } from '../telemetry/trace.js';
@@ -427,11 +428,11 @@ export class Scheduler {
return true;
}
// If the first tool is read-only, batch all contiguous read-only tools.
if (next.tool?.isReadOnly) {
// If the first tool is parallelizable, batch all contiguous parallelizable tools.
if (this._isParallelizable(next.tool)) {
while (this.state.queueLength > 0) {
const peeked = this.state.peekQueue();
if (peeked && peeked.tool?.isReadOnly) {
if (peeked && this._isParallelizable(peeked.tool)) {
this.state.dequeue();
} else {
break;
@@ -516,6 +517,11 @@ export class Scheduler {
return false;
}
private _isParallelizable(tool?: AnyDeclarativeTool): boolean {
if (!tool) return false;
return tool.isReadOnly || tool.kind === Kind.Agent;
}
private async _processValidatingCall(
active: ValidatingToolCall,
signal: AbortSignal,