fix(openclaw): populate agentDir so sub-agent spawns work#523
Open
cmoralestbrain wants to merge 1 commit into
Open
fix(openclaw): populate agentDir so sub-agent spawns work#523cmoralestbrain wants to merge 1 commit into
cmoralestbrain wants to merge 1 commit into
Conversation
`openclaw agents add --workspace <path>` registers `agentDir` (defaulting to `~/.openclaw/agents/<name>/agent/`) but does not create or populate that directory. Sub-agent spawns then fail with "agentDir does not exist" the first time the user tries to delegate to one of the agents. This patch: 1. Copies SOUL.md / AGENTS.md / IDENTITY.md into the agent state dir in addition to the workspace (3 extra `cp` calls per agent). 2. Passes `--agent-dir` explicitly to `openclaw agents add` so the registration matches what was just created on disk, even if a future OpenClaw release changes the default derivation. OpenClaw runtime files (HEARTBEAT.md / TOOLS.md / USER.md / `.openclaw/`) are created by the gateway on first spawn alongside the curated 3, so they are intentionally not copied here. Tested on a fresh Ubuntu 22.04 VM with OpenClaw 2026.4.23 and the upstream `claude-code` + `openclaw` workspaces. Without the patch, the first `sessions_spawn(runtime="subagent", agentId=...)` from the main agent fails. With the patch, spawn succeeds end-to-end.
|
Closing — this is my personal fork (bensl84/agency-agents). The canonical project lives at https://github.com/msitarzewski/agency-agents — please re-open your PR there. Thanks! |
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.
Summary
./scripts/install.sh --tool openclawregisters each agent in OpenClaw's config (viaopenclaw agents add --workspace <path>) but leaves the inferredagentDir(~/.openclaw/agents/<name>/agent/) empty on disk. The first time a user tries to delegate to one of these agents from the main agent (sessions_spawn(runtime="subagent", agentId=...)), OpenClaw can't find the agent files and the spawn fails.This PR copies the same 3 files (SOUL.md / AGENTS.md / IDENTITY.md) into the
agentDirand passes--agent-direxplicitly toagents add, so the post-install state matches the registered config.Why it happens
OpenClaw's
agents adddefaultsagentDirto~/.openclaw/agents/<name>/agent/when only--workspaceis given, but it does not materialize the personality files there — that's left up to the caller. The currentinstall_openclawonly writes them to theagency-agents/workspace, so spawn is broken until the user manually copies or symlinks.What's not changed
OpenClaw runtime files (HEARTBEAT.md, TOOLS.md, USER.md,
.openclaw/) are created by the gateway on first spawn alongside the 3 curated files, so they are intentionally not copied by the installer.Test plan
bash -n scripts/install.sh).sessions_spawn(geographer, ...)returns "agentDir does not exist". With the patch: same call succeeds; geographer responds within the spawn turn.install.sh --tool openclawoverwrites the same files (no duplication, no orphans).Scope
Only the
install_openclawfunction. Other targets (claude-code,cursor,aider, etc.) are untouched.