[Bug]: ACP replacement prompt can erase an unacknowledged terminal receipt and wedge the persistent host
Summary
A transient OMP ACP session/prompt rejection can become a persistent AO host acknowledgment wedge. Once a second prompt is attempted before the first terminal result is acknowledged, the second host-local rejection overwrites the ACP adapter's terminalEventID. A subsequent acknowledgment of the original, durably committed result silently returns nil without sending _ao/persistent_prompt_ack. The persistent host retains its pending result and rejects every later prompt with:
{"code":-32602,"message":"previous ACP prompt is active or not acknowledged"}
I reproduced this with the real AO ACP adapter, real persistent host and real ACP SDK, using an isolated deterministic provider process. No OMP or model API is needed to reproduce the AO defect. Timely acknowledgment is the passing control.
Environment
- Windows 11 x64.
- Installed desktop:
0.13.4-nightly.202610031727, release commita2a8917c22e2246bf63b98e06a97c417f3b3fb76. - Installed OMP reports
omp/18.6.0at investigation time. This is not a captured version handshake from the original long-lived provider process. - Reproducer executed against upstream
b2461dc5955bb11b4ee1213871e6a2157e68da0e, ACP Go SDKv0.13.5. - Compared the installed release with this revision:
acp/conversation.goandpersistenthost/acp_relay.goare unchanged.
Observed incident
Sanitized UTC timeline from a read-only query of AO's conversation_turns and conversation_provider_events. No user prompts, credentials or raw session dumps are included.
| Time, 2026-10-04 | Recorded event |
|---|---|
| 07:36:26.405 | Previous turn completes as interrupted |
| 07:36:32.714 | A steer delivery is durably rejected as no_active_turn |
| 07:36:32.770 | Replacement turn has already been bound/started in conversation_turns |
| 07:36:32.777 | Original prompt failure is archived with code -32003, providerData.reason=session_busy, and a nonempty ao.persistentEventId |
| 07:36:32.804 | Replacement fails with AO's -32602 acknowledgment error, no provider event ID |
| Through 07:52:37.045 | Eleven subsequent host-local acknowledgment rejections observed in total, including the replacement |
The raw OMP error was:
{"code":-32003,"message":"Agent is already processing. Use steer() or followUp() to queue messages, or wait for completion.","data":{"reason":"session_busy","hint":"steer|followUp|wait"}}
AO wraps its error data with ao.persistentEventId and providerData. The busy failure was durably archived with the same event ID, so this is not simply a missing event ID on error responses.
Confirmed mechanism
References pinned to the reproduced revision:
acp_relay.go:361-376retains the provider terminal response inPendingResultEventID, including errors.acp_relay.go:219-220rejects a new prompt while that receipt is outstanding. This host-local rejection has no persistent event ID.conversation.go:619-624extracts the original error's event ID correctly. ButfinishPrompt:682-705unconditionally assignsc.terminalEventID = eventIDfor every completion and releases the turn before the controller's durable acknowledgment.- A replacement's host-local error therefore assigns
terminalEventID = "". AcknowledgeProviderEvent:984-993silently returns nil when the original receipt no longer matches that mutable field. The host never receives its ACK and stays blocked.
Production entry path to investigate
[INFERENCE] The incident's rejected steer followed by a replacement dispatch is consistent with the SteerOrSend fallback race:
SteerOrSend:455-527holdssendMu, receivesErrNoActiveTurn, and callssendLocked(ctx, msg, false), bypassing the normal busy queue.- The driver may have released
activeTurn, while the controller has not yet committed/acknowledged its terminal event. Controller.project:2541-2579needs that samesendMubefore it can project and acknowledge terminal events.- A fast replacement rejection can overwrite the receipt before projection gets the lock.
The diagnostic below forces this ordering at the public driver boundary; it does not claim to have replayed the complete HTTP/controller scheduling of the live incident.
Deterministic reproduction
In a checkout of the revision above, place the program below at backend/cmd/acp-busy-probe/main.go, then run:
cd backend
go run ./cmd/acp-busy-probe
It uses fresh temporary data, terminates its own provider host and removes its scratch state. It does not access an existing AO installation's data or any model service.
Observed output:
delayed=false first: state=failed event_id_present=true typed_busy=true
delayed=false second: state=completed event_id_present=true error=<nil>
delayed=true first: state=failed event_id_present=true typed_busy=true
delayed=true second: state=failed event_id_present=false error=ACP session/prompt: {"code":-32602,"message":"previous ACP prompt is active or not acknowledged"}
late original ACK returned nil
third after original ACK: state=failed error=ACP session/prompt: {"code":-32602,"message":"previous ACP prompt is active or not acknowledged"}
CONFIRMED: delayed ACK is silently lost after a subsequent host-local prompt rejection
Standalone diagnostic program
package main
import (
"bufio"
"context"
"encoding/json"
"fmt"
"os"
"strings"
"time"
"github.com/aoagents/agent-orchestrator/backend/internal/adapters/chatdriver/acp"
"github.com/aoagents/agent-orchestrator/backend/internal/adapters/chatdriver/persistenthost"
"github.com/aoagents/agent-orchestrator/backend/internal/domain"
"github.com/aoagents/agent-orchestrator/backend/internal/ports"
)
func must(err error) { if err != nil { panic(err) } }
func provider() {
scanner := bufio.NewScanner(os.Stdin)
prompts := 0
for scanner.Scan() {
var req struct { ID json.RawMessage `json:"id"`; Method string `json:"method"` }
must(json.Unmarshal(scanner.Bytes(), &req))
if len(req.ID)==0 { continue }
var result any = map[string]any{}
switch req.Method {
case "initialize": result = map[string]any{"protocolVersion":1,"agentCapabilities":map[string]any{},"agentInfo":map[string]string{"name":"busy-probe","version":"1"}}
case "session/new": result = map[string]any{"sessionId":"probe-session"}
case "session/prompt":
prompts++
if prompts==1 {
must(json.NewEncoder(os.Stdout).Encode(map[string]any{"jsonrpc":"2.0","id":req.ID,"error":map[string]any{"code":-32003,"message":"Agent is already processing. Use steer() or followUp() to queue messages, or wait for completion.","data":map[string]any{"reason":"session_busy","hint":"steer|followUp|wait"}}}))
continue
}
result=map[string]any{"stopReason":"end_turn"}
}
must(json.NewEncoder(os.Stdout).Encode(map[string]any{"jsonrpc":"2.0","id":req.ID,"result":result}))
}
}
func turn(ctx context.Context, conv ports.ChatConversation) ports.ChatEvent {
ref,err:=conv.SendTurn(ctx,ports.ChatUserMessage{Text:"diagnostic"}); must(err)
must(conv.(ports.ChatDeferredTurnStarter).StartDeferredTurn(ref.ProviderTurnID))
var terminal ports.ChatEvent
for {
select {
case e:=<-conv.Events():
if e.Kind==ports.ChatEventTurnCompleted { terminal=e }
if terminal.Kind!="" && e.Kind==ports.ChatEventControllerState && e.ControllerState==ports.ChatControllerReady { return terminal }
case <-ctx.Done(): panic(ctx.Err())
}
}
}
func run(delayed bool) {
ctx,cancel:=context.WithTimeout(context.Background(),20*time.Second); defer cancel()
dir,err:=os.MkdirTemp("","ao-acp-busy-probe-");must(err);defer os.RemoveAll(dir)
exe,err:=os.Executable();must(err)
driver:=acp.New(acp.Config{Harness:domain.AgentHarness("omp"),Launch:func(context.Context,acp.LaunchConfig)(acp.Launch,error){return acp.Launch{Command:exe,Args:[]string{"provider"}},nil}},nil)
conv,err:=driver.Start(ctx,ports.ChatStartConfig{SessionID:"probe",DataDir:dir,WorkspacePath:dir});must(err)
defer conv.(ports.ChatProviderTerminator).Terminate()
ack:=conv.(ports.ChatProviderEventAcknowledger)
first:=turn(ctx,conv)
if first.Err==nil || !strings.Contains(first.Err.Error(),"session_busy") || first.ProviderEventID=="" { panic("busy fixture failed") }
fmt.Printf("delayed=%v first: state=%s event_id_present=%v typed_busy=%v\n",delayed,first.TurnState,first.ProviderEventID!="",strings.Contains(first.Err.Error(),"session_busy"))
if !delayed { must(ack.AcknowledgeProviderEvent(ctx,first.ProviderEventID)) }
second:=turn(ctx,conv)
fmt.Printf("delayed=%v second: state=%s event_id_present=%v error=%v\n",delayed,second.TurnState,second.ProviderEventID!="",second.Err)
if delayed {
if second.Err==nil || !strings.Contains(second.Err.Error(),"not acknowledged") { panic("missing host rejection") }
must(ack.AcknowledgeProviderEvent(ctx,first.ProviderEventID))
fmt.Println("late original ACK returned nil")
third:=turn(ctx,conv)
if third.Err==nil || !strings.Contains(third.Err.Error(),"not acknowledged") { panic("expected wedged result") }
fmt.Printf("third after original ACK: state=%s error=%v\n",third.TurnState,third.Err)
} else {
if second.TurnState!=domain.TurnStateCompleted { panic("timely ACK did not recover") }
must(ack.AcknowledgeProviderEvent(ctx,second.ProviderEventID))
}
}
func main() {
if len(os.Args)>1 && os.Args[1]=="provider" {provider();return}
if len(os.Args)>1 && os.Args[1]=="chat-host" {
must(persistenthost.Run(context.Background(),persistenthost.Config{SessionID:os.Args[2],DataDir:os.Args[3],Workdir:os.Args[4],Protocol:persistenthost.Protocol(os.Args[5]),OwnershipFingerprint:os.Args[6],Argv:os.Args[8:],Env:os.Environ()}));return
}
run(false)
run(true)
fmt.Println("CONFIRMED: delayed ACK is silently lost after a subsequent host-local prompt rejection")
}
Expected repair and acceptance
- Keep a pending durable terminal receipt acknowledgeable until its matching ACK has been delivered. A later local rejection must not erase it.
- Serialize replacement dispatch with terminal projection/acknowledgment, including the
SteerOrSendno-active-turn fallback. Do not bypass the host guard or acknowledge before durable commit. - Regression coverage should delay terminal projection while a steer loses the active-turn race, attempt the replacement, then commit/ACK the original result. A subsequent prompt must reach the provider and complete exactly once.
- Cover both successful and failed original terminal results, plus a replacement error with no persistent event ID.
- Preserve restart replay and the guarantee that uncommitted results are not discarded.
Relation to OMP and existing work
OMP's original busy rejection is separately documented in https://github.com/can1357/oh-my-pi/issues/10707 and https://github.com/can1357/oh-my-pi/issues/9157. The upstream discussion treats session_busy as transient and explains why blindly steering a new ACP prompt into an ownerless autonomous turn is unsafe. This report concerns AO losing its own acknowledgment, not changing OMP's response ownership semantics.
#6215 addresses reconnect replay queue overflow and an unreleased transport socket. This reproduction requires neither a restart nor a replay burst and identifies a different receipt-lifetime bug.
Investigation only. No production source changes or live-session restart were made.
Assigned to @ApexYash11
Additional human report (relayed by the user)
One of the user's AO agents encountered repeated errors in the Chat UI. Switching that session to TUI and back to Chat restored it. The user provided a screenshot showing the error:
ACP session/prompt: {"code":-32602,"message":"previous ACP prompt is active or not acknowledged"}
The screenshot also shows the error after a retry and a later short message. It contains private task and repository context, so I have transcribed the error rather than posting the unredacted image.
Agent-collected evidence
Read-only checks on the affected macOS installation, collected 2026-10-07 around 04:14 UTC:
which aoresolved to/Applications/Agent Orchestrator.app/Contents/Resources/daemon/ao;ao versionreturneddev. The desktop app'sCFBundleShortVersionStringwas0.13.4-nightly.202610060624.ao statusreported the app-owned daemon ready on port 3001, with run file~/.ao/running.jsonand data directory~/.ao/data.ao session get smarthow---octa-28 --jsonidentified the affected worker as using theclaude-codeharness. This differs from the OMP reproduction in the issue body.- A read-only SQLite query against the installation's
~/.ao/data/ao.db, selecting only timestamps, turn state, and error message fromconversation_turnsfor that session, found failed turns requested at 04:05:28, 04:05:41, and 04:07:03 UTC on 2026-10-07. Each recorded the exact-32602error above. - A read-only query of
session_interface_transitionsfor the same session found Chat→TUI (interrupt) completed at 04:08:07 UTC, then TUI→Chat (drain) completed at 04:09:08 UTC. A later turn requested at 04:09:27 UTC was recorded ascompleted.
These records corroborate the repeated failure and recovery after changing interfaces. They do not establish that this incident followed the same acknowledgment-loss path as the OMP reproduction; no safe reproduction or provider trace was captured for this Claude Code session.