fix: approved tool results are lost and approved tools can run twice (#31502)

With tool approval set to ask, the result of an approved tool call was dropped from the chat once the reply finished, so the model no longer saw it in later turns. When the model then asked for a second tool, the first call went back to waiting for approval, and approving it again ran the tool a second time. Approved results now stay in the chat and each tool runs once.

Related to #31499
This commit is contained in:
Classic298 2026-09-28 05:59:20 +02:00 • committed by GitHub
parent 8667dd7121
commit b00745c8d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1644,7 +1644,8 @@ async def chat_completion(
async def process_chat(request, form_data, user, metadata, model, tasks=None):
try:
ctx = None
if metadata.get('assistant_message_id'):
# Saved chats load the message after approved tool calls run, so their results are kept
if metadata.get('assistant_message_id') and not is_saved_chat_id(metadata.get('chat_id')):
ctx = await build_chat_response_context(request, form_data, user, model, metadata, tasks, [])
form_data, metadata, events = await process_chat_payload(request, form_data, user, metadata, model)