Skip to content

feat: support running skills as isolated sub-agents via context: fork#2137

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/what-is-needed-for-us-to-optionnaly-run-17583cad
Mar 17, 2026
Merged

feat: support running skills as isolated sub-agents via context: fork#2137
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/what-is-needed-for-us-to-optionnaly-run-17583cad

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 16, 2026

Summary

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 shared sub-session primitives from the duplicated handleTaskTransfer/RunAgent logic into reusable building blocks: SubSessionConfig, newSubSession, runSubSessionForwarding, runSubSessionCollecting
  • Add Context field and IsFork() to skills.Skill for parsing context: fork from SKILL.md frontmatter
  • Add run_skill tool to SkillsToolset, exposed only when fork skills exist
  • Add handleRunSkill runtime handler that builds a child session with the skill content as system prompt and the task as user message
  • Extend SubSessionConfig with SystemMessage and ImplicitUserMessage overrides for custom sub-session prompts
  • Update Instructions() to tag fork skills with <mode>sub-agent</mode> and explain run_skill usage
  • Document the feature in docs/features/skills/index.md with a frontmatter fields reference table and usage guide

How to use

Add context: fork to a SKILL.md frontmatter:

---
name: bump-go-dependencies
description: Update Go module dependencies one by one
context: fork
---

The agent will use run_skill instead of read_skill, spawning an isolated sub-agent session with its own conversation history.

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
@dgageot dgageot requested a review from a team as a code owner March 16, 2026 19:16
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dgageot dgageot merged commit 10cec57 into docker:main Mar 17, 2026
8 checks passed
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