Repository navigation
Conversation
The declarative subagent path built its local filesystem spec from three fields — project, mode and additionalRoots — and dropped everything else, including the isolation scope. A parent configured with IsolationScope.AGENT therefore handed the subagent a spec with no scope at all, which falls back to USER: every subagent path got prefixed with the user id, into a layout the parent had never configured. The command timeout, the output cap, the environment, the env-inheritance, project-writable, shared-root and path-mode flags were lost in the same way, and an overriding spec subclass degraded to the base type. Add LocalFilesystemSpec.copy(), which carries every field and preserves the concrete type through newInstance() so a subclass that carries its own state can extend it, and delegate the subagent clone to it. Copying fields by name at the call site is how a field added to the spec ends up silently dropped for every subagent. Build the context workspace namespace from the configured isolation scope as well, instead of assuming a per-user prefix; the main workspace already did.
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.
Background
An ISOLATED declarative subagent is supposed to run under its parent's filesystem policy and only get its own workspace root. It did not.
HarnessAgentBuilderSupport.cloneLocalSpecForSubagentrebuilt the spec from three fields:Everything else was dropped. The visible one is
isolationScope: the clone carriesnull, andHarnessAgent.Builder.build()falls back toIsolationScope.USER, so a parent configured withIsolationScope.AGENTgot subagent paths prefixed with the user id — a directory layout the parent never configured. The command timeout, the output cap, the environment map, env-inheritance,projectWritable,sharedLocalWorkspaceand the concrete spec type were lost the same way.A second place assumed the same thing: the context workspace in
workspaceForhardcodedwhile the main workspace already used
fsIsolationScope.toNamespaceFactory(). So even with the clone fixed, the two workspaces of one agent would be laid out under different rules.Change
LocalFilesystemSpec.copy()— copies every policy field and preserves the concrete type through a protectednewInstance(), so a subclass that carries its own state can extend the copy instead of silently degrading to the base type. Five read accessors for fields that had none (getExecuteTimeoutSeconds,getMaxOutputBytes,getEnv,isInheritEnv,isSharedLocalWorkspace) so the copy is assertable and the subagent path does not need to guess.cloneLocalSpecForSubagentdelegates tocopy(). Copying fields by name at the call site is how a field added to the spec ends up dropped for every subagent; one call is one place to keep current.nsFactorythe main workspace uses.The subagent still gets its own workspace root, so its memory and sessions stay isolated — that difference is what the workspace argument is for.
Tests
SubagentSpecInheritanceTest, two cases:isolationScope(AGENT), a 7 s timeout, a 1234-byte output cap, an env entry,inheritEnv,projectWritable,sharedLocalWorkspaceand an extra root keeps all of it after the clone;copy()on a subclass returns the subclass, so an integrating application's spec still overrides.Red without the fix, with the previous three-field body restored (
expected: <AGENT> but was: <null>):Green with it, and the whole harness module:
No configuration or migration changes;
copy()and the accessors are additive.Closes #4023