llama-stack-mirror/llama_stack/providers/inline/agents/meta_reference
Ben Browning a713221280 fix: Responses API: handle type=None in streaming tool calls
In the Responses API, we convert incoming response requests to chat
completion requests. When streaming the resulting chunks of those chat
completion requests, inference providers that use OpenAI clients will
often return a `type=None` value in the tool call parts of the
response. This causes issues when we try to dump and load that
response into our pydantic model, because type cannot be None in the
Responses API model we're loading these into.

So, strip the "type" field, if present, off those chat completion tool
call results before dumping and loading them as our typed pydantic
models, which will apply our default value for that type field.

This was found via manual testing of the Responses API with codex,
where I was getting errors in some tool call situations. I added a
unit test to simulate this scenario and verify the fix, as well as
manual codex testing to verify the fix.

Signed-off-by: Ben Browning <bbrownin@redhat.com>
2025-05-14 16:31:23 -04:00
..
__init__.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00
agent_instance.py feat: implementation for agent/session list and describe (#1606) 2025-05-07 14:49:23 +02:00
agents.py feat: function tools in OpenAI Responses (#2094) 2025-05-13 11:29:15 -07:00
config.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00
openai_responses.py fix: Responses API: handle type=None in streaming tool calls 2025-05-14 16:31:23 -04:00
persistence.py feat: implementation for agent/session list and describe (#1606) 2025-05-07 14:49:23 +02:00
safety.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00