Show actual file changes recorded for each Agent task
This commit is contained in:
1 parent
d04777247b
commit
3296d378c9
14 files changed
+453
-16
No files matched your search
@@ -74,6 +74,15 @@ public class SandboxClient {
|
||||
}
|
||||
|
||||
public String execute(UUID project, ModelGateway.Call call) {
|
||||
if (tracksChanges(call)) return executeBounded(project, call, 512000, false, true);
|
||||
return executeFileTool(project, call);
|
||||
}
|
||||
|
||||
static boolean tracksChanges(ModelGateway.Call call) {
|
||||
return Set.of("write_file", "delete_file", "run_command").contains(call.name());
|
||||
}
|
||||
|
||||
String executeFileTool(UUID project, ModelGateway.Call call) {
|
||||
return executeBounded(project, call, 131072);
|
||||
}
|
||||
|
||||
@@ -175,6 +184,11 @@ public class SandboxClient {
|
||||
}
|
||||
|
||||
private String executeBounded(UUID project, ModelGateway.Call call, int limit, boolean review) {
|
||||
return executeBounded(project, call, limit, review, false);
|
||||
}
|
||||
|
||||
private String executeBounded(
|
||||
UUID project, ModelGateway.Call call, int limit, boolean review, boolean trackChanges) {
|
||||
check();
|
||||
var allowed =
|
||||
review
|
||||
@@ -192,8 +206,9 @@ public class SandboxClient {
|
||||
"review_export");
|
||||
if (!allowed.contains(call.name())) throw new ApiError.Failure(400, "不允许的工具");
|
||||
try {
|
||||
String payload =
|
||||
json.writeValueAsString(Map.of("name", call.name(), "arguments", call.arguments()));
|
||||
var body = json.createObjectNode().put("name", call.name());
|
||||
body.set("arguments", call.arguments());
|
||||
if (trackChanges) body.put("trackChanges", true);
|
||||
var request =
|
||||
HttpRequest.newBuilder(
|
||||
URI.create(
|
||||
@@ -204,7 +219,7 @@ public class SandboxClient {
|
||||
.timeout(Duration.ofSeconds(150))
|
||||
.header("Authorization", "Bearer " + token)
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(payload))
|
||||
.POST(HttpRequest.BodyPublishers.ofString(body.toString()))
|
||||
.build();
|
||||
var response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
|
||||
try (var input = response.body()) {
|
||||
|
||||
Reference in new issue
Block a user