Skip to content

fix(protocols): recheck session admission after asynchronous eviction - #1036

Open
Yzzz88 wants to merge 1 commit into
modelscope:mainfrom
Yzzz88:fix/session-store-admission-race
Open

Yzzz88 wants to merge 1 commit into
modelscope:mainfrom
Yzzz88:fix/session-store-admission-race

Conversation

@Yzzz88

@Yzzz88 Yzzz88 commented Oct 30, 2026

Copy link
Copy Markdown

Change Summary

Concurrent ACP/A2A admission can exceed the configured store capacity while an idle agent is being cleaned up. Cleanup removes the old entry before awaiting cleanup_tools; another request can fill that slot before the original request resumes. With a capacity of one, two distinct requests both finish admission and keep running entries in the store.

For A2A, concurrent get_or_create calls for the same new task ID can also construct different agents and overwrite one entry. The callers retain different agents for the same task and the overwritten agent is no longer owned by the store.

Recheck capacity after each awaited eviction. Also recheck A2A task identity before building a replacement. Agent construction and insertion remain synchronous, so these repeated checks cover the actual yield boundary without introducing a lock or changing public interfaces.

Related issue number

No existing issue identified. Reproduced against main 6d90d84 (MS-Agent 1.6.0).

Validation

python -B -m pytest tests/test_session_store_concurrency.py tests/test_a2a/test_a2a_unit.py tests/test_acp/test_acp_unit.py -q -p no:cacheprovider -o asyncio_default_fixture_loop_scope=function
  • Before: 3 failed, 84 passed. Failures cover ACP/A2A over-admission and duplicate A2A task construction.
  • After: 87 passed. The seven added cases also cover cancellation during eviction and ordinary idle replacement for both protocols.
  • Changed source files pass flake8 7.3.0, isort 5.13.2 and yapf 0.32.0 checks. git diff --check passes.
  • Production store, eviction and configuration-update code is exercised; AgentLoader.build and agent cleanup are controlled to expose the interleaving. No model requests, MCP subprocesses, network services or end-to-end protocol deployment were used.
  • All applicable pre-commit hooks pass on the three changed files. A full-repository run was performed in an isolated copy; it reports existing lint and formatting failures in unrelated files, including E128 in .dev_scripts/webui/oss_distribution.py and E305 in ms_agent/config/skills_manager.py. These files were verified unchanged against HEAD. No unrelated formatter changes are included. Remote CI has not yet run.

Checklist

  • The pull request title summarizes the change.
  • Regression tests for the change exist.
  • Full-repository pre-commit passes: hooks were installed and the full run was attempted, but existing unrelated baseline failures remain. All applicable hooks pass for this change.
  • No public API or configuration behavior changes require documentation updates.

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.

1 participant