-
Notifications
You must be signed in to change notification settings - Fork 33
🤖 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
Open
ThomasK33
wants to merge
20
commits into
main
Choose a base branch
from
modes-config-20hn
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f917d27 to
6d948e1
Compare
c2aa0c9 to
e61f678
Compare
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: I3f1b6951196c5566ea232fcb36b11da72884cba5 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I51daf107e657bec4aae5acec9df63e1073604b53 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Id3b0f961c1c90a2db7f692a962037fc041191357 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ie0fe4dc9e794eb6b2b59c1ab68871ef44b2c8312 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I16452dc0aa6814ceb20e6608e143d9f1b0e34fd8 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: If9e57b0a146c41c59e0028480ae41ff0632e0216 Signed-off-by: Thomas Kosiewski <tk@coder.com>
fc21371 to
3131cea
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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