Skip to content

feat(v2): configure tool availability per session #35647

Closed

Description

@kitlangton

Summary

V2 needs a public API and generated SDK surface for enabling or disabling tools for a specific Session. Today tool definitions are filtered by the selected Agent’s configured permissions, but neither the Session API nor the prompt API can apply Session-specific tool availability.

V1 behavior

V1 accepted a tool map on session.prompt(...):

await client.session.prompt({
  sessionID,
  tools: {
    bash: false,
    write: false,
  },
})

The implementation translated those entries into permission rules and persisted them on the Session. This provided the capability, but the contract was misleading: a field on one prompt mutated durable Session configuration. The field is now deprecated in V1.

V2 gap

  • PromptInput.Prompt contains only text and attachments.
  • Session.Info has no Session-specific tool or permission configuration.
  • ToolRegistry.materialize(...) receives only the selected Agent’s permission rules.
  • SDK consumers cannot create a restricted Session without defining a separate Agent in configuration.

Desired behavior

Provide an explicit Session-scoped API for tool availability, exposed through Protocol and generated clients. The common SDK use case should be straightforward:

await client.session.configure({
  sessionID,
  tools: {
    bash: false,
    write: false,
  },
})

The exact endpoint and representation need design. In particular, decide:

  1. Whether this is a tool-specific allow/deny map or a Session permission ruleset.
  2. How Session rules compose with Agent permissions and built-in tool permission actions.
  3. Whether changes are durable Session configuration, scoped to one admitted prompt, or whether both concepts are needed.
  4. Whether consumers can inspect the effective tool catalog after composition.

Non-goal

Do not restore V1’s implicit behavior where sending a prompt silently mutates persistent Session configuration.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Jul 7, 2026
  2. opencode-agent commented on Jul 8, 2026

    @opencode-agent
    Contributor

    Active implementation: V2 PR #35691.

  3. marwenchaabouni commented on Oct 14, 2026

    @marwenchaabouni

    A practical use case for session-scoped MCP configuration:

    I often work with multiple OpenCode chats in parallel, each requiring different MCP servers. For example, one chat may need Granola for meeting notes, while another needs Firecrawl for web research.

    Currently, keeping the required MCPs enabled means that unrelated tool definitions may also be included in the context of chats that do not need them. Switching MCPs manually is inconvenient when moving between parallel tasks, and it undermines the benefit of having separate chats.

    Expected behavior: Each chat/session should be able to select which MCP servers are exposed to the model, independently of other open sessions. Ideally, this selection should persist with the session.

    This would reduce unnecessary context consumption and make MCP management more practical for users who maintain several task-specific conversations.

    Would session-scoped MCP selection be covered by this issue, or is it outside the current implementation scope? I would be interested in contributing if there is a defined direction for the UI or API.

    P.S. This becomes even more relevant when working with multiple MCP servers across several chats simultaneously, as the unnecessary context overhead can accumulate across different tasks.

  4. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for writing this up. I checked the current dev code (77a0fd6). As described, v2 has no Session-scoped way to configure which tools are available: PromptInput.Prompt carries only text and attachments, and tool availability comes from the selected Agent's permissions. This is how v2 is currently designed, not a bug, so there's nothing to reproduce. It's better tracked as feature work. The open design questions you listed (an allow/deny map versus a permission ruleset, how Session rules compose with Agent rules, durable versus per-prompt scope, and inspecting the effective tool catalog) are the next step.

  5. neriousy commented on Nov 12, 2026

    @neriousy
    Member

    Closing as completed by #48351. session.create and session.update accept permissions, and a session's rules apply after the agent's. A session rule that denies a tool for all resources removes that tool from the model's tool list, for example:

    { "permissions": [{ "action": "bash", "resource": "*", "effect": "deny" }] }

    Wildcards work too, so one MCP server's tools can be hidden for a single session. Two things are still missing: a tools: { bash: false } shorthand on the prompt, and a way to see a session's effective tool list. Please open a new issue for either one if you need it.

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

    2.0coreAnything pertaining to core functionality of the application (opencode server stuff)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions