Skip to content

Commit 8ad17fe

Browse files
nhortonclaude
andauthored
feat: Add agent delegation field to job.yml steps (#188)
When a step specifies an `agent` field (e.g., `agent: general-purpose`), the generated skill will include `context: fork` and `agent: <value>`. This enables steps to delegate execution to specific agent types. Changes: - Add `agent` field to Step class in parser.py - Add `agent` to job schema validation in job_schema.py - Pass agent to template context in generator.py - Update Claude skill template to emit context: fork when agent is set - Update job.yml.template with agent option comment - Update job_spec.md doc spec with Agent Delegation section - Update define.md step instructions with agent delegation guidance https://claude.ai/code/session_01GaqLCGFqkvUsvpqUVqB9G9 Co-authored-by: Claude <[email protected]>
1 parent f527dae commit 8ad17fe

File tree

15 files changed

+144
-0
lines changed

15 files changed

+144
-0
lines changed

.claude/skills/deepwork_jobs.define/SKILL.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ For each major phase they mentioned, ask structured questions to gather details:
192192
- Are there any quality checks or validation needed?
193193
- What makes a good vs. bad output for this step?
194194
195+
6. **Agent Delegation** (optional)
196+
- Should this step be executed by a specific agent type?
197+
- Use the `agent` field when the step should run in a forked context with a specific agent
198+
- When `agent` is set, the generated skill automatically includes `context: fork`
199+
- Available agent types:
200+
- `general-purpose` - Standard agent for multi-step tasks
201+
202+
```yaml
203+
steps:
204+
- id: research_step
205+
agent: general-purpose # Delegates to the general-purpose agent
206+
```
207+
195208
**Note**: You're gathering this information to understand what instructions will be needed, but you won't create the instruction files yet - that happens in the `implement` step.
196209

197210
#### Doc Spec-Aware Output Format
@@ -578,6 +591,19 @@ Use branch format: `deepwork/deepwork_jobs-[instance]-YYYYMMDD`
578591
exposed: true # Makes step available without running dependencies
579592
```
580593
594+
### Agent Delegation
595+
596+
When a step should be executed by a specific agent type, use the `agent` field. This automatically sets `context: fork` in the generated skill.
597+
598+
```yaml
599+
steps:
600+
- id: research_step
601+
agent: general-purpose # Delegates to the general-purpose agent
602+
```
603+
604+
Available agent types:
605+
- `general-purpose` - Standard agent for multi-step tasks
606+
581607
### Quality Hooks
582608

583609
```yaml

.claude/skills/deepwork_jobs.review_job_spec/SKILL.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,19 @@ Use branch format: `deepwork/deepwork_jobs-[instance]-YYYYMMDD`
345345
exposed: true # Makes step available without running dependencies
346346
```
347347
348+
### Agent Delegation
349+
350+
When a step should be executed by a specific agent type, use the `agent` field. This automatically sets `context: fork` in the generated skill.
351+
352+
```yaml
353+
steps:
354+
- id: research_step
355+
agent: general-purpose # Delegates to the general-purpose agent
356+
```
357+
358+
Available agent types:
359+
- `general-purpose` - Standard agent for multi-step tasks
360+
348361
### Quality Hooks
349362

350363
```yaml

.deepwork/doc_specs/job_spec.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ steps:
9090
exposed: true # Makes step available without running dependencies
9191
```
9292
93+
### Agent Delegation
94+
95+
When a step should be executed by a specific agent type, use the `agent` field. This automatically sets `context: fork` in the generated skill.
96+
97+
```yaml
98+
steps:
99+
- id: research_step
100+
agent: general-purpose # Delegates to the general-purpose agent
101+
```
102+
103+
Available agent types:
104+
- `general-purpose` - Standard agent for multi-step tasks
105+
93106
### Quality Hooks
94107

95108
```yaml

.deepwork/jobs/deepwork_jobs/doc_specs/job_spec.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ steps:
9090
exposed: true # Makes step available without running dependencies
9191
```
9292
93+
### Agent Delegation
94+
95+
When a step should be executed by a specific agent type, use the `agent` field. This automatically sets `context: fork` in the generated skill.
96+
97+
```yaml
98+
steps:
99+
- id: research_step
100+
agent: general-purpose # Delegates to the general-purpose agent
101+
```
102+
103+
Available agent types:
104+
- `general-purpose` - Standard agent for multi-step tasks
105+
93106
### Quality Hooks
94107

95108
```yaml

.deepwork/jobs/deepwork_jobs/steps/define.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ For each major phase they mentioned, ask structured questions to gather details:
172172
- Are there any quality checks or validation needed?
173173
- What makes a good vs. bad output for this step?
174174
175+
6. **Agent Delegation** (optional)
176+
- Should this step be executed by a specific agent type?
177+
- Use the `agent` field when the step should run in a forked context with a specific agent
178+
- When `agent` is set, the generated skill automatically includes `context: fork`
179+
- Available agent types:
180+
- `general-purpose` - Standard agent for multi-step tasks
181+
182+
```yaml
183+
steps:
184+
- id: research_step
185+
agent: general-purpose # Delegates to the general-purpose agent
186+
```
187+
175188
**Note**: You're gathering this information to understand what instructions will be needed, but you won't create the instruction files yet - that happens in the `implement` step.
176189

177190
#### Doc Spec-Aware Output Format

.deepwork/jobs/deepwork_jobs/templates/job.yml.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ steps:
3434
outputs:
3535
- [output_filename_or_path] # e.g., "report.md" or "reports/analysis.md"
3636
dependencies: [] # List of step IDs that must complete first
37+
# Optional: Delegate to a specific agent type (uses context: fork)
38+
# agent: general-purpose # or other agent type
3739
# Optional: Quality validation hooks
3840
hooks:
3941
after_agent:

.gemini/skills/deepwork_jobs/define.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ For each major phase they mentioned, ask structured questions to gather details:
192192
- Are there any quality checks or validation needed?
193193
- What makes a good vs. bad output for this step?
194194
195+
6. **Agent Delegation** (optional)
196+
- Should this step be executed by a specific agent type?
197+
- Use the `agent` field when the step should run in a forked context with a specific agent
198+
- When `agent` is set, the generated skill automatically includes `context: fork`
199+
- Available agent types:
200+
- `general-purpose` - Standard agent for multi-step tasks
201+
202+
```yaml
203+
steps:
204+
- id: research_step
205+
agent: general-purpose # Delegates to the general-purpose agent
206+
```
207+
195208
**Note**: You're gathering this information to understand what instructions will be needed, but you won't create the instruction files yet - that happens in the `implement` step.
196209
197210
#### Doc Spec-Aware Output Format

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11+
- Agent delegation field for job.yml steps
12+
- New `agent` field on steps allows specifying an agent type (e.g., `agent: general-purpose`)
13+
- When `agent` is set, generated Claude Code skills automatically include `context: fork` and `agent:` in frontmatter
14+
- Enables steps to delegate execution to specific agent types
15+
- Updated `deepwork_jobs.define` step instructions with agent delegation guidance
16+
- Updated `job_spec.md` doc spec with "Agent Delegation" section
1117
- Explicit workflow definitions in job.yml for distinguishing multi-step workflows from standalone skills
1218
- New `workflows` section in job.yml with `name`, `summary`, and ordered `steps` array
1319
- Workflows are shown separately from standalone skills in generated meta-skills

src/deepwork/core/generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def _build_step_context(
311311
"hooks": hooks, # New: all hooks by platform event name
312312
"stop_hooks": stop_hooks, # Backward compat: after_agent hooks only
313313
"quality_criteria": step.quality_criteria, # Declarative criteria with framing
314+
"agent": step.agent, # Agent type (e.g., "general-purpose") - triggers context: fork
314315
}
315316

316317
# Add workflow context if step is part of a workflow

src/deepwork/core/parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ class Step:
142142
# Declarative quality criteria rendered with standard evaluation framing
143143
quality_criteria: list[str] = field(default_factory=list)
144144

145+
# Agent type for this step (e.g., "general-purpose"). When set, skill uses context: fork
146+
agent: str | None = None
147+
145148
@property
146149
def stop_hooks(self) -> list[HookAction]:
147150
"""
@@ -180,6 +183,7 @@ def from_dict(cls, data: dict[str, Any]) -> "Step":
180183
hooks=hooks,
181184
exposed=data.get("exposed", False),
182185
quality_criteria=data.get("quality_criteria", []),
186+
agent=data.get("agent"),
183187
)
184188

185189

0 commit comments

Comments
 (0)