Skip to content

Commit 4f77489

Browse files
committed
Add tool skip history entry on rejection to satisfy the tool_call_id protocol
Regression introduced by 6280de2 refactor
1 parent ecda657 commit 4f77489

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

qgitc/aichatwidget.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,17 @@ def _onToolApproved(self, toolName: str, params: dict, toolCallId: str):
10521052
self._toolMachine.approveToolExecution(toolName, params, toolCallId)
10531053

10541054
def _onToolRejected(self, toolName: str, toolCallId: str):
1055+
model = self.currentChatModel()
1056+
1057+
# If the assistant previously requested a tool via tool_calls, OpenAI-style
1058+
# chat requires that each tool_call_id gets a corresponding tool message.
1059+
description = self.tr("✗ `{}` skipped").format(toolName)
1060+
model.addHistory(AiRole.Tool, SKIP_TOOL,
1061+
description=description,
1062+
toolCalls={"tool_call_id": toolCallId})
1063+
self._doMessageReady(model, AiResponse(
1064+
AiRole.Tool, SKIP_TOOL, description=description))
1065+
10551066
self._toolMachine.rejectToolExecution(toolName, toolCallId)
10561067

10571068
def _onAgentToolFinished(self, result: AgentToolResult):

0 commit comments

Comments
 (0)