anomalyco / anomalyco/opencode
[FEATURE]: Allow the LLM to create subagents at runtime via the task tool
@nexxeln is already working on this.
Since Sep 7, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
Subagents currently have to be defined before a session starts — config files, agent directories, etc. When the model hits a job none of the existing agents fit (e.g. "diff these two PDFs and report only semantic changes"), it either stretches a generic agent like general or has to stop and ask the user to write config and restart. That breaks the flow for one-off specialized work.
Proposal
Let the task tool accept an inline agent definition alongside the prompt, e.g.:
task(
description: "review pdfs",
prompt: "Compare a.pdf and b.pdf for meaningful changes",
runtime_agent: {
name: "pdf-reviewer",
description: "Specialized PDF review agent",
prompt: "You are a specialized PDF comparison agent...",
tools: { read: true, grep: true }
}
)
The agent would be registered in-memory in the agent service and spawned as a normal child session — no restart, no files written to disk. Rules I'd keep:
- runtime agents can't shadow native or config-defined agents (name collision = error)
- the tools map acts as a strict allowlist (everything denied, then the listed tools allowed)
- permissions derived the same way as for static subagents
Benefits
One-off specialist agents on demand, mid-conversation. Complements file-based agents (which stay the right choice for recurring/team conventions) with no file-system side effects from the LLM.
I have a working implementation (~250 lines in agent.ts + task.ts) with a test suite and a live e2e run against a server built from source. Happy to open a PR if there's interest.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.