Optimize the agent tool execution loop
This commit is contained in:
1 parent
572371d7af
commit
4291adfdfb
7 files changed
+110
-7
No files matched your search
@@ -111,7 +111,7 @@ public class ModelGateway {
|
||||
ArrayNode messages = body.putArray("messages");
|
||||
for (JsonNode m : history) {
|
||||
ObjectNode copy = ((ObjectNode) m).deepCopy();
|
||||
copy.remove(List.of("native", "nativeType"));
|
||||
copy.remove(List.of("native", "nativeType", "is_error"));
|
||||
messages.add(copy);
|
||||
}
|
||||
if (withTools) body.set("tools", definitions);
|
||||
@@ -135,6 +135,7 @@ public class ModelGateway {
|
||||
block.put("type", "tool_result");
|
||||
block.put("tool_use_id", m.path("tool_call_id").asText());
|
||||
block.put("content", m.path("content").asText());
|
||||
if (m.path("is_error").asBoolean(false)) block.put("is_error", true);
|
||||
} else if (role.equals("assistant") && m.path("nativeType").asText().equals(type)) {
|
||||
content.addAll((ArrayNode) m.get("native"));
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user