Remove the fixed round limit from AI development tasks
Verify control plane / verify (push) Canceled after 0s
Verify control plane / verify (pull_request) Canceled after 0s

This commit is contained in:
WebUp Cloud committed 2026-11-08 00:43:51 +08:00
1 parent 36ee771ef0
commit 66d339fbed
5 files changed
+34 -13

No files matched your search

@@ -159,11 +159,6 @@ public class AgentWorker {
tasks.finish(id, lease, "PAUSED", "用户暂停,预算继续保留", false);
return;
}
if (((Number) task.get("step_count")).intValue()
>= ((Number) task.get("max_steps")).intValue()) {
tasks.finish(id, lease, "PAUSED", "达到步骤上限,请核对当前项目进度", false);
return;
}
if (tasks.remaining(reservation).compareTo(bound) < 0) {
tasks.finish(id, lease, "PAUSED", "剩余预算不足以覆盖一次最坏情况下的调用,请取消后调整预算重新发起", false);
return;
@@ -429,10 +429,7 @@ public class TaskService {
if (action.equals("cancel") && (stopping || status.equals("CANCELLED"))) return find(id, user);
if (stopping) throw new ApiError.Failure(409, "任务正在停止");
if (action.equals("resume") && status.equals("PAUSED")) {
db.update(
"UPDATE ai_tasks SET status='QUEUED',error='',requested_action='',max_steps=CASE WHEN"
+ " max_steps<=step_count THEN step_count+30 ELSE max_steps END WHERE id=?",
id);
db.update("UPDATE ai_tasks SET status='QUEUED',error='',requested_action='' WHERE id=?", id);
event(id, "QUEUED", "用户继续任务");
} else if (action.equals("pause") && (status.equals("QUEUED") || status.equals("RUNNING"))) {
if (status.equals("QUEUED")) db.update("UPDATE ai_tasks SET status='PAUSED' WHERE id=?", id);
@@ -357,6 +357,37 @@ class AgentWorkerIntegrationTest {
verify(sandbox).execute(eq(project), argThat(call -> call.name().equals("write_file")));
}
@Test
void legacyStepLimitPauseCanResumeAndRunMoreThanThirtyAdditionalRounds() throws Exception {
UUID id =
(UUID)
tasks
.create(
user, project, model, "Finish build", new BigDecimal("20"), "legacy-step-cap")
.get("id");
users
.db()
.update(
"UPDATE ai_tasks SET step_count=60,max_steps=60,status='PAUSED',error=? WHERE id=?",
"达到步骤上限,请核对当前项目进度",
id);
tasks.action(id, user, "resume");
var toolResponse = response("Check the build", "run_command");
var finalResponse = response("Build done", null);
var rounds = new java.util.concurrent.atomic.AtomicInteger();
when(transport.request(anyString(), anyString(), anyString(), anyString(), anyInt(), any()))
.thenAnswer(call -> rounds.incrementAndGet() <= 31 ? toolResponse : finalResponse);
when(sandbox.execute(any(), any())).thenReturn("{\"exitCode\":0}");
new AgentWorker(tasks, gateway, sandbox, vault, json).run(tasks.claim());
var task = tasks.config(id);
assertEquals("COMPLETED", task.get("status"));
assertEquals(92, ((Number) task.get("step_count")).intValue());
verify(sandbox, times(31)).execute(eq(project), any());
}
@Test
void oversizedHistoryResumesAndCompactsAgainWithoutReplayingToolsOrLosingLogs() throws Exception {
String prompt = "Continue building the existing site";
@@ -162,9 +162,7 @@ class WalletTaskIntegrationTest {
UUID id = task();
tasks.action(id, user, "pause");
assertEquals("PAUSED", tasks.find(id, user).get("status"));
identity.db().update("UPDATE ai_tasks SET step_count=30 WHERE id=?", id);
tasks.action(id, user, "resume");
assertEquals(60, ((Number) tasks.find(id, user).get("max_steps")).intValue());
assertEquals("QUEUED", tasks.action(id, user, "resume").get("status"));
tasks.action(id, user, "cancel");
assertEquals("CANCELLED", tasks.find(id, user).get("status"));
assertEquals(0, BigDecimal.ZERO.compareTo((BigDecimal) wallets.get(user).get("reserved")));