Repository navigation
fix(harness): isolate subagent sandbox contexts and reject GLOBAL sandbox subagents (port to 2.0.x) - #4581
Open
Ernest-L wants to merge 2 commits into
Open
fix(harness): isolate subagent sandbox contexts and reject GLOBAL sandbox subagents (port to 2.0.x)#4581Ernest-L wants to merge 2 commits into
Ernest-L wants to merge 2 commits into
Conversation
…dbox subagents (port to 2.0.x) Port jujn's 3181063 (merged to main via agentscope-ai#4441) to the 2.0.x line: - DefaultAgentManager: extract childContext(sessionId, userId, parent) and strip the framework-default AbstractFilesystem and SandboxContext inherited from the parent runtime context (caller-managed externalSandbox / externalSandboxState sharing is preserved), so an ISOLATED declared subagent installs its own sandbox context and workspace projection instead of silently reusing the parent's; adapted to 2.0.x where the context construction is inlined in invokeAgent / invokeAgentStream and lacks the main-era typed-attribute strips - HarnessAgent.build: fail fast with IllegalStateException when GLOBAL sandbox isolation is combined with subagents (a nested child would block on the lease its parent holds for the whole call) - new tests: DefaultAgentManagerSandboxContextTest, HarnessAgentGlobalSandboxSubagentTest; adapted to 2.0.x (no journalEnabled builder, MiddlewareBase is an interface without activePoints, projection entry uses the literal __workspace_projection__ key) - docs: GLOBAL sentences rewritten from 'blocks on the lease' to 'rejected at build time'; subagent.md notes the new isolation behavior Unlike the original commit, the doc paragraphs are kept (not deleted) and updated to match the new behavior, keeping 2.0.x and mainline in lockstep per juruoO-o's review.
The parameterized workspaceForKeepsSandboxHostRoutingAndConfiguredNamespace test enumerates all IsolationScope values; with the new build-time rejection the GLOBAL parameter now asserts the IllegalStateException instead of building an agent (mainline removed this test before the rejection landed, which is why upstream CI did not hit it).
Contributor
Author
|
Companion mainline PR for the doc restore + coverage test lost in the #4441 squash: #4582 (@jujn for review/merge). It restores the rollout guidance juruoO-o asked for, rewrites the stale |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
Author
|
@juruO-o friendly ping for review when convenient — this ports jujn's 3181063 to 2.0.x (see description for what and why, including how the doc handling differs from the original commit). |
This branch has not been deployed
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.
@juruO-o — heads-up that jujn's 3181063 (merged to main via #4441) had not reached
2.0.x: #4520 was cut before that commit existed on the PR branch. This PR ports it,
while keeping the rollout guidance you asked for in the 2.0.x docs (the
GLOBALsentences are updated to the new build-time rejection behavior instead of the original
commit's deleted "blocks on the lease" wording).
What this ports
3181063 (jujn, merged to main via #4441) for code and tests:
DefaultAgentManager— extractschildContext(sessionId, userId, parent)and stripsthe framework-default
AbstractFilesystemandSandboxContextinherited from theparent runtime context (caller-managed
externalSandbox/externalSandboxStatesharing is preserved), so an ISOLATED declared subagent installs its own sandbox
context and workspace projection instead of silently reusing the parent's. Adapted to
2.0.x, where the context construction is inlined in
invokeAgent/invokeAgentStreamand lacks the main-era typed-attribute strips;HarnessAgent.build— fails fast withIllegalStateExceptionwhenGLOBALsandboxisolation is combined with subagents (a nested child would block on the lease its
parent holds for the whole call);
DefaultAgentManagerSandboxContextTest,HarnessAgentGlobalSandboxSubagentTest.Doc handling (differs from the original commit)
The original commit deleted the four doc paragraphs added by #4441 — two
GLOBALsentences in them were stale after this change ("blocks on the lease"), while the rest
was still valid. On 2.0.x this PR keeps the paragraphs and instead rewrites the
GLOBALsentences to "rejected at build time", and adds the new isolation behavior tothe
subagent.md"Sandbox mode" note — keeping mainline and 2.0.x in lockstep. Acompanion PR to
mainrestores the same guidance there (cross-referenced).Tests
mvn clean verifyon this branch with the CI Windows flags(
-Djacoco.skip=true -DskipDurableWindowsTests=true): 114 modules,11,890 tests, 0 failures, 0 errors, including the two ported test classes;
HarnessAgentTest#workspaceForKeepsSandboxHostRoutingAndConfiguredNamespacewasadapted: its
@EnumSourceenumerates allIsolationScopevalues, and theGLOBALparameter now asserts the build-time
IllegalStateException(this test no longerexists on mainline, which is why upstream CI did not hit the rejection).
Compatibility
GLOBAL+ subagents now fails at buildtime (previously it deadlocked at runtime under a serializing guard — see fix(sandbox): scope the execution guard key by agent for USER isolation (backport to 2.0.x) #4520's
fix and [Bug]: Declared subagent spawned inside a sandboxed call self-deadlocks on SandboxExecutionGuard (USER/GLOBAL scope) #4440), which is the documented unsupported combination.
Related