assistant2: Skip tool uses without a matching tool result (#27082)
Anthropic API doesn't allow `tool_use` messages without a corresponding `tool_result`, so we'll skip those when building a request. I'll separately investigate why we are sending request before the tool result as that might lead to separate issues, but that might take a while and this is currently very frustrating. Release Notes: - N/A
This commit is contained in:
parent
410a942d57
commit
5f398071b2
1 changed files with 11 additions and 3 deletions
|
@ -286,9 +286,17 @@ impl ToolUseState {
|
||||||
) {
|
) {
|
||||||
if let Some(tool_uses) = self.tool_uses_by_assistant_message.get(&message_id) {
|
if let Some(tool_uses) = self.tool_uses_by_assistant_message.get(&message_id) {
|
||||||
for tool_use in tool_uses {
|
for tool_use in tool_uses {
|
||||||
request_message
|
if self.tool_results.contains_key(&tool_use.id) {
|
||||||
.content
|
// Do not send tool uses until they are completed
|
||||||
.push(MessageContent::ToolUse(tool_use.clone()));
|
request_message
|
||||||
|
.content
|
||||||
|
.push(MessageContent::ToolUse(tool_use.clone()));
|
||||||
|
} else {
|
||||||
|
log::debug!(
|
||||||
|
"skipped tool use {:?} because it is still pending",
|
||||||
|
tool_use
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue