🤖 feat: make mux agent routable from Auto in project workspaces#2768
🤖 feat: make mux agent routable from Auto in project workspaces#2768ethanndickson wants to merge 13 commits intomainfrom
Conversation
c16c999 to
bff3f88
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c16c9996c8
ℹ️ 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".
|
@codex review |
842b79e to
7f14af8
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f14af86e2
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62fb263f9e
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03cf98f807
ℹ️ 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".
|
Resolved — backward-compat aliases are unnecessary here. Frontend and backend are always in sync (see AGENTS.md IPC/Compatibility section), so breaking tool renames are expected and safe. No persisted policy will reference the old names since this is a net-new feature. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 728534d868
ℹ️ 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".
|
@codex review |
- Add MuxToolScope discriminated union (global/project) to ToolConfiguration - Scope-aware skill tools: project writes to .mux/skills/, global to ~/.mux/skills/ - agent_skill_list scans both project + global roots in project scope - Rename mux_global_agents_read/write → mux_agents_read/write, scope-aware - Symlink-safe AGENTS.md via realpath + containment (replaces blanket rejection) - Simplify config tools to use muxScope.muxHome directly; delete muxHome.ts - Rewrite mux.md for dual-scope behavior; add mux routing to auto.md - Sentinel tool names via getAvailableTools + applyToolPolicyToNames (no throwaway runtime) - Add enableAnalyticsQuery flag to getAvailableTools; sync in getToolsForModel allowlist - Shift MCP/secrets gates from workspace-ID to agent-ID check
5f358a1 to
1fbe812
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fbe8126d9
ℹ️ 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".
| workspacePath: string | ||
| ): string { | ||
| const runtimeType = metadata.runtimeConfig.type; | ||
| return runtimeType === "ssh" || runtimeType === "docker" ? metadata.projectPath : workspacePath; |
There was a problem hiding this comment.
Keep project AGENTS writes in the active SSH workspace
For ssh workspaces this maps muxScope.projectRoot to metadata.projectPath (host path), so mux_agents_write edits host AGENTS.md instead of the remote workspace file. The prompt pipeline still reads instructions from workspacePath via runtime-first lookup (readInstructionSources), and SSHRuntime.ensureReady() only checks repo presence (it does not resync host edits each stream), so users can successfully edit AGENTS via mux but those changes won’t actually affect subsequent model requests in that SSH workspace.
Useful? React with 👍 / 👎.
Summary
Make the
muxagent (skills, AGENTS.md, config tools) reachable in any project workspace via Auto routing. In project context, tools operate on project-scoped resources (.mux/skills/, projectAGENTS.md); in the system workspace they continue to operate globally. Also eliminates a wasteful throwaway runtime assembly used for sentinel tool-name computation.Background
The
muxagent was previously confined to the singleton "Chat with Mux" system workspace. All its tools derived scope fromworkspaceSessionDir(navigating up~/.mux/sessions/<id>to find~/.mux/), hardcoding them to global scope. This meant project workspaces couldn't manage their own skills orAGENTS.mdvia mux.Separately,
resolveAgentForStreamcreated a throwaway runtime and instantiated every tool object just to compute tool names for the agent-transition sentinel message. This was slow and causedanalytics_queryto be missing from the handoff message (the stub config lackedanalyticsService).Implementation
1. MuxToolScope type + wiring (
toolScope.ts,aiService.ts,tools.ts)MuxToolScope:{ type: "global", muxHome }— system workspace{ type: "project", muxHome, projectRoot }— project workspace (projectRoot = worktree path)muxScope?: MuxToolScopetoToolConfigurationaiService.tsbased onworkspaceId === MUX_HELP_CHAT_WORKSPACE_IDworkspaceId !== MUX_HELP_CHAT_WORKSPACE_IDtoeffectiveAgentId !== MUX_HELP_CHAT_AGENT_IDso mux running in project scope gets the right capability set2. Scope-aware skill tools (
agent_skill_{write,delete,list}.ts,skillFileUtils.ts)config.muxScope:<projectRoot>/.mux/skills/<muxHome>/skills/validateLocalSkillDirectorygeneralized: takes acontainmentRootparameter instead of hardcodedmuxHomeRealagent_skill_listscans both project and global roots when in project scope, tagging each entry with its scope. Global-only listing retained for system workspace.getMuxHomeFromWorkspaceSessionDirfrommuxHome.ts(file deleted) — all callers usemuxScopedirectly3. Renamed + scope-aware AGENTS.md tools (
mux_agents_{read,write}.ts)mux_global_agents_read/write→mux_agents_read/writeviagit mvconfig.muxScopeto determine target:<projectRoot>/AGENTS.md<muxHome>/AGENTS.mdlstat+ reject-if-symlink) withrealpath()+ containment validation (isPathInsideRoot). In-root symlinks (e.g.,AGENTS.md → docs/AGENTS.md) now work; escaping symlinks are rejected.toolDefinitions.ts,tools.ts,exec.md,plan.md4. Simplified config tools (
mux_config_{read,write}.ts)config.muxScope!.muxHomedirectly instead ofgetMuxHomeFromWorkspaceSessionDirgetMuxHomeFromWorkspaceSessionDirfromconfigToolUtils.ts5. Agent prompt updates (
mux.md,auto.md,exec.md,plan.md)mux.md: Rewritten for dual-scope behavior with clear context-aware documentation and safety rulesauto.md: Added mux routing criteria for config/skills/AGENTS.md management requestsexec.md/plan.md: Updated tool policy regexmux_global_agents_.*→mux_agents_.*builtInAgentContent.generated.ts6. Sentinel tool-name computation without throwaway runtime (
agentResolution.ts,toolPolicy.ts,toolDefinitions.ts)applyToolPolicyToNames(names, policy)— name-only policy filtering that shares matching logic withapplyToolPolicy(single source of truth for regex/order semantics)applyToolPolicyrefactored to delegate toapplyToolPolicyToNamesgetAvailableTools()gainedenableAnalyticsQuery?: booleanflag (defaultstrue)resolveAgentForStreamreplaced throwaway block withgetAvailableTools(model, flags) → applyToolPolicyToNames(names, policy)— no tool objects instantiatedinitStateManagerfromResolveAgentOptions, addedhasAnalyticsService: booleanos,createRuntime,getToolsForModel,InitStateManagergetToolsForModelallowlist passesenableAnalyticsQuery: Boolean(config.analyticsService)to stay in sync7. Test coverage
testHelpers.ts:createTestToolConfigaccepts optionalmuxScope(defaults to global scope pointing at tempDir)muxScopein configsapplyToolPolicyToNamesparity tests (undefined/empty policy, disable, regex, last-wins, require, order preservation)mux_global_agents.test.tsdeleted, replaced bymux_agents.test.tswith expanded scope coverageValidation
make typecheck✅toolPolicy.test.ts,agent_skill_list.test.ts,mux_agents.test.ts,aiService.test.ts,agent_skill_write.test.ts,agent_skill_delete.test.ts,mux_config_read.test.ts,mux_config_write.test.tsRisks
effectiveAgentIddoesn't resolve toMUX_HELP_CHAT_AGENT_IDin the system workspace, MCP/secrets would incorrectly activate. Low risk — the resolution path for the system workspace always yields this agent ID.realpath+isPathInsideRootapproach is more permissive than the old blanket symlink rejection. Escaping symlinks are still rejected, but in-root symlinks are now allowed. This is intentional for repos with committedAGENTS.mdsymlinks.Generated with
mux• Model:anthropic:claude-opus-4-6• Thinking:xhigh• Cost:$31.71