Skip to content

Studio: keep the user's git identity and gh login in unsloth start pi - #15865

Merged
danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:start-pi-shell-commands-lose
Oct 29, 2026
Merged

danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:start-pi-shell-commands-lose

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

unsloth start pi moved HOME to a temporary session folder, and every shell command Pi runs inherits it. Inside Pi, git config --global user.email comes back empty, git commit fails with "Author identity unknown", and gh no longer finds its login, while plain pi on the same machine works. When the model tries to fix this itself, it writes a placeholder name and email into the session folder and commits under that made-up author.

HOME now stays the user's own. Pi's config, provider, key and sessions still live in the session folder through PI_CODING_AGENT_DIR, which Pi already prefers over HOME, so nothing new lands in the real ~/.pi. Since Pi reads the user's ~/.agents/skills directly again, the link that copied it into the session folder is gone too. The same applies on Windows, where USERPROFILE is no longer moved.

@NilayYadav NilayYadav self-assigned this Oct 28, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Review + reproduction evidence

Pinned review: 25957a5f3. No blocking findings.

I reproduced a shell command run by Pi through unsloth start pi on the merge base 987731e (Linux, CPU, Pi 0.74.2, user identity set with git config --global):

  • Before: inside Pi HOME=/root/.unsloth/studio/auth/agents/.tmp/unsloth-pi-..., git config --global user.email is empty and git commit fails with fatal: unable to auto-detect email address.

  • PR head: inside Pi HOME=/root, user.email is [email protected] and the commit is authored by Real User <[email protected]>.

  • Pi still resolves the unsloth provider and model from the session config on both sides, and nothing is written to the real ~/.pi.

  • The --no-launch recipe now exports only PI_CODING_AGENT_DIR.

  • unsloth_cli/tests/test_start.py: the new git identity test fails on the merge base and passes on head; Linux and macOS green; the Windows failures are all in tests of code this PR does not touch.

Conclusion: real bug on the default unsloth start pi path, fixed by this PR.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Reached Codex review convergence at NilayYadav#922 on 25957a5.

@shimmyshimmer

Copy link
Copy Markdown
Member

Review record for #15865, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#602.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 772debe81c (this PR's d00261801)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 772debe81c

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 772debe81c (this PR's d00261801).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit ba24b21 into unslothai:main Oct 29, 2026
61 of 63 checks passed
danielhanchen added a commit that referenced this pull request Oct 29, 2026
## Summary

`unsloth_cli/tests/test_start.py` has 9 tests that fail on Windows on
main. They only show up when a PR touching `unsloth start` gets a
Windows leg (first seen on the staging xplat run for #15865, which
changes none of them), because the regular CI does not run this file on
Windows. In each case the product does the right thing for Windows and
the test encoded a POSIX-only expectation:

| Test | Windows failure | Why |
|---|---|---|
| `test_write_codex_subagent_bridge_keeps_parent_credentials_out`,
`test_write_codex_parent_overlay_preserves_user_state_and_instructions`
| `assert (33206 & 63) == 0` | `st_mode & 0o077` is a POSIX promise;
Windows reports `0o666` for any writable file, whatever `os.open(...,
0o600)` asked for |
| `test_no_launch_last_line_is_self_contained`,
`test_no_launch_claude_last_line_blanks_conflicting_auth` | `KeyError:
'CODEX_HOME'`, no `ANTHROPIC_API_KEY= ` | they parse inline `NAME=value
cmd`; on Windows `--no-launch` prints PowerShell, which the neighbouring
`test_no_launch_output_is_parseable` already skips for |
| `test_start_studio_server_builds_command_and_waits` | `assert '-X' ==
'run'`, then `start_new_session` is `None` | on Windows the server is
launched through this interpreter (`python -X utf8 ...`, #8490), so
`run` is not `cmd[1]`, and it is detached with
`CREATE_NEW_PROCESS_GROUP`, not a POSIX session |
| `test_connect_pi_as_subagent_preserves_cloud_parent[False/True]` |
`'...\\unsloth_cli\\pi_subagent.ts'.endswith('unsloth_cli/pi_subagent.ts')`
| separator, compared as a POSIX path now |
|
`test_session_config_falls_back_when_existing_temp_root_is_unwritable`,
`..._when_studio_auth_root_is_unwritable` | the "unwritable" root was
written to | `mkdir(mode = 0o500)` / `chmod(0o500)` do not make a
directory unwritable on Windows |

## What changed

- The two mode-bit checks become `os.name == "nt" or ... & 0o077 == 0`.
- The two last-line tests and the two unwritable-root tests skip on
Windows, with the reason.
- The studio server test finds `run` after the interpreter head on
Windows and checks `creationflags & CREATE_NEW_PROCESS_GROUP` there; on
POSIX it still requires `cmd[1] == "run"` and `start_new_session=True`.
- The pi subagent test compares `Path(command[2]).as_posix()`.

Nothing changes on Linux or macOS except that comparison.

## Verification

- Linux: `unsloth_cli/tests/test_start.py` 949 passed, 1 skipped.
- With `start.py`'s two `os.open(..., 0o600)` calls changed to `0o644`,
both credential tests fail on Linux, so the permission guard still bites
where it means something.
- Windows (staging `windows-latest`): the first push fixed the two
mode-bit tests and showed the other 7; the second left only the server
test's detach check (`919 passed, 1 failed`); this push covers it, and
the leg is re-running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants