Skip to content

Run the agent CLI, not the mise wrapper, when newer mise keeps it on PATH - #17301

Open
jasona wants to merge 2 commits into
omacom:quattrofrom
jasona:agent-exec-skip-mise-wrappers
Open

jasona wants to merge 2 commits into
omacom:quattrofrom
jasona:agent-exec-skip-mise-wrappers

Conversation

@jasona

@jasona jasona commented Nov 1, 2026

Copy link
Copy Markdown

Since mise 2026.10.23, Claude, Codex and Grok started through account dispatch get the system's tools ahead of the project's mise tools. In a project that pins python = "3.12", a terminal runs 3.12, but inside Claude Code python3 is /usr/bin/python3 3.14. The reporter's Rails project hit the same with Ruby, so bin/rails, bin/ci and git hooks failed inside the agent.

omarchy-agent-account-exec finds the CLI with type -P "$provider", relying on mise having removed its wrapper directory from PATH before running the wrapper's command. mise 2026.10.23 (jdx/mise#15126) keeps that directory on PATH and tracks running wrappers in __MISE_ACTIVE_WRAPPERS instead. So type -P now finds the wrapper again, account dispatch execs it, and mise's second pass hands the CLI the inherited PATH with the tool directories after /usr/bin.

Account dispatch now takes the wrapper directory off PATH before resolving the CLI. The existing line that puts it back in front for the agent's subprocesses is unchanged, so other agents stay reachable through their wrappers.

Verified on Omarchy 4.5.0rc2 in a VM, launching claude from an interactive shell in a project that pins Python 3.12:

mise before after
2026.10.19 (RC2) 3.12 3.12
2026.10.22 3.12 —
2026.10.23 3.14 (/usr/bin) —
2026.10.25 3.14 (/usr/bin) 3.12

Tracing PATH showed it arriving at omarchy-agent-account-exec in the right order with 2026.10.25; the reorder happens only on the second pass through the wrapper. That also explains why jdx/mise#15207, the same report against mise, couldn't be reproduced on plain mise.

test/shell.d/agent-account-test.sh gets one check, which fails on the current script and passes with this change.

This touches the same file as #14656, which already conflicts with quattro there; its rewrite keeps the type -P lookup, so it would need these lines too.

Fixes #17163

🤖 Generated with Claude Code

…PATH

mise 2026.10.23 stopped removing its wrapper directory before running a
wrapper's command. Account dispatch then resolved the wrapper again instead
of the CLI, and the second pass put the inherited PATH ahead of the
project's mise tools, so a system ruby or python shadowed the pinned one in
everything the agent ran.

Fixes omacom#17163

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes appear safe to merge.

Summary

Account launches now skip mise’s wrapper when finding the agent CLI, preserving the project’s chosen tools.

  • Agent account launches skip mise's wrapper when finding the CLI.

No new actionable issues were found in the changes since the previous review.

Reviews (2) · Last reviewed commit: "Restore mise account dispatch for nested..." · Reviewed by Greptile

@Jitheswar

Copy link
Copy Markdown

I hit the same mise 2026.10.23 change through test/shell.d/agent-account-exec-test.sh, which fails on quattro with mise 2026.10.25. This PR fixes the lookup, but that test still fails with it applied:

not ok - claude Main sessions keep their account after a switch

mise also exports __MISE_ACTIVE_WRAPPERS=["claude"], and the agent inherits it. When the agent runs claude again (a nested or new session), mise skips the claude wrapper for that call because it's marked active. So the call never reaches account dispatch, and with no mise-installed CLI it falls into mise install claude. Under older mise, those nested calls went through dispatch, and the line that puts the wrapper directory back on PATH exists for exactly that.

Clearing the marker before handing off fixes it. The script runs the real CLI directly, so nothing recurses:

export PATH
unset __MISE_ACTIVE_WRAPPERS
exec "$agent_binary" "$@"

With this PR plus that line, agent-account-exec-test.sh passes all 38 checks and agent-account-test.sh still passes (mise 2026.10.25, Omarchy 4.0.6 host). Run it with #17324 too: without it, an older installed Omarchy makes several unrelated shell tests fail.

@amalrik

amalrik commented Nov 2, 2026

Copy link
Copy Markdown

Independently reproduced this on the issue reporter's machine with mise 2026.10.25 (linux-x64) and Bash 5.3.20, using isolated homes/data/config/cache/state directories, real mise dispatch, the real Omarchy account scripts, and small probe executables in place of the agent CLIs. No agent credentials or service calls were used.

