Verify the declared Node entry before completing Agent tasks
This commit is contained in:
1 parent
da93d4fa1c
commit
6d55806b4f
6 files changed
+113
-9
No files matched your search
@@ -151,7 +151,7 @@ public class AgentWorker {
|
||||
.multiply(BigDecimal.valueOf(context))
|
||||
.add(((BigDecimal) price.get("output_price")).multiply(BigDecimal.valueOf(maxOutput)))
|
||||
.divide(BigDecimal.valueOf(1000000), 8, RoundingMode.UP);
|
||||
int emptyCompletions = 0;
|
||||
int incompleteCompletions = 0;
|
||||
while (true) {
|
||||
task = tasks.config(id);
|
||||
String action = task.get("requested_action").toString();
|
||||
@@ -242,10 +242,18 @@ public class AgentWorker {
|
||||
tasks.finish(id, lease, "PAUSED", "源码检查达到扫描上限,尚不能确认生成结果;请检查工作区后继续", false);
|
||||
return;
|
||||
}
|
||||
if (inspection == null || inspection.path("sourceFiles").asInt(0) == 0) {
|
||||
tasks.requireSource(id, lease);
|
||||
if (++emptyCompletions < 2) continue;
|
||||
tasks.finish(id, lease, "PAUSED", "AI 尚未生成实际源码,已暂停;请调整需求或模型后继续", false);
|
||||
String missingStart =
|
||||
inspection == null ? "" : inspection.path("missingStartFile").asText("");
|
||||
if (inspection == null
|
||||
|| inspection.path("sourceFiles").asInt(0) == 0
|
||||
|| !missingStart.isEmpty()) {
|
||||
tasks.requireSource(id, lease, missingStart);
|
||||
if (++incompleteCompletions < 2) continue;
|
||||
String reason =
|
||||
missingStart.isEmpty()
|
||||
? "AI 尚未生成实际源码,已暂停;请调整需求或模型后继续"
|
||||
: "缺少 package.json 指定的启动文件 " + missingStart + ",补齐后可继续任务";
|
||||
tasks.finish(id, lease, "PAUSED", reason, false);
|
||||
return;
|
||||
}
|
||||
tasks.finish(id, lease, "COMPLETED", "本轮开发已结束,工作区已有源码;完整功能与构建结果以实际测试为准", true);
|
||||
|
||||
@@ -465,8 +465,22 @@ public class TaskService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void requireSource(UUID id, String lease) {
|
||||
public void requireSource(UUID id, String lease, String missingStart) {
|
||||
locked(id, lease);
|
||||
if (!missingStart.isEmpty()) {
|
||||
message(
|
||||
id,
|
||||
Map.of(
|
||||
"role",
|
||||
"user",
|
||||
"content",
|
||||
"The workspace is missing the Node startup file declared in package.json: "
|
||||
+ missingStart
|
||||
+ ". Use the tools to create the entry point or correct the start script to match"
|
||||
+ " the project, then verify that the app can start before finishing."));
|
||||
event(id, "SOURCE_REQUIRED", "缺少 package.json 指定的启动文件 " + missingStart + ",已要求 AI 补齐");
|
||||
return;
|
||||
}
|
||||
message(
|
||||
id,
|
||||
Map.of(
|
||||
|
||||
Reference in new issue
Block a user