2.8 KiB
2.8 KiB
Subagent Usage Templates and Orchestration
This helper provides the Management agent with templates to create robust and repeatable runSubagent calls.
- Basic runSubagent Template
runSubagent({
prompt: "<Clear, short instruction for the subagent>",
description: "<Agent role name - e.g., Backend Dev>",
metadata: {
plan_file: "docs/plans/current_spec.md",
files_to_change: ["..."],
commands_to_run: ["..."],
tests_to_run: ["..."],
timeout_minutes: 60,
acceptance_criteria: ["All tests pass", "No lint warnings"]
}
})
- Orchestration Checklist (Management)
- Validate:
plan_fileexists and contains aHandoff ContractJSON. - Kickoff: call
Planningto create the plan if not present. - Run: execute
Backend DevthenFrontend Devsequentially. - Parallel: run
QA and Security,DevOpsandDoc Writerin parallel for CI / QA checks and documentation. - Return: a JSON summary with
subagent_results,overall_status, and aggregated artifacts.
- Return Contract that all subagents must return
{
"changed_files": ["path/to/file1", "path/to/file2"],
"summary": "Short summary of changes",
"tests": {"passed": true, "output": "..."},
"artifacts": ["..."],
"errors": []
}
- Error Handling
- On a subagent failure, the Management agent must capture
tests.outputand decide to retry (1 retry maximum), or request a revert/rollback. - Clearly mark the
statusasfailed, and includeerrorsandfailing_testsin thesummary.
- Example: Run a full Feature Implementation
// 1. Planning
runSubagent({ description: "Planning", prompt: "<generate plan>", metadata: { plan_file: "docs/plans/current_spec.md" } })
// 2. Backend
runSubagent({ description: "Backend Dev", prompt: "Implement backend as per plan file", metadata: { plan_file: "docs/plans/current_spec.md", commands_to_run: ["cd backend && go test ./..."] } })
// 3. Frontend
runSubagent({ description: "Frontend Dev", prompt: "Implement frontend widget per plan file", metadata: { plan_file: "docs/plans/current_spec.md", commands_to_run: ["cd frontend && npm run build"] } })
// 4. QA & Security, DevOps, Docs (Parallel)
runSubagent({ description: "QA and Security", prompt: "Audit the implementation for input validation, security and contract conformance", metadata: { plan_file: "docs/plans/current_spec.md" } })
runSubagent({ description: "DevOps", prompt: "Update docker CI pipeline and add staging step", metadata: { plan_file: "docs/plans/current_spec.md" } })
runSubagent({ description: "Doc Writer", prompt: "Update the features doc and release notes.", metadata: { plan_file: "docs/plans/current_spec.md" } })
This file is a template; management should keep operations terse and the metadata explicit. Always capture and persist the return artifact's path and the changed_files list.