Repository navigation
fix(controlplane): let failed managed turns be cancelled to release the session - #4033
Merged
juruoO-o merged 1 commit intoNov 11, 2026
Merged
Conversation
…he session A managed turn that fails is terminal in the public API, but the dataplane keeps it ahead of later turns until it is resumed or cancelled. The control plane rejected every command on terminal invocations and never forwarded cancellation, so later turns in the Session stayed queued forever. Accept /cancel for a failed public Turn whose dataplane turn is still failed, forward it to the dataplane, and list cancel in available_commands. The public Turn keeps its failed status and no tool call is replayed. Other commands on such a Turn now point to cancel instead of suggesting a new invocation. Fixes agentscope-ai#4011 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
juruoO-o
approved these changes
Nov 11, 2026
juruoO-o
left a comment
Collaborator
There was a problem hiding this comment.
已核对 failed Turn 的能力查询、命令接收、ScheduleInvocation 唤醒、后台 processServiceCommands 以及数据面 cancel 路径。仅允许丢弃仍在阻塞队列的 failed native turn,公共终态保持 failed,没有重开终态或重放工具。实现范围合理,未发现阻塞问题。本轮为调用链审查,未运行真实数据面端到端测试。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.1.0-SNAPSHOT (
mainat85fa9a60)Description
A managed Turn that fails (model error, budget exceeded, max iterations) is terminal in the public Session API, but the dataplane still holds it ahead of later Turns until it is resumed or cancelled (
SessionTurnCommandRepository.findDispatchable). The control plane gave no way to release it:createServiceCommandrejected every command on a terminal invocation with409 invocation has ended;requestServiceCancellationreturned early for terminal invocations, socancelnever reached the dataplane;resumeonly acceptsinterrupteddataplane turns, and the projection stops refreshing terminal invocations.As a result every later Turn in the Session stayed
queuedforever.This PR adds an explicit discard path in the control plane. Neither state machine changes:
failedand its dataplane turn is stillfailed, accept/canceland forward it to the dataplane/turns/{id}/cancel. That endpoint already runscancelPendingand moves the turn tocancelled, which releases the Session queue.failedstatus. No terminal state is reopened and no tool call is replayed./capabilitieslistscancelinavailable_commandsfor such a Turn.cancelinstead of suggesting a new invocation.service/session-event-logpages describe the discard step.Resuming a failed Turn would require reopening a terminal invocation and its projection, so it is out of scope here.
Validation
TestPublicManagedSessionCancelDiscardsFailedTurnwalks through the whole path with a fake dataplane: failure is projected, onlycancelis offered,resumegets 409,cancelgets 202, the sweep forwards exactly one dataplane cancel, the command completes, the Turn staysfailed, and a secondcancelgets 409. It fails onmainwithout this change.go test -p 1 ./...andgo vet ./...inservice-controlplanepass against PostgreSQL 17 withCONTROL_PLANE_TEST_POSTGRES_DSNset, matching the service source check workflow.gofmt -lis clean.cancel()handling offailedturns was read but not exercised end to end against a live deployment. Documentation checks (npm test,npm run validate) were not run locally.Fixes #4011
Checklist
gofmt; no Java files changed, somvn spotless:applydoes not apply)go test -p 1 ./...inservice-controlplane;mvn testnot affected)AI assistance: developed with help from Claude Code. I reviewed the change, and the checks listed under Validation were run locally.