Skip to content

fix(protocol): serialize concurrent task submissions - #3643

Open
pengmoubuaixuexi wants to merge 1 commit into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/protocol-submit-idempotency
Open

pengmoubuaixuexi wants to merge 1 commit into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/protocol-submit-idempotency

Conversation

@pengmoubuaixuexi

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT, based on main c3959cea69c40e2c44fd2365dfbdeed4bc53e951.

Description

Fixes #3642.

Two concurrent submit calls with the same task ID can both observe no running future and schedule an agent run, despite the documented idempotency contract. A persisted PENDING record does not prevent the second submission from passing the check before the first future is registered. This can duplicate model/tool execution and leave only one of the runs addressable by task ID.

Use the existing per-task monitor (already used by resume) around the submission checks, pending persistence and future registration. Actual agent execution remains asynchronous; different task IDs retain independent registration. Keep the existing identity-based future cleanup and terminal-task rejection behavior. Update the English and Chinese protocol guides to state the single-instance scope.

The regression pauses the first PENDING save after it reaches a real temporary workspace repository. A second submission then either completes registration on the old code or blocks on the first thread's task monitor after the fix. The agent stream is held open until assertions finish. A separate different-ID case requires the second submission to finish before the first save is released, guarding against accidental global serialization. Completion and rejection of a completed ID are also checked.

Validation

Java 17.0.20.1, Maven 3.9.12, Windows, from the repository root:

mvn -B -T1 -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agent-protocol -am -Dtest=AgentProtocolTaskStoreConcurrentSubmitTest -Dsurefire.failIfNoSpecifiedTests=false spotless:apply test
mvn -B -T1 -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agent-protocol -am "-Dtest=AgentProtocol*Test,WorkspaceProtocolTaskRepositoryTest" -Dsurefire.failIfNoSpecifiedTests=false spotless:apply test
mvn -B -T1 -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agent-protocol -am spotless:check
  • Final regression tests with the original production implementation: 2 tests, 1 failure (one registration per logical task ==> expected: <1> but was: <2>); the different-ID control passes.
  • Fixed implementation: all 35 protocol module tests pass, including existing HITL resume tests; no failures, errors or skips.
  • Spotless and git diff --check pass.
  • In docs/, npm test: 13 pass; npm run validate: passes (430 pages, 584 redirects plus Mintlify build validation).
  • npm run broken-links: exits 1 with 2,208 reported links in 326 files. Re-running with the original EN/ZH pages gives the same file/link entries; no new reports from this change.

Scope: coordination within one AgentProtocolTaskStore, not cross-replica exactly-once execution. This reuses the existing task-lock registry and its lifecycle; cancellation and persisted-task recovery semantics are unchanged. Full-repository clean verify and real-model/HTTP integration tests were not run.

AI assistance: investigation, implementation and test execution were performed with Codex. The final diff was checked against the reproduction and the validation above; this is not a claim of independent human review.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test) — all 35 protocol module tests pass; full-repository suite not run
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated
  • Code is ready for review

Copilot AI balanced review requested due to automatic review settings October 18, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Concurrent protocol submissions with the same task ID can start duplicate runs

2 participants