Skip to content

backends: bridged brain sessions drop the MCP server instructions #4416

Open

Description

@schlessera

Part of #4278. Deferred from the first review of PR #4394 (#4325).

Blocked by #4325

Context

  • The host bridge does not exist on main yet. It arrives with PR CONTRACT: feat(backends): bridge hosted brain reads before runtime startup #4394 (draft, for backends: serve the brain's MCP tools as host bridge tools that forward to a per-turn sandboxed server, so tool search survives non-blocking startup #4325). At that PR's head 8aefa80be, the bridge is created without instructions (createSdkMcpServer({ name: "brain", ... tools: [] }), packages/ui-backend-claude/src/brain-tool-forwarder.ts:63). On main, the stdio brain MCP server sends serverInstructions at initialize (serverInstructions, packages/core/src/mcp-server.ts:97-111; sent at :779; the owner name is sanitized by ownerName, :84-90). Bridged sessions therefore lose that guidance. The Claude Agent SDK's CreateSdkMcpServerOptions accepts an optional instructions string, which is "returned from initialize and surfaced to the model as an MCP instructions block" (installed @anthropic-ai/claude-agent-sdk 0.3.293, sdk.d.ts).
  • The current text names the owner from config, which the host must not read, and it recommends brain_add and brain_update, which hosted sessions disallow. docs/integration-contract/mcp.md:38-46 describes the stdio text as descriptive, not frozen. The text a bridged session should receive needs a decision.

Scope

Choose the static instruction text a bridged session receives, and pass it at registration, fixed for the session.

Acceptance criteria

  • The maintainer records the chosen text, or the rule for deriving it without a host read of the brain.
  • The keyless wire test shows a new bridged session's first request carries the chosen instructions block.
  • The text is identical across turns and on resume.
  • docs/integration-contract/mcp.md states what a bridged session receives.

Decision needed

Question. What instructions block, if any, does a bridged (hosted) brain session receive?

  • Option A. A fixed, owner-neutral variant of the stdio text, written for hosted sessions: no owner name, no write-tool advice, and only the tools the bridge serves.
    • Consequences: bridged agents keep the guidance to prefer brain tools over grepping files, and on which tool answers which need. It costs a few hundred bytes in every new bridged session's context. Because the block is fixed per session, provider history stays byte-identical (docs/decisions/provider-history.md), and it applies to new sessions only. A package-owned constant then has to track the hosted tool roster.
  • Option B. No instructions block for bridged sessions, with the difference documented.
    • Consequences: no cost and nothing to keep in sync. But hosted agents lose the tool-selection guidance that stdio clients get, and fall back to tool descriptions alone.

Recommendation: Option A, as a package-owned constant in the same style as autonomous-prompt.ts ("package-owned instructions only"), so the host never reads the brain to build it. This is a recommendation, not a ruling.

Contract impact

docs/integration-contract/mcp.md gains a statement of what a bridged session receives, in a CONTRACT: commit (additive).

2026-11-23 triage at main a3395c4: the forwarder exists only on PR #4394's head, so I added Blocked by #4325 and repaired the main citations for serverInstructions. Added the SDK instructions option evidence, consequences and a recommendation. The ruling is still open.

Activity

  1. added
    type: fix
    area: backends
    priority: p3
    needs: decision
    on Nov 21, 2026
  2. added
    blocked
    on Nov 23, 2026
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

    area: backendsblockedneeds: decisionpriority: p3type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions