Skip to content

fix(flow): give each agent run its own /tmp workspace - #7691

Closed
ump45nose wants to merge 1 commit into
1Panel-dev:v2from
ump45nose:fix/7625-unique-agent-temp-dir
Closed

ump45nose wants to merge 1 commit into
1Panel-dev:v2from
ump45nose:fix/7625-unique-agent-temp-dir

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Summary

Fixes #7625: agent shell tools used /tmp/<chat_id> as the run workspace and deleted it when the generator finished. Concurrent runs (workflow AI nodes / duplicate requests on the same chat) could therefore remove the cwd out from under a sibling still executing commands, producing:

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/<chat_id>'

Changes

  • Allocate a unique temp directory per run (/tmp/<chat_id>-<uuid7> or /tmp/<uuid7>).
  • Recreate SandboxShellBackend cwd with os.makedirs(..., exist_ok=True) before execute.
  • Unit tests for the path helper.

Test plan

  • PYTHONPATH=apps python3 -m unittest application.flow.test_agent_temp_dir -v
  • Manual: start two overlapping agent turns on the same chat_id and confirm shell execute no longer loses its cwd mid-turn.

AI disclosure

This change was prepared with AI assistance. I reviewed the diff and ran the listed unit tests locally.

Concurrent mcp_response_generator runs that shared /tmp/<chat_id> could
delete the directory when the first finished, so later shell execute
calls failed with FileNotFoundError on the cwd (1Panel-dev#7625).

Always append a uuid to the temp path, and recreate the sandbox cwd
before execute as a safety net.
@liuruibin liuruibin closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants