From 52e1013b17c80f81b08d427b5b1354d4f80f2be0 Mon Sep 17 00:00:00 2001 From: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 Date: Wed, 10 Jun 2026 12:33:04 -0400 Subject: [PATCH] fix(agent): backfill tool name on Responses API event ordering race output_item.added may arrive after function_call_arguments.delta when the Responses API reorders events. The delta handler creates the HashMap entry with an empty name, and the previous or_insert_with no-oped on existing entries. Use and_modify to backfill the name regardless of insertion order. Co-authored-by: Will Pfleger Signed-off-by: Will Pfleger --- crates/sprout-agent/src/llm.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/sprout-agent/src/llm.rs b/crates/sprout-agent/src/llm.rs index a0ccd595ca..3aa281d633 100644 --- a/crates/sprout-agent/src/llm.rs +++ b/crates/sprout-agent/src/llm.rs @@ -732,6 +732,11 @@ impl Llm { if !call_id.is_empty() { tool_calls_map .entry(call_id) + .and_modify(|e| { + if e.0.is_empty() { + e.0 = name.clone(); + } + }) .or_insert_with(|| (name, String::new())); } }