Honor cwd for native subagent spawns#81896
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. source-reproducible: current main exposes and reads Real behavior proof Next step before merge Security Review detailsBest possible solution: Land this narrow cwd-threading fix after maintainer review, green focused checks, and redacted runtime proof showing a native child Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main exposes and reads Is this the best way to solve the issue? Yes for the code shape: forwarding What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against bea4f0d2f4b4. |
03f57bf to
41b8c6f
Compare
martingarramon
left a comment
There was a problem hiding this comment.
The workspace-resolution refactor is clean. toolSpawnMetadata is moved earlier so spawnedWorkspaceDir can be resolved once and shared between materializeSubagentAttachments and normalizeSpawnedRunMetadata — eliminates the prior duplication where resolution happened inline only for metadata, leaving attachments without access to the resolved path.
Precedence chain is correct: explicitWorkspaceDir ?? inheritedWorkspaceDir — explicit params.cwd wins; inherited workspace applies only for same-agent spawns (targetAgentId !== requesterAgentId ? undefined); cross-agent spawns fall back through resolveSpawnedWorkspaceInheritance to the target agent's config. The original cross-agent guard is preserved.
normalizeOptionalString returns undefined for empty/blank cwd, so cwd: "" gracefully falls through to inherited — no edge case.
LGTM.
dc606b2 to
4087f75
Compare
Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4087f75 to
3246e90
Compare
|
Updated #81896 with a fresh deterministic proof image and gate-friendly proof section. The proof compares
Fresh proof image: https://raw.githubusercontent.com/giodl73-repo/openclaw/proof-artifacts/pr-81896-fresh/pr-81896/pr-81896-native-subagent-cwd-before-after-proof.png |
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
* Honor cwd for native subagent spawns Thread sessions_spawn cwd through the native subagent path, use the resolved child workspace for attachment materialization, and keep workspace metadata internal to the gateway boundary. * Refresh checks after proof update
Summary
sessions_spawncwdthrough the nativeruntime="subagent"path.cwdbefore same-agent inherited workspace and target-agent fallback.workspaceDirinternal and out of Gatewayagentparams.Closes #79840
Real behavior proof
sessions_spawn({ runtime: "subagent", cwd })should carry explicitcwdinto native spawn workspace resolution; spawned runs and inline attachments should use the requested workspace, while public Gatewayagentparams should not receive internalworkspaceDir.upstream/mainand PR head3246e902cfa20da8a03dca318cb6b4442b9038e5.upstream/mainandfork/fix/subagent-cwd-79840; in each worktree rannode --import ./node_modules/tsx/dist/loader.mjs ./probe-subagent-cwd.mjs. The probe checked the real source plumbing forcwdon the native spawn path and called the realmaterializeSubagentAttachments()with an explicit workspace plus a different target-agent fallback workspace.upstream/maindoes not accept/forwardcwdon the native spawn path, and attachment materialization falls back to the target agent workspace. PR head accepts/forwardscwdand materializes attachments under the explicit child workspace instead of the target-agent fallback workspace.cwdplumbing, and the PR includes focused spawn/attachment regression tests.Validation
node scripts/test-projects.mjs src/agents/tools/sessions-spawn-tool.test.ts src/agents/subagent-spawn.workspace.test.ts src/agents/subagent-spawn.attachments.test.ts src/agents/spawned-context.test.tspnpm check:changed