Skip to content

Commit 507934e

Browse files
committed
feat(gemini-adapter): improve tool events
Normalized Gemini tool_use/tool_result events to expose richer metadata (name, callId, args/output/exitCode/error) and fall back to parameters/input fields so downstream consumers no longer need to inspect originalItem.
1 parent 79cb1fe commit 507934e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/gemini-adapter/src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ function normalizeGeminiEvent(event: any): CoderStreamEvent[] {
504504
{
505505
type: 'tool_use',
506506
provider,
507-
name: ev.tool_name ?? 'tool',
508-
callId: ev.call_id,
509-
args: ev.args,
507+
name: ev.tool_name ?? ev.name ?? 'tool',
508+
callId: ev.tool_id ?? ev.call_id ?? ev.id ?? null,
509+
args: ev.parameters ?? ev.args ?? ev.input ?? null,
510510
ts,
511511
originalItem: ev,
512512
},
@@ -516,10 +516,11 @@ function normalizeGeminiEvent(event: any): CoderStreamEvent[] {
516516
{
517517
type: 'tool_result',
518518
provider,
519-
name: ev.tool_name ?? 'tool',
520-
callId: ev.call_id,
521-
result: ev.result,
522-
exitCode: ev.exit_code ?? null,
519+
name: ev.tool_name ?? ev.name ?? 'tool',
520+
callId: ev.tool_id ?? ev.call_id ?? ev.id ?? null,
521+
result: ev.output ?? ev.result ?? ev.response ?? null,
522+
exitCode: ev.exit_code ?? ev.status ?? null,
523+
error: ev.error ?? null,
523524
ts,
524525
originalItem: ev,
525526
},

0 commit comments

Comments
 (0)