Skip to content

Commit 9f41447

Browse files
authored
examples: make gpt-oss resilient for failed tool calls (#569)
1 parent da79e98 commit 9f41447

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

examples/gpt-oss-tools-stream.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def get_weather_conditions(city: str) -> str:
9898
messages.append(result_message)
9999
else:
100100
print(f'Tool {tool_call.function.name} not found')
101+
messages.append({'role': 'tool', 'content': f'Tool {tool_call.function.name} not found', 'tool_name': tool_call.function.name})
101102

102103
else:
103104
# no more tool calls, we can stop the loop

examples/gpt-oss-tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_weather_conditions(city: str) -> str:
7878
messages.append({'role': 'tool', 'content': result, 'tool_name': tool_call.function.name})
7979
else:
8080
print(f'Tool {tool_call.function.name} not found')
81-
81+
messages.append({'role': 'tool', 'content': f'Tool {tool_call.function.name} not found', 'tool_name': tool_call.function.name})
8282
else:
8383
# no more tool calls, we can stop the loop
8484
break

0 commit comments

Comments
 (0)