Skip to content

Commit dc394cd

Browse files
committed
Fix stuck 'thinking' status after compaction or agent-end retry
After compaction_end with willRetry=true (or agent_end with willRetry), status is set to 'sending' and activity-phase to 'thinking', awaiting agent_start or auto_retry_start. The prompt-start-wait fallback timer (0.5s → idle) was only scheduled for user-sent prompts; server-initiated retries had no fallback. If the server never sends the expected event, the session remains stuck indefinitely. Call --begin-prompt-start-wait when status becomes 'sending' after compaction_end and agent_end, so the existing 0.5s fallback resets to idle if no agent_start/auto_retry_start arrives.
1 parent c64c72a commit dc394cd

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

pi-coding-agent-render.el

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,14 @@ follow-up as a fresh prompt.")
644644
(skip-chars-backward "\n")
645645
(delete-region (point) (point-max))
646646
(insert "\n"))))
647-
(pi-coding-agent--set-activity-phase
648-
(if (eq pi-coding-agent--status 'sending) "thinking" "idle"))
647+
(if (eq pi-coding-agent--status 'sending)
648+
(progn
649+
;; Pi will retry (auto_retry or compaction retry).
650+
;; Begin prompt-start-wait so the fallback timer resets to idle if
651+
;; no agent_start/auto_retry_start arrives.
652+
(pi-coding-agent--begin-prompt-start-wait)
653+
(pi-coding-agent--set-activity-phase "thinking"))
654+
(pi-coding-agent--set-activity-phase "idle"))
649655
(pi-coding-agent--refresh-header)
650656
;; Give immediate post-run compaction/retry events a chance to arrive before
651657
;; turning a local follow-up into a new independent prompt.
@@ -771,7 +777,11 @@ Status transitions are handled by `pi-coding-agent--update-state-from-event'."
771777
;; Pi is either retrying automatically or resuming a prompt whose
772778
;; preflight compacted first. Keep local follow-ups behind that
773779
;; Pi-owned work.
774-
(pi-coding-agent--set-activity-phase "thinking"))
780+
(pi-coding-agent--set-activity-phase "thinking")
781+
;; Server-initiated retry has no user-owned prompt-start-wait.
782+
;; Begin one so the fallback timer resets to idle if agent_start
783+
;; never arrives (e.g. server bug, network issue).
784+
(pi-coding-agent--begin-prompt-start-wait))
775785
(pi-coding-agent--set-activity-phase "idle")
776786
(pi-coding-agent--schedule-followup-queue-processing)))
777787
(t

0 commit comments

Comments
 (0)