Add an awaited terminal cancellation API for ACP prompts

Aperta
#1,760 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust, typescript

Direzione di ricerca

Inizia da crates/client/src/session.rs, packages/core/src/agent-os.ts e crates/agentos-actor-plugin/src/actions/session.rs per tracciare la cancellazione, i produttori di prompt e i risultati terminali. Usa gli scenari elencati di ritardo, ignoramento, autorizzazione, strumento, race condition, chiamate ripetute e actor/direct-client come test di accettazione. È completato quando entrambi i client e l’azione dell’actor espongono la parità, si attende la quiescence o l’hard-close e viene emesso esattamente un risultato terminale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

AgentOS currently exposes cancellation acknowledgement, not a reliable terminal/quiescence boundary.

When a prompt is pending, both clients resolve the local prompt and dispatch the real session/cancel in the background:

  • crates/client/src/session.rs — AgentOs::cancel_session
  • packages/core/src/agent-os.ts — AgentOs.cancelSession

The returned synthetic { via: "prompt-fallback" } result means only that cancellation was requested. It does not prove that the adapter stopped the turn, stopped emitting events, released tool/permission work, or can safely accept the next prompt.

The actor plugin also aborts its tracked prompt task before issuing cancellation in crates/agentos-actor-plugin/src/actions/session.rs. This can suppress the correlated terminal promptResult event, leaving callers without a clean completion signal.

A real Claude ACP reproduction acknowledged cancellation and appeared idle while the original turn remained active; an immediate follow-up then remained blocked for minutes. GigaCode currently compensates with a timer, an awaited session close, ACP-session recreation, and transcript handoff before reporting idle.

Proposed API

Expose an awaited terminal operation in both Rust and TypeScript, conceptually:

cancelPromptAndWait(sessionId, options?) ->
  { state: "quiescent", sessionReusable: true }
  { state: "closed", sessionReusable: false }
  { state: "timed_out", sessionReusable: false }

The exact naming and types can follow existing AgentOS conventions. If multiple in-flight turns become supported, the operation should also accept a turn/request ID.

Required semantics

  • Deliver ACP cancellation through a control/interrupt path that cannot queue behind the prompt being cancelled.
  • Do not discard the prompt producer before it publishes a terminal outcome.
  • Emit exactly one terminal prompt outcome: completed, cancelled, failed, or session closed.
  • Do not return quiescent until the old turn can no longer emit output, request permissions, run tools, or interfere with the next prompt.
  • Report whether the existing ACP session is reusable.
  • Support a bounded hard-cancel policy that closes the adapter session/process when cooperative cancellation does not quiesce.
  • Await adapter process teardown before returning closed.
  • Make repeated/concurrent cancellation calls idempotent.
  • Preserve parity between the Rust and TypeScript clients and the actor action surface.
  • Keep cancellation errors structured; do not collapse them into core/internal_error.

Acceptance tests

  • A delayed mock prompt cooperatively cancels, emits one cancelled terminal result, and the same session accepts an immediate follow-up.
  • An adapter that acknowledges but ignores cancellation reaches the deadline, is closed, and reports sessionReusable: false.
  • The hard-close path leaves no adapter process, prompt resolver, permission request, tool task, or event pump alive.
  • Cancellation while a permission request or tool call is pending settles that work before the API returns.
  • A completion racing cancellation still produces exactly one terminal result.
  • Repeated cancellation calls return a consistent result without duplicate cancellation/close operations.
  • Actor-backed and direct AgentOS clients pass the same lifecycle tests.

Outcome

Products should be able to report idle immediately after this operation returns without implementing their own cancellation timers, prompt listeners, process teardown, session recreation, or quiescence barriers.

Lingua principale
Rust
Stelle
4.8k
Fork
275
Merge medio
13h 12m
PR unite (30g)
51

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rivet-dev/agentos

Tutte le issue di rivet-dev/agentos

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.