Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/crates/ai-adapters/src/client/response_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub(crate) async fn aggregate_stream_response(
id,
name,
arguments,
arguments_is_snapshot,
} = tool_call;

if let Some(tool_call_id) = id {
Expand Down Expand Up @@ -85,7 +86,11 @@ pub(crate) async fn aggregate_stream_response(

if let Some(tool_call_arguments) = arguments {
if pending_tool_call.has_pending() {
pending_tool_call.append_arguments(&tool_call_arguments);
if arguments_is_snapshot {
pending_tool_call.replace_arguments(&tool_call_arguments);
} else {
pending_tool_call.append_arguments(&tool_call_arguments);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/crates/ai-adapters/src/stream/stream_handler/gemini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,15 @@ mod tests {
id: None,
name: Some("get_weather".to_string()),
arguments: Some("{\"city\":".to_string()),
arguments_is_snapshot: false,
};
state.assign_id(&mut first);

let mut second = UnifiedToolCall {
id: None,
name: Some("get_weather".to_string()),
arguments: Some("\"Paris\"}".to_string()),
arguments_is_snapshot: false,
};
state.assign_id(&mut second);

Expand All @@ -225,6 +227,7 @@ mod tests {
id: None,
name: Some("get_weather".to_string()),
arguments: Some("{}".to_string()),
arguments_is_snapshot: false,
};
state.assign_id(&mut first);
state.on_non_tool_response();
Expand All @@ -233,6 +236,7 @@ mod tests {
id: None,
name: Some("get_weather".to_string()),
arguments: Some("{}".to_string()),
arguments_is_snapshot: false,
};
state.assign_id(&mut second);

Expand All @@ -252,11 +256,13 @@ mod tests {
id: None,
name: Some("grep".to_string()),
arguments: Some("{}".to_string()),
arguments_is_snapshot: false,
};
let mut second = UnifiedToolCall {
id: None,
name: Some("read".to_string()),
arguments: Some("{}".to_string()),
arguments_is_snapshot: false,
};

first_state.assign_id(&mut first);
Expand Down
Loading
Loading