Compared:

  • Base: e2c7007c105d3e9e5f1706bb8e364bd794f3e995.
  • This PR: 7567df89e1c54f0174671335c1c107a6e7215d13.
  • The same PR plus unset __MISE_ACTIVE_WRAPPERS immediately before the final exec.

Actual Ruby lookup: a project pins Ruby 4.0.9, using the already-installed real Ruby binary. The system Ruby is 3.4.12. After mise activate bash and mise hook-env -s bash, the parent shell resolves Ruby 4.0.9 in every variant.

Code Ruby seen by launched claude, codex, and grok probes Marker inherited by probe
Base /usr/bin/ruby, 3.4.12 ["claude"], ["codex"], or ["grok"]
PR mise Ruby 4.0.9 provider still marked active
PR + unset mise Ruby 4.0.9 unset

The base process PATH puts /usr/bin before mise/installs/ruby/4.0.9/bin; both patched variants put the pinned Ruby directory before /usr/bin. This directly reproduces #17163 for all three dispatch providers, independently of the agent's own shell startup behavior.

Existing regression tests: I used the base-test.sh isolation change from #17324 (b4af99290928b7886593a8977e070c79ae1832df) identically in all three variants, so sibling commands come from the tested checkout.

Code agent-account-exec-test.sh agent-account-test.sh
Base exit 1 before first successful check 31 checks pass, exit 0
PR 3 checks pass, then not ok - claude Main sessions keep their account after a switch, exit 1 31 checks pass, exit 0
PR + unset 38 checks pass, exit 0 31 checks pass, exit 0

The PR-only failure also prints Failed to install aqua:anthropics/claude-code@latest: no versions found for claude in the offline fixture, consistent with the nested invocation bypassing account dispatch. These upstream fixtures set MISE_OFFLINE=1; their fresh cache also produces version-resolution warnings, retained in the full logs.

This independently confirms @Jitheswar's result: the PR fixes the tool lookup, and clearing the active-wrapper marker is needed for the existing nested-account regression tests to pass:

export PATH
unset __MISE_ACTIVE_WRAPPERS
exec "$agent_binary" "$@"

Scope: this tests the real dispatch boundary, real Ruby versions, and the repository's account tests. It does not launch authenticated Claude/Codex/Grok sessions or validate directory changes/worktrees inside a running agent.

Clear the active-wrapper marker before executing the resolved CLI so a same-provider child enters account dispatch again. The existing real-mise account tests reproduce the skipped dispatch without this reset. This implements the correction reported by Jitheswar and confirmed by amalrik. Describe wrapper removal at the boundary that now performs it, rather than claiming mise has already removed it.

Co-Authored-By: GPT-6 High (Codex) <noreply@openai.com>
Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Pushed de4cad7 to clear __MISE_ACTIVE_WRAPPERS before executing the resolved CLI, addressing the nested-session failure reported by @Jitheswar and @amalrik. Clearing the marker lets child sessions enter account dispatch again; removing just that reset reproduces the failing account test.

On a disposable Omarchy ISO worker with mise 2026.11.9 and real Python 3.12.12, all three providers inherited system Python 3.14.10 on base, retained the project’s Python 3.12.12 with this change, and returned to system Python when the fix was reverted. The final branch passed all 129 CLI checks and 150 checks across the seven focused account, dispatch, autoswitch, copy, recovery, default-agent and preinstalls suites, including SSH-style mise shims.

GPT-6 High in Codex reviewed this with Opus 5.5 High and muse-wonder via pi, thinking high. The final reviews found no source defects; agreement does not guarantee review independence. Their requested launch-path comparison also established a separate case: without interactive activation, both the parent and every tested branch retain system-first tool resolution. #18158 changes that global mise policy; the reviewers differed on whether that separate scope question should delay this fix. #14656 overlaps this dispatcher and must preserve both the wrapper bypass and marker reset if combined.

Waiting on the maintainer.

@jelenv

jelenv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

With this PR, an agent that moves to another project still gets the launch directory's tool versions. Putting the shims right after the wrappers fixes that. It's one line in the block this PR already changes; diff and test results are in #17163 (comment). Could it go in here?

@omarchybot omarchybot removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents launched through account dispatch get system tools ahead of the project's mise tools

5 participants