Skip to content

fix(agentmain): add --no-reply-wait for unattended one-shot --task runs - #874

Closed
leonsong09 wants to merge 1 commit into
lsdefine:mainfrom
leonsong09:fix/agentmain-no-reply-wait
Closed

leonsong09 wants to merge 1 commit into
lsdefine:mainfrom
leonsong09:fix/agentmain-no-reply-wait

Conversation

@leonsong09

@leonsong09 leonsong09 commented Nov 12, 2026 •

Copy link
Copy Markdown

Problem

agentmain.py --task waits up to 600s (300 x 2s) for reply.txt after round 1 finishes, so an external supervisor can feed a follow-up round (documented in memory/subagent.md).

That is correct for supervised sessions. For unattended callers (scheduler, batch runner, CI) there is no supervisor, so the wait is pure idle:

  • the report is already written,
  • but the process keeps running,
  • until the outer runner's hard timeout kills the whole process tree (rc=-999).

Evidence

A task whose real work takes ~1200s, run with timeout_s=1800, hit the wall on three consecutive days:

date rc duration report written at
2026-11-09 -999 1800.7s 20:41 (≈10 min earlier)
2026-11-10 -999 1800.9s 20:45 (≈6 min earlier)
2026-11-11 -999 1800.8s 20:40 (≈10 min earlier)

duration is always the timeout value, and the report's mtime is always well before it — i.e. the work completed, only the exit was late.

Reproduced minimally:

# without the flag: still alive after 120s (would run to 600s, then the runner kills it)
python agentmain.py --task probe --input "reply with OK" --nobg

# with the flag: exits in 3.0s
python agentmain.py --task probe --input "reply with OK" --nobg --no-reply-wait

Change

Add an explicit opt-in flag; default behavior is unchanged, so supervised workflows keep working.

parser.add_argument('--no-reply-wait', action='store_true',
                    help='one-shot mode: exit right after round 1, do not wait for reply.txt')
if not args.task: break
if args.no_reply_wait: break          # <- new
consume_file(d, '_stop')
for _ in range(300):                  # <- unchanged
    ...

Unattended callers then pass --no-reply-wait. I deliberately avoided inferring it from --nobg (that would silently change existing semantics) and avoided turning the 600s into a tunable (that would treat the symptom, not the cause).

Testing

  • py_compile OK.
  • End-to-end, real task invocation, both arms measured (numbers above).
  • --nolog / --no-user-tools / --nobg all still present and parsed.

Closes #866

@leonsong09

Copy link
Copy Markdown
Author

superseded by #880 — see #880 / #881.

Folded into #880 as commit 6 of 6, unchanged (+9 in agentmain.py).

Closing to keep one open diff per change.

@leonsong09 leonsong09 closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] agentmain --task: unconditional 600s reply.txt wait after round 1 keeps unattended tasks alive until the runner kills them (rc=-999)

1 participant