Skip to content

fix: prevent sessions_spawn from creating directories with error messages#47

Open
newtontech wants to merge 1 commit intomainfrom
fix/issue-31311
Open

fix: prevent sessions_spawn from creating directories with error messages#47
newtontech wants to merge 1 commit intomainfrom
fix/issue-31311

Conversation

@newtontech
Copy link
Owner

Summary

Fixed a bug where sessions_spawn would create workspace directories using error message strings as paths when called with invalid agent IDs.

Changes

  • Modified resolveAgentWorkspaceDir to validate the agentId against the list of configured agents before creating a workspace directory
  • If the agentId is not configured, it falls back to the default agent ID
  • This prevents creating workspace directories with error messages or invalid IDs as names

Testing

  • All existing tests pass (37 tests in agent-scope, workspace, sessions-spawn-tool, and acp-spawn)
  • The fix ensures no filesystem artifacts are created when agentId is invalid

Root Cause

When sessions_spawn was called with a non-existent agent ID, the resolveAgentWorkspaceDir function would normalize the agentId (which could be an error message) and use it to create a workspace directory. This resulted in "ghost directories" being created with names like acp-target-agent-is-not-configured-pass-agentid-in-sessions-spawn-or-set-acp-defaultagent-in-config.

Fix

The fix adds validation to check if the agentId is a configured agent before creating a workspace directory. If not, it falls back to the default agent ID, preventing the creation of directories with error messages as names.

Fixes openclaw#31311

…ages

When sessions_spawn is called with an invalid agent ID, the error message
was being used as a directory path, creating ghost directories in the
workspace root. This fix ensures validation happens before any directory
creation, preventing filesystem artifacts on error.

The fix modifies resolveAgentWorkspaceDir to validate the agentId against
the list of configured agents before creating a workspace directory. If
the agentId is not configured, it falls back to the default agent ID.

Fixes openclaw#31311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed sessions_spawn creates workspace directory from error message string

1 participant