runSubagent still allows empty agentName and bypasses custom agent allow-list (related to #306266)
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.133.0
- OS Version: 25H2 (OS Build 26200.8893)
EDIT : confirmed bug still present in 1.133.0
# runSubagent allows self-invocation when `agentName` is empty, bypassing configured agent restrictions
Related:
- #306266
- #306568
- #306871
Previous issues discussing this behavior (#306266 and #306568) were closed and associated with work targeted for VS Code 1.114/1.115. However, the behavior described below remains reproducible in VS Code 1.132.x.
I have a custom agent configured as follows:
```yaml
---
name: CustomAgent
tools: [agents]
agents: [ResearchAgent]
---
```
In this configuration, `CustomAgent` is allowed to invoke `ResearchAgent`, but `CustomAgent` itself is not present in the allowed agents list.
If the model generates a `runSubagent` call without an `agentName`, or with an empty `agentName` such as:
```json
{
"agentName": "",
"prompt": "Research something"
}
```
the call succeeds and appears to spawn a new instance of the currently running agent.
Observed behavior:
```text
CustomAgent
-> CustomAgent
```
Expected behavior:
Regardless of how the target agent is resolved (explicit name, defaulting logic, fallback behavior, etc.), the final selected agent should be validated against the configured `agents` allow-list before execution. If the resolved agent is not present in the allow-list, the call should fail.
Actual behavior:
An empty or missing `agentName` appears to fall back to the current agent, allowing the current agent to invoke itself as a subagent even when it is not explicitly listed in its own `agents` configuration.
This effectively bypasses the configured subagent restrictions. Any agent that has access to `runSubagent` can self-invoke simply by omitting `agentName`, despite not being present in the allow-list.
Besides enabling recursive self-invocation, this also means that the runtime behavior is inconsistent with the configuration, since the `agents` list does not appear to be fully enforced when `agentName` is empty.
I believe this is either a regression or an incomplete fix related to the issues referenced above, as the behavior remains reproducible in VS Code ~~1.132.1~~ 1.133.0
`
Contributor guide
Assessment
This issue has not been assessed yet.