fix(server): schema preflight for tool call (#15172)

This commit is contained in:
OrbisAI Security authored and GitHub committed 2026-07-05 03:53:44 +08:00
1 parent 06a89d478e
commit a7f824c42b
2 files changed
+123 -2

No files matched your search

@@ -1,3 +1,5 @@
import { z } from 'zod';
import {
type LlmBackendConfig,
llmDispatchToolLoopStream,
@@ -63,7 +65,7 @@ export function createToolExecutionCallback(
};
}
async function executeToolCall(
export async function executeToolCall(
tools: CopilotToolSet,
request: LlmToolCallbackRequest,
options: CopilotToolExecuteOptions
@@ -103,7 +105,11 @@ async function executeToolCall(
}
try {
const output = await tool.execute(request.args, options);
const args =
tool.inputSchema instanceof z.ZodType
? tool.inputSchema.parse(request.args)
: request.args;
const output = await tool.execute(args, options);
return {
callId: request.callId,
name: request.name,
@@ -173,3 +179,7 @@ export function createToolLoopBridge(
);
};
}
// re-export for test consumers
export type { LlmToolCallbackRequest } from '../../../../native';
export type { CopilotToolSet, CopilotToolExecuteOptions } from '../../tools';