Skip to content

Fix agent workspace isolation and Hermes one-shot resume - #7103

Merged
wasimysaid merged 10 commits into
unslothai:mainfrom
wasimysaid:fix/start-agent-session-safety
Jul 15, 2026
Merged

wasimysaid merged 10 commits into
unslothai:mainfrom
wasimysaid:fix/start-agent-session-safety

Conversation

@wasimysaid

@wasimysaid wasimysaid commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Route resumed Hermes one-shot prompts through its session-aware chat command in quiet, unattended mode.
  • Keep OpenClaw workspaces inside the Unsloth-managed session directory, including Windows shims launched from WSL.
  • Allow OpenCode YOLO sessions to work outside their launch directory, then restore prompts for non-YOLO runs.

Details

Hermes handles top-level -z before its resume shortcut and does not pass --resume or --continue into one-shot execution. The wrapper now converts only resumed one-shot invocations to the equivalent session-aware chat form and preserves automatic tool approval. New one-shot sessions and interactive resume commands remain unchanged.

Hermes upstream exposes --usage-file only for top-level one-shot execution, so it cannot be preserved by the chat compatibility path. That unsupported combination now fails with a clear message instead of losing resume state or passing an invalid chat option.

OpenClaw's state directory does not relocate its default workspace, so ephemeral sessions could initialize or read ~/.openclaw/workspace. The workspace is now pinned beside the managed config and persists only when the session itself persists. When WSL launches a Windows OpenClaw shim, the embedded workspace path is converted with wslpath -w just like the config and state environment paths.

OpenCode requires a separate external_directory permission when tools access paths outside the launch directory. YOLO mode now enables it, while later non-YOLO launches restore the prompting policy.

Verification

  • python -m pytest unsloth_cli/tests -q (390 passed)
  • python -m ruff check unsloth_cli/commands/start.py unsloth_cli/tests/test_start.py
  • python -m py_compile unsloth_cli/commands/start.py unsloth_cli/tests/test_start.py
  • python scripts/enforce_kwargs_spacing.py unsloth_cli/commands/start.py unsloth_cli/tests/test_start.py

@wasimysaid
wasimysaid force-pushed the fix/start-agent-session-safety branch from dec5368 to 98e0fb0 Compare July 13, 2026 12:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several enhancements to the CLI commands. Specifically, it routes resumed one-shot prompts through Hermes' session-aware chat command, configures a dedicated workspace directory for OpenClaw, and adds external directory permissions for OpenCode when running in YOLO mode. Additionally, corresponding unit tests have been updated and added. The feedback suggests a more idiomatic way to prepend elements to a list in _hermes_resume_oneshot_args using list concatenation instead of slice assignment.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread unsloth_cli/commands/start.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5de5d70da7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
Comment thread unsloth_cli/commands/start.py Resolved
@wasimysaid
wasimysaid force-pushed the fix/start-agent-session-safety branch from 98e0fb0 to f13c04e Compare July 13, 2026 12:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f13c04ece2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
@wasimysaid
wasimysaid force-pushed the fix/start-agent-session-safety branch from f13c04e to 621bfd6 Compare July 13, 2026 12:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 621bfd6777

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 621bfd6777

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
Comment thread unsloth_cli/commands/start.py Resolved
Comment thread unsloth_cli/commands/start.py Resolved
@wasimysaid
wasimysaid force-pushed the fix/start-agent-session-safety branch from 621bfd6 to e1fb76a Compare July 13, 2026 13:23
@wasimysaid wasimysaid self-assigned this Jul 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 673372d108

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
Comment thread unsloth_cli/commands/start.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 559417b42c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
Comment thread unsloth_cli/commands/start.py Resolved
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4039a3d54a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
@wasimysaid
wasimysaid merged commit 1bf3509 into unslothai:main Jul 15, 2026
62 of 64 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e88877af6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1490 to +1491
if permission.get("external_directory") == {"*": "allow"}:
permission["external_directory"] = {"*": "ask"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear stale external_directory instead of forcing ask

When a reused --no-launch/--persist OpenCode config follows a --yolo run, this writes an explicit external_directory ask rule into the OPENCODE_CONFIG file. OpenCode loads OPENCODE_CONFIG above the user's global config (https://opencode.ai/docs/config/), and external_directory already defaults to prompting, so this overrides a user's global deny/allow policy instead of just removing Unsloth's stale yolo override; delete the key when it matches the yolo fingerprint so the next non-yolo run falls back to the user's policy/default.

Useful? React with 👍 / 👎.

# config so ephemeral launches avoid ~/.openclaw and persisted sessions retain it.
workspace = path.parent / "workspace"
workspace.mkdir(parents = True, exist_ok = True, mode = 0o700)
defaults["workspace"] = workspace_path or str(workspace)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear default OpenClaw agentDir during isolation

When a reused managed openclaw.json contains agents.defaults.agentDir (for example after OpenClaw setup or migration records a default state root), this path survives while only the default workspace and per-agent paths are adjusted. OpenClaw uses agentDir for agent state/session storage, so those launches can still write sessions under the old ~/.openclaw or another user path despite the Unsloth session dir being isolated; clear or relocate the default agentDir alongside the default workspace.

Useful? React with 👍 / 👎.

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.

2 participants