feat: support running skills as isolated sub-agents via context: fork#2137
Conversation
Add 'context: fork' SKILL.md frontmatter support, matching Claude Code's syntax. When set, the agent spawns an isolated child session for the skill instead of reading its instructions inline. Changes: - Extract SubSessionConfig and shared sub-session primitives from the duplicated handleTaskTransfer/RunAgent logic (newSubSession, runSubSessionForwarding, runSubSessionCollecting) - Add Context field and IsFork() to skills.Skill - Add run_skill tool to SkillsToolset, exposed only when fork skills exist - Add handleRunSkill runtime handler using the shared sub-session infra - Extend SubSessionConfig with SystemMessage and ImplicitUserMessage overrides for custom sub-session prompts - Update Instructions() to tag fork skills with <mode>sub-agent</mode> - Document the feature in docs/features/skills/index.md Assisted-By: docker-agent
There was a problem hiding this comment.
Review Summary
Assessment: 🟢 APPROVE
Summary
This PR introduces context: fork support for running skills as isolated sub-agents, matching Claude Code's syntax. The implementation refactors the existing agent delegation logic to extract reusable sub-session primitives and adds a new run_skill tool for fork-mode skills.
Code Quality: The refactoring is well-structured, extracting duplicated session-construction logic into SubSessionConfig, newSubSession, runSubSessionForwarding, and runSubSessionCollecting. This improves maintainability and sets up a clean foundation for the new skill runner feature.
Testing: Comprehensive test coverage added for the new primitives (agent_delegation_test.go) and the skills toolset changes (skills_test.go). Tests cover edge cases like custom system messages, implicit user messages, agent pinning, and fork skill detection.
Documentation: The feature is well-documented in docs/features/skills/index.md with a clear frontmatter reference table and usage guide explaining when to use context: fork.
Findings
No bugs found in the changed code. The refactoring correctly preserves the existing behavior while adding the new fork skill capability.
Note: This is an automated review. The assessment label (🟢 APPROVE) is informational only — this bot always posts reviews as COMMENT and never grants merge authority.
Summary
Add
context: forkSKILL.md frontmatter support, matching Claude Code's syntax. When set, the agent spawns an isolated child session for the skill instead of reading its instructions inline.Changes
handleTaskTransfer/RunAgentlogic into reusable building blocks:SubSessionConfig,newSubSession,runSubSessionForwarding,runSubSessionCollectingContextfield andIsFork()toskills.Skillfor parsingcontext: forkfrom SKILL.md frontmatterrun_skilltool toSkillsToolset, exposed only when fork skills existhandleRunSkillruntime handler that builds a child session with the skill content as system prompt and the task as user messageSubSessionConfigwithSystemMessageandImplicitUserMessageoverrides for custom sub-session promptsInstructions()to tag fork skills with<mode>sub-agent</mode>and explainrun_skillusagedocs/features/skills/index.mdwith a frontmatter fields reference table and usage guideHow to use
Add
context: forkto a SKILL.md frontmatter:The agent will use
run_skillinstead ofread_skill, spawning an isolated sub-agent session with its own conversation history.