From a662e8faf1267c9d3f526231174820945a6b482c Mon Sep 17 00:00:00 2001 From: Mark Ward Date: Fri, 29 Aug 2025 18:39:42 -0500 Subject: [PATCH] resolve invalid tool usage status code 400 if llm makes a mistake in the tool name. --- examples/gpt-oss-tools-stream.py | 1 + examples/gpt-oss-tools.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gpt-oss-tools-stream.py b/examples/gpt-oss-tools-stream.py index 1becdd78..97be624e 100644 --- a/examples/gpt-oss-tools-stream.py +++ b/examples/gpt-oss-tools-stream.py @@ -98,6 +98,7 @@ def get_weather_conditions(city: str) -> str: messages.append(result_message) else: print(f'Tool {tool_call.function.name} not found') + messages.append({'role': 'tool', 'content': f'Tool {tool_call.function.name} not found', 'tool_name': tool_call.function.name}) else: # no more tool calls, we can stop the loop diff --git a/examples/gpt-oss-tools.py b/examples/gpt-oss-tools.py index b2502271..d4a20f7f 100644 --- a/examples/gpt-oss-tools.py +++ b/examples/gpt-oss-tools.py @@ -78,7 +78,7 @@ def get_weather_conditions(city: str) -> str: messages.append({'role': 'tool', 'content': result, 'tool_name': tool_call.function.name}) else: print(f'Tool {tool_call.function.name} not found') - + messages.append({'role': 'tool', 'content': f'Tool {tool_call.function.name} not found', 'tool_name': tool_call.function.name}) else: # no more tool calls, we can stop the loop break