From 9f41447f201589b194be064001ea2f0e073e55cf Mon Sep 17 00:00:00 2001 From: Mark Ward <90335263+MarkWard0110@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:58:36 -0500 Subject: [PATCH] examples: make gpt-oss resilient for failed tool calls (#569) --- 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 1becdd7..97be624 100644 --- a/examples/gpt-oss-tools-stream.py +++ b/examples/gpt-oss-tools-stream.py @@ -98,6 +98,7 @@ while True: 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 b250227..d4a20f7 100644 --- a/examples/gpt-oss-tools.py +++ b/examples/gpt-oss-tools.py @@ -78,7 +78,7 @@ while True: 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