Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/modules/llm/domain/entity/eino_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func FromDOToolCall(t *ToolCall) schema.ToolCall {
ID: t.ID,
Type: t.Type,
Function: FromDOFunctionCall(t.Function),
Extra: t.Extra,
}
}

Expand Down
37 changes: 37 additions & 0 deletions backend/modules/llm/domain/entity/eino_convertor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,48 @@ func TestFromDOToolCalls(t *testing.T) {
},
},
},
{
// Regression test: FromDOToolCall previously dropped Extra when
// converting a stored ToolCall back into an eino schema.ToolCall
// for an outbound model request, silently losing any
// provider-specific metadata attached to a prior tool call
// (e.g. on a follow-up turn in a multi-turn tool-calling
// conversation), even though ToDOToolCall correctly preserves it
// in the reverse direction.
name: "test from do tool calls preserves extra",
args: args{
ts: []*ToolCall{
{
Index: ptr.Of(int64(0)),
ID: "id2",
Type: "function",
Function: &FunctionCall{
Name: "name2",
Arguments: "args2",
},
Extra: map[string]any{"signature": "abc123"},
},
},
},
want: []schema.ToolCall{
{
Index: ptr.Of(0),
ID: "id2",
Type: "function",
Function: schema.FunctionCall{
Name: "name2",
Arguments: "args2",
},
Extra: map[string]any{"signature": "abc123"},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, len(tt.want), len(FromDOToolCalls(tt.args.ts)))
assert.Equal(t, tt.want[0].Function.Arguments, FromDOToolCalls(tt.args.ts)[0].Function.Arguments)
assert.Equal(t, tt.want[0].Extra, FromDOToolCalls(tt.args.ts)[0].Extra)
})
}
}
Expand Down
Loading