You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9e58ca9
Browse filesBrowse the repository at this point in the historyBrowse files
Mark Pollack
committed
Answer a prompt the handler does not: cancel grace period and maximum duration
Two limits on a session/prompt, configurable on the agent builders
(AcpAgent.async/sync and AcpAgentSupport) and as PromptTimeouts on the
AcpAgentSession constructor:
- cancelGracePeriod, default 60 s: if the handler has not answered that
long after session/cancel, the session cancels the handler's
subscription and answers stopReason cancelled itself, which ACP v1
requires of a cancelled prompt and which ends the turn.
- maxPromptDuration, off by default: when a prompt runs that long, the
session cancels the handler and answers JSON-RPC error -32800 (request
cancelled, which ACP v1 Cancellation asks of an internally cancelled
request such as an internal timeout), or cancelled when the prompt was
already being cancelled.
Duration.ZERO turns either off; negative or null is rejected. The
forced answer takes the normal path: the turn is released just before
it is published, and it is queued behind every update the handler had
sent. The timers run on the shared timeout timer and deliver on its
delivery threads; no new threads.
PromptAnswer decides who answers in one atomic step, so the handler's
answer racing a timer gives exactly one response. PromptAnswerLincheckTest
model checks the handler, a cancel, the grace timer and the max timer
(at most one answer, turn released once answered) and a cancel racing
the deadlines' set-up (the grace period still starts, once); both fail
when the guard or the re-check is removed. The behaviour tests run on a
virtual clock and failed with the deadlines switched off; an end-to-end
test shows the forced answer arriving after the handler's update.
Copy file name to clipboardExpand all lines: acp-agent-support/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ This module transitively includes `acp-annotations` and `acp-core`.
62
62
|`@LoadSession`|`session/load`| Loads an existing session by ID. |
63
63
|`@Prompt`|`session/prompt`| Handles user prompts within a session. |
64
64
|`@SetSessionMode`|`session/set_mode`| Changes the operational mode of a session. |
65
-
|`@Cancel`|`session/cancel`| Handles cancellation notifications (fire-and-forget). The cancel does not end the prompt turn: the cancelled `@Prompt` method still returns, with stop reason `cancelled`, and the session rejects a new prompt until it has. |
65
+
|`@Cancel`|`session/cancel`| Handles cancellation notifications (fire-and-forget). The cancel does not end the prompt turn: the cancelled `@Prompt` method still returns, with stop reason `cancelled`, and the session rejects a new prompt until it has, or until the cancel grace period (default 60 s, `cancelGracePeriod`) passes and the agent answers `cancelled` itself. |
@@ -801,6 +837,37 @@ public SyncAgentBuilder requestTimeout(Duration timeout) {
801
837
returnthis;
802
838
}
803
839
840
+
/**
841
+
* Sets how long a prompt handler has to answer after {@code session/cancel}. When it
842
+
* passes, the agent cancels the handler (a sync handler blocked on its thread is not interrupted; what it sends afterwards is its own) and answers the prompt itself with stop
843
+
* reason {@code cancelled}, as ACP requires of a cancelled prompt, which ends the
844
+
* turn so the session accepts a new prompt. Updates the handler sent before that
845
+
* answer reach the client first. Default: 60 seconds
0 commit comments