Repository navigation
fix(workspace): honor an explicit max_live_stateful_mcps of 0 - #2741
Merged
qbc2016 merged 2 commits intoNov 10, 2026
Merged
Conversation
The constructor used `max_live_stateful_mcps or max(...)`, so an explicit 0 was discarded and replaced by the derived default, making "no stateful instance is retained for other scopes" unconfigurable. Derive only when the argument is None.
The review guide asks for assertions that compare an entire data structure, so the zero/one/None expectations are checked as a single table instead of three separate scalars.
zuizhuai
pushed a commit
to zuizhuai/agentscope
that referenced
this pull request
Nov 10, 2026
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.
Closes #2738
AgentScope Version
2.0.8(src/agentscope/_version.py), branch cut frommain@226daf0, Python 3.12.11.Description
WorkspaceBase.__init__fell back withor:0is falsy, so an explicitmax_live_stateful_mcps=0was indistinguishable from "argument not given" and was replaced by the derived default. The one value that means "retain no stateful MCP instance for another scope" could not be configured, while every other value is passed straight through — including-1, which is meaningless but survives. That asymmetry is what makes it a bug rather than an undocumented choice.The change derives a cap only when the argument is
None; an explicit value is used as given, and the constructor docstring now says so._enforce_mcp_capacityneeds no change: with a cap of0it immediately stops sparing other scopes, and when every live instance belongs to the caller it logs the existing "exceeding max_live_stateful_mcps" warning and lets the caller through — i.e. the documented "the requesting scope always gets its full set" behaviour is preserved.Design alternatives considered:
0(or non-positive values) with aValueError. Rejected: the argument is typedint,-1already works, and raising would add a new failure mode without removing the asymmetry.0means the derived default". Rejected: the docstring already frames derivation as theNonecase, and a silent override of an explicitly passed cap is the surprising reading.How to test
RED — the new test against the unpatched package (a
maincheckout shadowing the installed one), which fails on behaviour rather than on a mock:PYTHONPATH=/path/to/base/checkout/src python -m pytest tests/workspace_local_test.py -k zero_stateful_cap -q # E AssertionError: {'cap=0': 40, 'cap=1': 1, 'cap=None': 40} != {'cap=0': 0, 'cap=1': 1, 'cap=None': 40}GREEN — this branch:
Lint:
black --line-length=79,flake8 --extend-ignore=E203,mypyandpylintwere run at the versions and with the exact arguments pinned in.pre-commit-config.yaml; all four are clean on both changed files.pre-commit run --all-filesitself could not run in this environment (the hook environments need to be downloaded), and the Docker / E2B / Daytona / Kubernetes workspace modules were not executed locally — both are left to the CI runs on this PR.Checklist
Please check the following items before code is ready to be reviewed.
triage/confirmed, claimed via/assignmax_live_stateful_mcps, and no example underexamples/passes it, so there is no doc change to make; leaving the box unchecked rather than claiming oneAuthorship disclosure: this PR was written autonomously by an AI agent, and no human read the diff before submission. The measurements above were taken by that agent on the machine described and are reproducible with the commands given;
CONTRIBUTING.md§2 was followed in that the change is atomic (2 commits, +44/−4) and keeps the repository's conventions.