Skip to content

Commit a19361b

Browse files
committed
Handle empty function call metadata arguments
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9b232bff-6a8c-4b02-addd-89de57a82f6a
1 parent abf8c3c commit a19361b

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,7 @@ def handle(self, content: Content) -> Generator[ResponseStreamEvent]:
996996
yield self._summary_part.emit_text_delta(content.text)
997997

998998
elif content.type == "function_call" and content.call_id is not None:
999-
if (
1000-
content.user_input_request
1001-
and content.arguments is None
1002-
and content.call_id in self._seen_function_call_ids
1003-
):
999+
if content.user_input_request and not content.arguments and content.call_id in self._seen_function_call_ids:
10041000
return
10051001
if self._active_type != "function_call" or self._active_id != content.call_id:
10061002
yield from self._close()

python/packages/foundry_hosting/tests/test_responses.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,11 @@ async def test_function_call_streaming(self) -> None:
12651265
assert len(args_done) == 1
12661266
assert args_done[0]["data"]["arguments"] == '{"q": "hello"}'
12671267

1268-
async def test_declaration_only_metadata_does_not_duplicate_streamed_function_call(self) -> None:
1269-
metadata = Content.from_function_call("call_1", "search", arguments=None)
1268+
@pytest.mark.parametrize("arguments", [None, ""])
1269+
async def test_declaration_only_metadata_does_not_duplicate_streamed_function_call(
1270+
self, arguments: str | None
1271+
) -> None:
1272+
metadata = Content.from_function_call("call_1", "search", arguments=arguments)
12701273
metadata.id = "call_1"
12711274
metadata.user_input_request = True
12721275
agent = _make_agent(

0 commit comments

Comments
 (0)