-
Notifications
You must be signed in to change notification settings - Fork 34
🤖 feat: user-defined agents (unify modes + subagents) #1289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f917d27 to
6d948e1
Compare
172aa21 to
be5df72
Compare
|
@codex review |
There was a problem hiding this comment.
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.
ℹ️ 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".
|
@codex review Addressed the "Apply per-agent defaults when syncing model/thinking" thread.
|
There was a problem hiding this comment.
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.
ℹ️ 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".
Change-Id: I19d4bc5c5dd1e5b2a38a4a3e6021bf0b8543b839 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I1a5ba1d32ff0a15abae85af904d89074e36be101 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I8d55fb7ca4c3173706e390846b77416f7540af59 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ic00fe3e1cd68818771ac324787461a0427fcfb05 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I9daeab5067c65855a32f44c9626b8f855072fe9d Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ib691f6831627e0e03ecfb26339a6bd9b4a4c310c Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I73e70a106d775fe476864725b484c74a210e0775 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I5b50d8a66415580553f621b90b3b7504d779b59a Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I48698b7b296f11f250b24a9d0889b41df23362d5 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ibf3179de947d6c5cce6b9fdd8c81d55638c2c235 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I33242062387e70d5ada677c9e774bced561db1c6 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I97371ec54fbf9048540fd079ae097c1846e8133a Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I33815ac9fd94d7df809fcd39a35279947b5967bd Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Id8bdbdeb79baf7f56334f17abf6124b02945259d Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: If9e57b0a146c41c59e0028480ae41ff0632e0216 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I673ded0bd5f6a26b4adabb32171f661e54053ec6 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I41ab4e479cd02d0b9f0e3b2a7f7c73a5c1b604a7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
- Update Cmd/Ctrl+Shift+M to cycle Exec → Plan → Other (pinned agent) - Auto-open AgentModePicker when cycling to Other; Esc confirms pinned agent - Add tooltips for tools-only/tools-deny counts in Agent Defaults - Update related UI copy/command palette labels; add unit coverage Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-5.2` • Thinking: `xhigh`_ Change-Id: I24be4a31baa63a7650c163a5237a155657c56187
Change-Id: I73d9ffb02aaf0fb8a80255e8b1c485816d8f0f78 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: If06fdbd712b6d31987fe74707ac4f986518908e3 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I769c8d442e8f5fd28748e0566e729b6b29520ddc Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I8ac5ee71690fd4641dae88635362aebbf1251247 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I9966a03a794ae29b78bd072654b367186a66bd4d Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I65df30bf8b26f448508c1bb6dbd5fac34975023c Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I9f7de0bbb54deb35ac9149b54e60aa19a571656d Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I913ca93b136a3c5e93a3f4638c6714f265ce605c Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I8e9ae0acd43d880f9bf1c4ea515540eabbb75dad Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ib52891f117b95d4598dfb30b1670f6aba36d1cde Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I80b022cf9af068db66c6815891cd6697674d047b Signed-off-by: Thomas Kosiewski <tk@coder.com>
e2ced9a to
557e9e3
Compare
Change-Id: Id4351ae3a0554ffb427cc24773c4a5639050ecf8 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review Addressed your note about custom agents clobbering base mode overrides:
This prevents a reviewer agent (base=exec) from overwriting exec-mode overrides. |
There was a problem hiding this comment.
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.
ℹ️ 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".
Change-Id: Iaac0d86b08569520ed27bed10443d6d25a611946 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review Addressed the backend persistence clobber:
|
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Change-Id: I4c55efdb1253de127b6d17c79814e4ee72e5d154 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Unifies modes (Plan/Exec/Compact) and subagents (explore/exec presets) into user-defined Agent Definitions.
Key points:
~/.mux/agents/*.mdand<projectRoot>/.mux/agents/*.md(project overrides global overrides built-in).agentAiDefaultsconfig (with back-compat for legacymodeAiDefaults/subagentAiDefaults).Agent: <agentId>scoped sections inAGENTS.md(and keepsMode:scoping working).tasktool now supportsagentId(withsubagent_typeas a legacy alias).Docs/tests:
CI/stability fixes included:
mux api --helprunnable in the bundled ESM CLI output (definerequireviacreateRequire).srcBaseDirrespectMUX_ROOTduring E2E runs (special-case~/.mux/~/.cmuxtilde expansion).MUX_ROOTisolation + sanity check + updated UI helpers for the Agent selector combobox.commit.gpgSign=false).📋 Implementation Plan
Plan: User-defined Agents (unify Modes + Subagents)
Goal
Unify modes (Plan/Exec/Compact) and subagents (explore/exec presets) into a single, extensible concept: Agent Definitions.
Users can define new “modes” and “subagents” via Markdown files discovered from:
~/.mux/agents/*.md<projectRoot>/.mux/agents/*.mdEach file’s Markdown body becomes the agent’s system prompt (layered with mux’s base prelude), and its YAML frontmatter is strongly typed and parsed/validated on discovery.
Additionally, consolidate model + thinking defaults so modes and subagents share one configuration pipeline (frontmatter defaults → config overrides → workspace overrides → inheritance).
Recommended approach (v1): “Agent Definitions” registry + unified AI defaults
Net LoC estimate (product code): ~1,200–1,700
1) Define the on-disk format + schema
1.1 File layout + precedence
*.mdfiles (non-recursive):<projectRoot>/.mux/agents/*.md~/.mux/agents/*.mdagentId.agentIdis the filename without extension (e.g.,plan.md→agentId="plan").1.2 YAML frontmatter schema (strongly typed)
Create
AgentDefinitionFrontmatterSchema(Zod) + TS types.Proposed schema (v1):
Notes:
agentIdis derived from the filename (strip.md); there is noidfield in frontmatter.policy.basekeeps compatibility with existing “mode-based” behavior (tool defaults + UX expectations).policy.toolsis optional. If present, it must specify exactly one of:deny: allow the base tool set except these toolsonly: deny the base tool set except these tools1.3 Parsing rules
Mirror
agent skillsparsing patterns:agentIdfrom the filename (strip.md).2) Implement discovery + reading (Node)
Create an
agentDefinitionsServiceanalogous toagentSkillsService.Deliverables:
discoverAgentDefinitions({ projectRoot })→ list of index entries (id/name/description/flags + ai defaults + policy metadata).readAgentDefinition({ projectRoot, agentId })→ returns the validated frontmatter + markdown body.(projectRoot, mtime)to avoid re-reading on every message; add a cheap invalidation strategy:3) Unify “modeAiDefaults” + “subagentAiDefaults” into one config model
3.1 New config field
Add a single field to global config (backed by Zod + TS types):
agentAiDefaults: Record<string, { modelString?: string; thinkingLevel?: ThinkingLevel }>3.2 Back-compat migration
On config load:
agentAiDefaultsis missing, synthesize it from existing:modeAiDefaults[plan|exec|compact]→agentAiDefaults[plan|exec|compact]subagentAiDefaults[type]→agentAiDefaults[type]On config save:
agentAiDefaults.4) Apply Agent Definitions to system prompt construction
4.1 Main agent
Update
buildSystemMessageto incorporate the selectedagentId:AGENTS.mdlayering (global + project-local).4.2 Extend instruction scoping in AGENTS.md
Add support for a new scoped heading:
Agent: <agentId>Rules:
Mode: plan|exec|compactworking.Agent: <agentId>sectionsMode: <policy.base>sectionsModel:sections (unchanged)Tool:sections (unchanged)5) Make tool policies agent-driven (with subagent safety)
5.1 Policy resolution algorithm
Implement a single policy resolver:
policy.base:plan→ existing plan tool policyexec→ existing exec tool policycompact→ existing compact policypolicy.tools(exactly one):deny: remove tools from the base setonly: keep only these tools from the base settask(no recursion)propose_plan(main-agent only)5.2 Enforce in both frontend + backend
6) Unify AI defaults + overrides resolution for agents
Target resolution order (single algorithm used everywhere):
6.1 Workspace overrides
Generalize the existing “per-mode workspace override” to “per-agent workspace override”:
aiSettingsByAgentId: Record<string, AiSettings>workspaceAiSettingsByAgentId:${workspaceId}When user changes model/thinking while
agentId=X, persist overrides under thatagentId.6.2 Replace
WorkspaceModeAISyncwithWorkspaceAgentAISync(workspaceId, agentId).7) UI changes
7.1 Replace ModeSelector with AgentSelector
AgentDefinitionentries whereui.selectable: true.agentId(global or per-project).TOGGLE_MODEbecomes “toggle between last two selected UI agents”.7.2 Settings: single “Agents” defaults editor
Replace the split “Mode defaults” and “Subagent defaults” views with one:
policy.base)denyoronly)8) Subagents: switch from presets to agentId
8.1 Tool + API shape
Evolve the task tool schema:
task({ agentId: string, prompt: string, ... })subagent_typeas an alias for 1–2 releases (mapped to agentId).8.2 Backend behavior
agentIdexists andsubagent.runnable: true.9) Telemetry + timing
Current telemetry expects a small fixed
modeunion in some places.agentId: stringto relevant telemetry events.modeas the derivedpolicy.basefor backward compat and dashboards.sessionTimingServiceschema so custom agentIds don’t crash timing aggregation.10) Tests / validation
Unit tests (fast):
.md)Integration tests (targeted):
Agent:scoped AGENTS.md sections.11) Documentation
Add/extend user docs so this feature is discoverable and predictable:
docs/agents.mdx):<project>/.mux/agents/*.mdoverrides~/.mux/agents/*.md)policy.basetools.denyvstools.onlydocs/instruction-files.mdx:Agent: <agentId>scoped sectionsMode:scoping (derived frompolicy.base)docs.json) for the new page.Alternatives (not recommended for v1)
Option B: Only add custom subagents (keep modes fixed)
Net LoC (product): ~400–700
~/.mux/agents/*.mdonly for subagent presets.modeAiDefaultsfor modes; unify only subagent side.Pros: much smaller surface area.
Cons: does not deliver “custom modes” and does not unify defaults/UI.
Option C: Agent Definitions replace mode-based tool policy entirely
Net LoC (product): ~2,000–3,000
AgentMode/UIModeassumptions.Pros: cleanest long-term architecture.
Cons: high risk; lots of knock-on refactors.
Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh