Skip to content

unsloth start: fix Studio discovery, proxy, Hermes context, Claude hooks and Codex login - #14591

Merged
shimmyshimmer merged 3 commits into
mainfrom
studio-unsloth-start-fixes
Oct 22, 2026
Merged

shimmyshimmer merged 3 commits into
mainfrom
studio-unsloth-start-fixes

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

What changed

A sweep of unsloth start for bugs a normal user hits. Each fix has a regression test. Several were reproduced against the real agents: Hermes 0.21.0, Claude Code 2.1.307, dsh 0.2.1-rc.2 and PowerShell 7.6.

Server discovery and HTTP

  • Finds your own Studio when another one holds 8888. If 8888 belongs to another OS user's or another install's Studio, unsloth studio moves to the next free port. unsloth start then failed with "Couldn't verify that http://127.0.0.1:8888 is your Unsloth". Discovery now uses the server this install recorded whenever the default port's server can't prove it belongs to this install. unsloth chat and unsloth mcp share this code, so they get the fix too.
  • Loopback requests skip http_proxy. urllib proxies 127.0.0.1 unless no_proxy lists it. With a proxy exported, discovery failed, the health poll ran to the 900 s timeout, and the minted sk-unsloth- key went to the proxy in plain text. Loopback requests now skip the proxy, which unsloth studio already does. Remote URLs still use it.

Model selection

  • No-model attach skips speech and separation models. These entries carry a task tag in the loaded-models listing. Before, Claude or Codex could be pointed at an Orpheus TTS model. If only such a model is loaded, the error now says so.
  • Relative paths are resolved for a running server. --model ./foo.gguf is now sent as an absolute path, because a running server resolves paths against its own working directory.
  • Conflicting variants now warn. --model repo:Q8_0 --gguf-variant Q4_K_M used to drop the inline variant silently. It still prefers the flag, and now prints a warning.
  • Clearer --no-launch error. With no server running, --no-launch --model X now says that --no-launch never starts one.

Hermes

  • Small-context models work again, and context pins apply. The provider is now registered as unsloth-studio instead of unsloth. Hermes strips a <provider>/ prefix from model ids, which turned unsloth/Qwen3-0.6B-GGUF into Qwen3-0.6B-GGUF. The id then no longer matched model.default, so Hermes ignored the pinned context_length. Models under 64K were refused outright ("below the minimum 64,000"), and larger ones lost the pin. An earlier providers.unsloth entry written by Unsloth is removed, both in the session home and with --app. A user's own entry is left alone.
  • Compaction fits the real window. Hermes raises any threshold below 0.75, so a 40K model compacted at 55,705 tokens, past its real window. compression.threshold_tokens now caps compaction at 90% of the real window (36,864 for 40,960).
  • No leftover pins under --persist. A home kept with --persist no longer carries small-window settings into a later run with a larger window.

Claude Code

  • Hooks work on Windows without Git Bash. Hooks now use exec form (command + args, Claude Code 2.1.139+), so no shell parses them. Without Git Bash, Claude Code runs shell-form hooks in PowerShell, which can't parse "python.exe" -c .... Since 2.1.299 a failing guard blocks the call, so --as-subagent could never call unsloth_agent. Older builds keep the shell string.
  • apiKeyHelper no longer runs. The session overlay now blanks apiKeyHelper. Before, the user's helper ran on every launch and its cloud key was sent to Unsloth as x-api-key.
  • Forwarded --settings is kept. Claude keeps only the last --settings, so a user's forwarded one used to be dropped. It is now merged into the overlay, and Unsloth's pins win where the two conflict.

Codex

  • --as-subagent no longer breaks Codex login on Windows. Where symlinks are denied, auth.json is now hard-linked rather than copied. Before, a token refresh in the overlay left the real ~/.codex/auth.json with a refresh token that had already been used, so the next plain codex run couldn't refresh it.
  • A first login is kept. A first sign-in under --as-subagent now goes to the user's Codex home instead of the overlay, which is deleted on exit.
  • Recovery hint for --app. The --app message now says how the app is switched back if the command is killed.

Other agents

  • dsh profile shorthand passes through. unsloth start dsh headless "task" now reaches dsh as its own profile shorthand, instead of becoming dsh web ... headless "task", which dsh rejects.
  • --app keeps comments in JSON configs. OpenCode and OpenClaw configs keep their // and /* */ comments: only the touched member is rewritten. The parsed result is checked, and the old full rewrite is the fallback.
  • Pi warns about an old Node. Pi needs Node.js 22.19+, while Unsloth accepts Node 20.19. Pi now warns and names the legacy-node20 package when node is older.
  • Docs. Help text and the README table now list VS Code and Mistral Vibe.

Verification

  • unsloth_cli suites for start, start_app, plan gate, the subagent bridges, inference_chat and mcp: all pass. In the full unsloth_cli/tests run, the only failures are in studio update and training tests that touch none of the changed code; they fail locally because torch and GPU are absent.
  • End to end on macOS (CPU) with an isolated Studio on its own port, while another Studio held 8888:
    • unsloth start hermes unsloth/Qwen3-0.6B-GGUF:Q4_K_M --no-launch downloaded and loaded the model and found the right server.
    • A one-shot hermes chat initialized against the 40,960-token model and compacted at 36,864. Before this change it refused the model.
    • unsloth start claude -p ... with Claude Code 2.1.307 sent its requests to the local model.
  • The PowerShell hook repro: the shell-form string fails with ParserError: Unexpected token '-c', and the exec form returns the deny decision.

