[FEATURE]: Expose way to set a specific agent of a running instance (sdk/api/keybind) · Issue #4531 · anomalyco/opencode · GitHub
Skip to content

[FEATURE]: Expose way to set a specific agent of a running instance (sdk/api/keybind) #4531

Closed as not planned

Description

@einarpersson

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

TLDR: Add a way to set the agent of a running opencode instance.

Background

I use opencode both standalone and from within neovim using opencode.nvim which creates or attaches to a running opencode instance.

I would like to be able to set an agent via this plugin. The benefit would for example be:

When I start a new session/conversation from within neovim UI I can also specify what agent should be used. Eg. if I use a simple "spellcheck" prompt i would like to have another agent (and cheaper model) than if I use a "analyze this code and explain what it does".

Current state

It IS possible to set the starting agent for a new opencode instance with the --agent flag to the CLI. But that requires you to kill the instance and start a new one if you want to set it. It is (as far as I can see) not possible to change the agent of a running instance.

It IS possible to list all agents and cycle through the agent list (forwards, reverse). But why not set?

Other considerations

I'm not enought well versed in the opencode codebase yet in order to say exactly where this should be added. But I suppose it would also be good to have the same capability in the TUI itself. Right now you can have a keybinding for cycling agents (agent_cycle) but not setting a specific agent. It feels quite natural to be able to set a specific agent also (agent_set <agent_id>). My usage of Opencode is not so much "switching between the builtin plan/build agents" but much more leveraging my own custom agents. I have many custom agents. I really hope opencode can enable and empower that kind of "bring your own agents"-mindset.

Related issues

EDIT: One thing I'm not sure about is whether the ACP protocol allows for setting the agent of a running session? But I do think ACP supports "slash commands" and such, so that could perhaps be also resolved by this.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 20, 2025
  2. changed the title [-][FEATURE]: Expose endpoint to set agent of running instance (sdk/api)[/-] [+][FEATURE]: Expose way to set a specific agent of a running instance (sdk/api/keybind)[/+] on Nov 20, 2025
  3. Alex-CodeLab commented on Mar 2, 2026

    @Alex-CodeLab

    I also use external tools, it allows me to do everything, except ... switching agents. (sub agents does work)
    So I would like to see this feature as well.

  4. github-actions commented on May 2, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionUsed for feature requests, proposals, ideas, etc. Open discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions