Repository navigation
Description
What happened
On 2026-09-03, in the live chat task door on build d4ac249c (dirty), a task using z-ai/glm-5.3-flash ran:
go test ./internal/tui3/ -count=1 2>&1 | tail -5
The foreground call crossed background after and became job 16. The task could not park on that live job. Instead it issued the same helper repeatedly:
bash {"command":"sleep 28; tail -5 <job-16.log>"}
...
[stuck] You have repeated the same bash call 3 times with the same result.
It then killed job 16 as though the empty buffered log meant a hang, restarted the suite verbosely as job 18, and polled that progressing run four more times. At 4m35s, while the log was still advancing through passing tests, the task ended with:
this turn is going in circles · stopping here with anything remaining left undone
The same session supplies the control. Another task's original suite, job 24, was allowed to remain alive and exited successfully:
ok github.com/Agent-Field/aforge-v2/internal/tui3 459.973s
That task created and killed a succession of helper jobs in the 25–39 range merely to wait for job 24. The run therefore paid for many model rounds and helper processes around one legitimate eight-minute command.
This is a logic bug across two already-stated contracts. #55 says a background job completes by event and wakes the waiting work without polling. #79 says quiet, productive work is not circling. The present task runner leaves a promoted foreground job between those contracts: the child agent deliberately cannot wake itself (TestTaskNodeAgentDoesNotWake), but its runner does not park and resume it either. The loop detector correctly sees the resulting polls as repeated calls, yet reports the task rather than the missing wait state as the failure.
Replication
Deterministic (no model).
Add a scripted task-run case beside internal/session/wake_test.go / task_progress_test.go:
- Give a task child a stub completer whose first answer calls
bashwith a command that emits a line, waits longer than an injected shortbackground after, then printsPASSand exits 0. - Let the ordinary promotion door adopt the call; do not call
jobRegistry.notifyby hand. - Record every subsequent completer request and every tool call until the process exits.
Run it with:
go test ./internal/session/ -run 'TestATaskParksOnItsPromotedForegroundCommandUntilItExits' -count=20Today the loop immediately asks the completer again after the promotion result. A stub that answers with the field-run's sleep 28; tail ... calls reaches the no-progress/loop path; a stub that simply says it is waiting lets the task run proceed toward settlement while its required command is still alive. Both are the same missing state. The deterministic fixture should initially pin the simpler observation: a second model request happens before the promoted process exits.
Field (real model).
Build with make build, run bin/aforge, and start a /task solo whose last acceptance command is an unbuffered command known to take longer than background after (the package command above takes about 8 minutes in this repository). Use z-ai/glm-5.3-flash for the task seat. Today the task begins jobs output, sleep; tail, or equivalent calls after promotion; repeated waits can produce [stuck] and finally this turn is going in circles before the original command ends.
Owner's forensics, may be gone: the 2026-09-03 folder-picker session retained task 7's journal and jobs 16/18; the deterministic stub above must stand without it.
Where
internal/session/promote.go: turns the foreground call into a job and returns control to the model.internal/session/task_child_run.go: owns a task child's turns and has a park for outstanding parts, but none for a promoted foreground command.internal/session/wake_test.go, searchable asTestTaskNodeAgentDoesNotWake: correctly forbids a task agent from starting an unowned second conversation; the task runner must own this wake.internal/session/looped.goand the no-progress accounting intask_run.go: observe the manufactured polling, then attribute the stop to the worker.
The fix
A foreground command that is promoted inside a task remains work that call is waiting for. At the promotion boundary, the task runner parks without another model request. The job registry's real exit event wakes that same runner, which resumes the same task turn with the ordinary while you worked: job N exited ... note.
This must not make the task agent self-wake, and it must not wait forever on an explicitly detached background:true server. Preserve the provenance of a promoted foreground call so the runner knows it is owed before the task can finish. Time parked on that live process is neither a tool step nor no-progress/circling evidence. Cancellation and jobs kill still wake the park with their actual ending.
The loop detector should keep stopping genuine repeated polling; the fix removes the need to poll instead of weakening that detector.
Acceptance
- e2e: Through the real task-child run with the scripted completer and a real promoted shell process, no second model request occurs before the process exits; the next request contains
while you worked: job 1 exited 0: PASS, and the task can settle done with exit code 0. - e2e: The same door with a process killed through
jobs killwakes exactly once with the killed ending and leaves no parked goroutine or live process. - e2e: An explicit
bash background:truedev server does not hold a task open merely because it remains alive; only a foreground call adopted by the promotion/timeout/key road is owed. - Unit: Parked duration adds zero tool steps, zero no-progress steps, and zero loop nudges; repeated polling after a non-owed explicit background job still trips the existing detector.
TestTaskNodeAgentDoesNotWakeremains green: the runner owns the wake, not a second conversation inside the task worktree.- The manual page under
internal/manual/chat/states the task-specific park/wake behavior, and the change entry'sinvalidatesnames the old belief that completion wake alone prevented task workers from polling.
Drafted with CodeAF · reviewed and owned by the author
Activity
test: the real-model lane that watches a worker wait out its own comm…
test: the missing-ending failure names what the worker did instead (#568
fix: a task waits for the command it started instead of polling it (#568
test: the real-model lane that watches a worker wait out its own comm…
test: the missing-ending failure names what the worker did instead (#568
fix: a task waits for the command it started instead of polling it (#568
test: the real-model lane that watches a worker wait out its own comm…
test: the missing-ending failure names what the worker did instead (#568
test: the park tests own the clock they were racing (#568)
fix: a task waits for the command it started instead of polling it (#568