fix: resolve target agent workspace for cross-agent subagent spawns#40176
Conversation
Greptile SummaryThis PR fixes a bug where cross-agent subagent spawns (e.g. PM → Ops) incorrectly inherited the caller's workspace directory instead of the target agent's, by threading Key observations:
Confidence Score: 4/5
|
Cross-agent spawns (e.g. PM → Ops) incorrectly inherited the caller's workspace and persona files instead of the target agent's. Two issues: 1. resolveSpawnedWorkspaceInheritance extracted agent ID from the requester's session key, not the target agent 2. The caller's ctx.workspaceDir was passed as explicitWorkspaceDir, short-circuiting resolution before targetAgentId was considered Now targetAgentId is passed to the resolver and takes priority, and cross-agent spawns skip the caller's inherited workspace override. Fixes openclaw#40171
89824f4 to
2378e40
Compare
|
Merged via squash.
Thanks @moshehbenavraham! |
|
Thank you and the team @mcaxtr ! Love the project! |
…penclaw#40176) Merged via squash. Prepared head SHA: 2378e40 Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com> Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com> Reviewed-by: @mcaxtr
…penclaw#40176) Merged via squash. Prepared head SHA: 2378e40 Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com> Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com> Reviewed-by: @mcaxtr
|
Thanks @moshehbenavraham just uncovered the same problem today for our setup. Thanks for the PR |
…penclaw#40176) Merged via squash. Prepared head SHA: 2378e40 Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com> Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com> Reviewed-by: @mcaxtr
…penclaw#40176) Merged via squash. Prepared head SHA: 2378e40 Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com> Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com> Reviewed-by: @mcaxtr
…penclaw#40176) Merged via squash. Prepared head SHA: 2378e40 Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com> Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com> Reviewed-by: @mcaxtr
…penclaw#40176) Merged via squash. Prepared head SHA: 2378e40 Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com> Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com> Reviewed-by: @mcaxtr
Summary
sessions_spawn(agentId: "ops")) incorrectly inherited the caller's workspace and persona files instead of the target agent'stargetAgentIdparameter toresolveSpawnedWorkspaceInheritanceso it resolves the target agent's workspacectx.workspaceDirasexplicitWorkspaceDirso it doesn't short-circuit the resolutionFixes #40171
Test plan
spawned-context.test.ts,subagent-spawn.attachments.test.ts— 19 tests)pnpm build)workspace-ops/IDENTITY.mdand returns "Ops Agent" (previously readworkspace-pm/IDENTITY.mdand returned "PM Agent")🤖 Generated with Claude Code