Not tested here

  • Windows and WSL themselves (NTFS hard links, a Claude Code session without Git Bash). These rest on the upstream sources cited above plus the pwsh repro.
  • Node 20 at runtime for Pi.
  • The OpenCode and OpenClaw desktop apps.
  • Not changed, noted for follow-up: a trusted project .codex/config.toml can override the Codex model, and TOML table splitting doesn't account for [ lines inside multi-line strings (--app refuses those files instead of corrupting them).

…gin issues

- Discovery prefers this install's recorded Studio when the default port's server is not provably ours, and loopback requests skip any exported http_proxy.
- No-model attach skips speech/separation models; relative --model paths are sent absolute; a conflicting inline variant warns.
- Hermes: register the provider as unsloth-studio so unsloth/* ids keep their context pin, cap compaction at 90% of a small window, clear stale --persist pins.
- Claude: exec-form hooks (no PowerShell parse failure on Windows without Git Bash), blank apiKeyHelper, merge a forwarded --settings.
- Codex --as-subagent: hard-link auth.json when symlinks are denied, keep a first login.
- dsh profile shorthand, comment-preserving JSONC --app edits, Pi Node warning, help/README lists.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T03:21:54.673334Z fa5eee7 Manual request
🔒 Security Review ✅ Completed 2026-10-22T03:08:51.664277Z b6e3169 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@shimmyshimmer

Copy link
Copy Markdown
Member 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: b6e3169538

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

and legacy.get("base_url") == provider["base_url"]
and set(legacy) <= {"base_url", "api_mode", "api_key", "models", "extra_body"}
):
changes.append((("providers", _HERMES_LEGACY_PROVIDER), _APP_DELETE))

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 Migrate the selected Hermes provider before deleting its entry

If the existing Hermes profile selects model.provider: custom:unsloth, this migration deletes providers.unsloth but leaves the selected provider unchanged: _hermes_app_target() only returns provider updates, unlike _set_hermes_provider(), which also updates model.provider. Consequently, running unsloth start hermes --app against a previously configured profile leaves its default model referencing a provider that no longer exists. Migrate the active provider reference along with the entry, or retain the legacy entry while it is referenced.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in fa5eee7: when the legacy entry is removed, a model.provider of custom:unsloth now moves to custom:unsloth-studio.

Comment on lines +4837 to +4839
if model and server is None and is_loopback_url(base) and _is_model_path(model):
if os.path.exists(os.path.expanduser(model)):
model = os.path.abspath(os.path.expanduser(model))

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 Verify a shared filesystem before absolutizing model paths

When Studio is reached through an SSH tunnel or container port forward on loopback, a relative model path belongs to the server's filesystem, not necessarily this process's filesystem. If ./foo.gguf also exists locally, this code replaces it with the client's absolute path and sends that to the remote server, breaking a previously valid server-relative request. _attach_gguf_check() already distinguishes these cases using verify_studio_identity() before trusting local filesystem checks; apply the same safeguard here so forwarded servers retain their original paths.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in fa5eee7: the path is only made absolute after verify_studio_identity confirms the loopback server is this machine's Studio.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: b6e3169538

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: fa5eee7035

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shimmyshimmer
shimmyshimmer merged commit cb2590f into main Oct 22, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-unsloth-start-fixes branch October 22, 2026 06:32
shimmyshimmer added a commit that referenced this pull request Oct 22, 2026
… (follow-up to #14591) (#14635)

Follow-up to #14591.

## What broke

#14591 fixed a real Codex login problem under `unsloth start codex
--as-subagent` on Windows: where symlinks are denied (no Developer Mode,
no admin), the overlay copied `auth.json`, so a token refresh in the
overlay left the user's real `~/.codex/auth.json` with a refresh token
that had already been used. The fix replaced the copy with a hard link.

The hard link was applied to every file in the user's Codex home, not
only `auth.json`. Codex keeps its WAL-mode SQLite databases in
`CODEX_HOME` (`state_5.sqlite`, `queue_1.sqlite`,
`thread_history_1.sqlite`, the logs db, plus any `-wal` / `-shm`
sidecars; `sqlite_home` defaults to `codex_home` in
`codex-rs/core/src/config/mod.rs`). Hard-linking those gives the live
database a second name. SQLite derives the `-wal` and `-shm` paths from
the name it was opened under, so the overlay Codex and a plain `codex`
(or the Codex app) running at the same time use different WAL and
shared-memory files for one database. SQLite documents this as a
corruption path: [How To Corrupt An SQLite Database File, 2.6 Multiple
links to the same file](https://www.sqlite.org/howtocorrupt.html).
Before #14591 those files were copied into the overlay, so the user's
real databases were never touched.

## What changed

- `write_codex_parent_overlay` hard-links only `auth.json` when symlinks
are denied. Every other file is copied, as before #14591. Symlinks,
junctions and the first-login dangling `auth.json` link are unchanged.
- Regression test: with symlinks denied, `state_5.sqlite`, its `-wal`
and `history.jsonl` land in the overlay as copies (not the same inode),
while the existing test still shows a rotated `auth.json` refresh token
reaching the user's home. The new test fails on current `main` and
passes with this change.

The rest of #14591 was audited and left as is: discovery, loopback proxy
bypass, task-tagged model filtering, Hermes provider rename and
`threshold_tokens`, Claude exec-form hooks (`args` landed in Claude Code
2.1.139), `apiKeyHelper` blanking, merged `--settings`, the dsh profile
shorthand, JSONC splicing and the Pi Node warning (`legacy-node20` tag
confirmed on npm).

## Verification

- `unsloth_cli` suites for start, start_app, the Claude plan gate,
inference_chat, mcp, and the Codex and Claude subagent bridges: 1206
passed, 2 skipped.
- `ruff check` and the repo's ruff format on the changed files.

## Not tested here

- Windows itself (NTFS hard links, symlink privilege denied). The test
simulates the denied symlink the same way the #14591 tests do.
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.

1 participant