Adding TurnId to Tool call and API responses and error logs. (#3039)

Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
uttamkanodia14
2025-07-10 00:19:30 +05:30
committed by GitHub
parent 6c12f9e0d9
commit 063481faa4
26 changed files with 289 additions and 72 deletions

View File

@@ -46,6 +46,7 @@ function getResponseText(response: GenerateContentResponse): string | null {
export async function runNonInteractive(
config: Config,
input: string,
prompt_id: string,
): Promise<void> {
await config.initialize();
// Handle EPIPE errors when the output is piped to a command that closes early.
@@ -67,15 +68,18 @@ export async function runNonInteractive(
while (true) {
const functionCalls: FunctionCall[] = [];
const responseStream = await chat.sendMessageStream({
message: currentMessages[0]?.parts || [], // Ensure parts are always provided
config: {
abortSignal: abortController.signal,
tools: [
{ functionDeclarations: toolRegistry.getFunctionDeclarations() },
],
const responseStream = await chat.sendMessageStream(
{
message: currentMessages[0]?.parts || [], // Ensure parts are always provided
config: {
abortSignal: abortController.signal,
tools: [
{ functionDeclarations: toolRegistry.getFunctionDeclarations() },
],
},
},
});
prompt_id,
);
for await (const resp of responseStream) {
if (abortController.signal.aborted) {
@@ -101,6 +105,7 @@ export async function runNonInteractive(
name: fc.name as string,
args: (fc.args ?? {}) as Record<string, unknown>,
isClientInitiated: false,
prompt_id,
};
const toolResponse = await executeToolCall(