[Bug] Prime Agent harness: SIGTERM mid-turn freezes the session permanently #1566
precociousapprentice
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Not sure
What happened?
TL;DR: When the Prime Agent worker process is killed (SIGTERM) while a tool call is in-flight, the in-flight call never gets a result. When the session re-attaches, it sits in
needs_inputon a transcript whose last entry is an unanswered tool call and never resumes the turn — the agent is frozen forever (visible as the "thinking" spinner that never resolves) even though the model is alive. This is a harness-side bug, not an engine bug.Which component — read this first
127.0.0.1:8000, the OpenAI-compatiblemtplx serveprocess). This one is healthy. In both incidents it completed every request it received (verified against~/.mtplx/logs/request-log-8000.jsonl). It is not the bug.prime-agentsupervisor + per-session worker processes that relay model calls and execute tool calls). This one is the bug. Its worker received SIGTERM mid-turn and never synthesized a terminal tool result, so the re-attached session dangles forever.The fix belongs in the Prime Agent harness (the worker/shutdown layer), not in the MLX engine. If "MTPLX devs" = the engine team, forward this to the Prime Agent / harness maintainers instead.
The bug (one sentence)
On worker shutdown, the harness must (a) synthesize a terminal tool result for any in-flight tool call, and (b) reap/kill spawned process trees. It does neither — so a SIGTERM mid-call leaves a dangling tool call that a re-attached session treats as "waiting for input" and never resumes.
Steps to reproduce
Reproduction (two confirmed incidents)
Both: model alive, engine healthy, tool call in-flight, worker gets SIGTERM,
session frozen
needs_inputuntil the terminal is killed.Incident A — 2026-08-19 00:06:33Z (full postmortem)
received SIGTERM; shutting down (exit 143)at 00:06:33Z.needs_inputfor 2h19m until a terminal restart.SESSION-HANDOFF.md→ "Harness-incident postmortem".Incident B — 2026-08-19 16:35:00Z (this investigation)
(transcript
01a01a20-…) ran ~50 local-only turns (no MTPLX model traffic13:00→15:09Z — the engine was idle, not stalled). 15:18:30Z a second
clip arrived; the cascade ran locally. 15:25:50Z the session issued an
ipythontool call; its result never arrived. 16:35:00.077Z thesupervisor received SIGTERM and took the worker(s) down (exit 143);
the hanging call logged
"Request was aborted". 16:37:07Z the supervisorre-attached the session → it hung in
needs_inputforever. 16:52Z theuser killed the terminal.
~/.prime/agent/logs/worker-…-7e5fe3fa9241.sock.de451d9d.log:received SIGTERM; shutting down (exit 143); closing 1 active session(s)at 16:35:00.077Z.
~/.prime/agent/logs/daemon.sock.4260edfa.log: supervisor relaying thesame SIGTERM to both workers at 16:35:00.078–79Z.
01a01a20-…jsonl: last assistant entry 15:25:50Z is atoolCall(ipython); the next entry 16:35:00Z is atoolResultwhosetext is literally
"Request was aborted". No entries after.~/.mtplx/logs/request-log-8000.jsonl: zero model requests13:00→15:09Z, then local-only activity — the engine was idle, not dead.
(16:35:00Z) a long-running launchd daemon logged a stop/start, and at
00:06:33Z (incident A) the same class of daemon stopped/restarted
concurrently. The supervisor is a child of a plain
/bin/zsh -il;log showrecords no launchd kill, so the sender is not yet identified.(The daemon has since been parked to remove this variable —
.scratch/llm-wiki-autopipeline/daemon/PARKED.md.)Expected behavior
The three fixes needed
toolResultfor the dangling call (e.g."worker shut down mid-call; turn aborted") so a re-attached session sees a complete tool exchange and resumes (the model can state the abort and continue).nohup/start_new_sessionchild the agent launched outlives the turn and dies orphaned when the worker's session is torn down; the worker should reap the child's tree so pidfiles/logs are left consistent, not half-written.received SIGTERMbut not the sender. Add asender=<pid>line so these ncidents are diagnosable in minutes, not hours.What is ruled out
Prime Agent version
Prime Agent 0.7.2
Environment
MacOS Sequoia 15.7.7, Qwen 3.8 27b, MTPLX haness, terminal in VS Code
Additional context
I am not a real developer. I'm a physician using AI to help me produce a communication app for my patients. Please understand I am doing the best I can. Thank you.
All reactions