Skip to content

Add custom subagent support via markdown files#6

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-subagent-customization-support
Draft

Add custom subagent support via markdown files#6
Copilot wants to merge 4 commits intomainfrom
copilot/add-subagent-customization-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 16, 2025

Enables users to define specialized subagents through markdown files in $CODEX_HOME/agents/. Each agent runs as an isolated subagent with custom instructions, model selection, and sandbox policies.

Implementation

Core Infrastructure

  • custom_agents.rs: Agent discovery from filesystem, frontmatter parsing (description, model, sandbox)
  • CustomAgentTask: Executes agents via run_codex_conversation_one_shot with modified config
  • Protocol: ListCustomAgents op, RunCustomAgent op with agent name + input items

Configuration via Frontmatter

---
description: "Expert code reviewer"
model: "claude-3-5-sonnet-20241022"
sandbox: "read-only"
---
You are an expert code reviewer...

Usage

// Discover available agents
conversation.submit(Op::ListCustomAgents).await?;

// Execute agent
conversation.submit(Op::RunCustomAgent {
    agent_name: "code-reviewer".to_string(),
    items: vec![UserInput::Text { text: "Review src/main.rs".into() }],
}).await?;

Security

  • Sandbox policies: read-only (default), workspace-write, danger-full-access
  • Inherits parent session feature flags and approval policies

Documentation

  • docs/custom-agents.md: Feature documentation, best practices, troubleshooting
  • docs/examples/custom-agents/: Four working examples (code-reviewer, documentation-writer, test-engineer, security-auditor)

Architecture

Follows existing subagent pattern (ReviewTask, CompactTask):

  1. Load agent definition from $CODEX_HOME/agents/{name}.md
  2. Spawn sub-conversation with custom base_instructions, model, sandbox_policy
  3. Forward events to parent session
  4. Complete on TaskComplete/TurnAborted

Agent names derived from filename stems. Only .md files discovered. Subdirectories not scanned.

Original prompt

增强本项目,让其支持可以通过编写md文件来自定义subagent。


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 16, 2025 08:28
- Create custom_agents module in core for discovering agent .md files from $CODEX_HOME/agents/
- Add CustomAgent struct in protocol with frontmatter support (description, model, sandbox)
- Add ListCustomAgents operation and ListCustomAgentsResponse event
- Implement list_custom_agents handler in codex.rs
- Add tests for agent discovery and frontmatter parsing
- Update rollout policy to handle new event type

Co-authored-by: x22x22 <3389949+x22x22@users.noreply.github.com>
- Create CustomAgentTask to run custom agents as subagents
- Add RunCustomAgent operation to protocol
- Implement run_custom_agent handler in codex.rs
- Add Custom task kind to TaskKind enum
- Custom agents run with their own instructions, model, and sandbox policy
- Forward all events from custom agent to parent session

Co-authored-by: x22x22 <3389949+x22x22@users.noreply.github.com>
- Create comprehensive custom-agents.md documentation
- Add four example custom agents:
  - code-reviewer: Code review specialist
  - documentation-writer: Technical documentation expert
  - test-engineer: Test automation specialist
  - security-auditor: Security vulnerability assessor
- Add examples README with usage instructions
- Document frontmatter configuration options
- Include best practices and troubleshooting guide

Co-authored-by: x22x22 <3389949+x22x22@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance project to support subagent customization via md files Add custom subagent support via markdown files Dec 16, 2025
Copilot AI requested a review from x22x22 December 16, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants