Skip to content

Custom commands with agents should(?) run in isolated sessions #2315

Closed

Description

@audibleblink

Problem

When using a custom command that specifies an agent, the agent execution happens in the current context/session instead of running in isolation like when using @agent syntax.

Expected Behavior

A custom command like /commit with agent: git configured should behave the same as @git save my work - running the agent in its own isolated session without polluting the current context with tool output.

Current Behavior

The /commit command with agent: git executes everything in the current context/session, showing all git tool output and analysis in the main conversation.

Configuration

Command configuration (command/commit.md):

---
description: Commit using the current git state
agent: git
---

## Context

**Current git status**
!`git status`

**Current git diff (staged and unstaged changes)**
!`git diff --no-ext-diff HEAD | tr @ _`

**Recent commit format**
!`git log --oneline -10`

Agent configuration (agent/git.md):

---
description: Create well-formatted commits using the conventional commits style
mode: subagent
permission:
  bash:
    "git add *": "deny"
    "git stage *": "deny"
    "git reset *": "deny"
    "git restore *": "deny"
---
< git instructions here >

Impact

This makes custom commands with agents less useful since they clutter the main conversation instead of providing the clean, isolated execution that @agent syntax provides.

If this is the intended behavior, then perhaps an additional /command property like subtask: <boolean> could allow both behaviors

Activity

  1. NaikSoftware commented on Sep 1, 2025

    @NaikSoftware

    It looks like subagent used under the hood. But not showed in the session title

  2. rekram1-node commented on Sep 1, 2025

    @rekram1-node
    Collaborator

    wdym? can you reword that

  3. NaikSoftware commented on Sep 1, 2025

    @NaikSoftware

    I tried to ask which agent currently used and it responds with name of subagent

  4. rekram1-node commented on Sep 1, 2025

    @rekram1-node
    Collaborator

    ah it is probably lying, the agent doesnt know its name but it does know the name of other subagents so it is just telling you the name of a subagent it can trigger

  5. arsham commented on Sep 10, 2025

    @arsham

    You can test this behaviour by running the slash command and instruct it to do nothing and return back. Then in the current context ask questions about specific instructions in the slash command. Unfortunately my tests shows that the context is not isolated.

  6. NaikSoftware commented on Sep 10, 2025

    @NaikSoftware

    It worked for me, because I copied slash commands from Claude Code. There I described at the beginning of the instructions which agent to use. I this case calling /my-command always switch to isolated agent, but this is a tricky 😄

  7. arsham commented on Sep 10, 2025

    @arsham

    I don't think that is what this issue is about, correct me if I'm wrong. You can delegate to agents in the instructions, but the issue is about the part in the front-matter:

    ---
    description: Commit using the current git state
    agent: git
    ---

    In this setup, we expect the command to be run by the git agent and in isolation.

  8. rekram1-node commented on Sep 10, 2025

    @rekram1-node
    Collaborator

    if it is a subagent I think that makes a lot of sense, but what if it's a primary agent?

  9. arsham commented on Sep 10, 2025

    @arsham

    if it is a subagent I think that makes a lot of sense, but what if it's a primary agent?

    I think it would be valuable to have both behave the same and in isolation. When we set this agent in a slash command, we intend to isolate it, otherwise we would omit the agent all together.

    Another possibility would be in cases someone wants to run the command in the context of a certain primary agent. In that case we can document that they could use shift-tab to choose the primary agent and run the command with it.

  10. audibleblink commented on Sep 10, 2025

    @audibleblink
    Author

    If the slash command has no configured subagent, then I think it's a reasonable expectation for it to run in the currently selected agent and context.

    In the event that someone wants the slash command to run with the currently active main agent, but as a subtask to strategically separate context, then a subtask frontmatter property seems valuable.

  11. rekram1-node commented on Sep 13, 2025

    @rekram1-node
    Collaborator

    Will be in next release, will behave as @audibleblink said

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions