Skip to content

Login runs the recipe's bare command from PATH, not the agent patchbay launched #93

Closed

Description

@hussain

Problem

An agent's Log in can run a different binary from the one patchbay connected to. OpenCode shows it on both of its current versions (wire-checked 2026-10-08 with patchbay's own initialize):

opencode-login method what patchbay runs
1.18.35 (registry) no type, plus _meta["terminal-auth"] {command: "opencode", args: ["auth","login"]} bare opencode auth login, resolved from PATH
2.0.25 (@opencode/cli) type: "terminal", args: ["--login"], and the same _meta recipe the same bare opencode auth login

Patchbay starts the agent from an absolute path: the staged registry binary, or a custom command such as C:\…\opencode.exe acp. The login doesn't use that path. It uses whatever opencode the PATH finds:

  • Registry install, nothing on PATH: the command isn't found and the login fails.
  • PATH points at another install (v1 next to a custom v2, or the desktop app that takes the opencode name on some installs): credentials go to that install, not to the agent the card shows.

Reported live on anomalyco/opencode#11176: a user's local v2 opencode.exe added through Add custom.

Root cause

readAuthMethods (readers/initialize.ts) lets a parseable _meta recipe win over the method's own type. That rule was made for Auggie, which ships its recipe on a type-less method whose authenticate does nothing. Recipe-first is still right there. But it also overrides a spec terminal method when one exists. That spec path (typedLoginViaTerminal) runs the agent's own spawn spec plus the method's args, with the agent's env and the Windows resolver — the right binary by construction.

When there's no typed method (1.18.35), the recipe is the only path, and its command is a bare name. The recipe convention expects a machine-absolute command, and OpenCode sends a name.

Decision needed

  1. A spec terminal method and a _meta recipe, both parseable — which runs? Proposal: the typed method. It's the spec path, and the recipe remains the fallback for type-less methods (Auggie unchanged). This fixes 2.0.25.
  2. A recipe whose command is a bare name — what resolves it? Options: run it as the agent wrote it (today), or put the agent's own executable directory first on the login task's PATH so the bare name finds the binary patchbay launched (shape-based, no vendor named). This decides 1.18.35.

Activity

  1. added this to the 0.84.3 milestone on Oct 8, 2026
  2. hussain commented on Oct 8, 2026

    @hussain
    MemberAuthor

    Decision, after measuring every agent's authMethods against each client declaration (spec only / _meta only / both):

    A method with no type that carries a _meta["terminal-auth"] recipe is the convention from before the spec had terminal methods. OpenCode 2.0.25 sends exactly that shape to a _meta-only client, and the typed method to a spec client. A method carrying both is one login, sent for both kinds of client. Patchbay declares both, so the typed method is the one meant for it.

    Login, per method:

    1. Valid type: "terminal" → the spec path: the agent's configured launch + the method's args, its env over the agent's. A recipe on the same method is ignored. (Claude, OpenCode 2.x)
    2. Otherwise, a valid recipe → run as the agent wrote it, with the agent's configured and stored env underneath the recipe's own env. (Auggie, OpenCode 1.x)
    3. Otherwise, no type or agent → authenticate. (Codex)
    4. Anything else → shown, never run.

    A recipe's bare command stays as written: the convention asks for a path on the user's machine, and that is the agent's to send. OpenCode 1.x gets a note upstream.

  3. hussain commented on Oct 8, 2026

    @hussain
    MemberAuthor

    Fixed in 9986ad6 — ships with 0.84.3.

    A spec terminal method now wins over a _meta["terminal-auth"] recipe sent beside it: Log in runs the agent's own launch with the method's arguments — for OpenCode 2.x, <the binary Patchbay launched> acp --login. A recipe still runs where it is a method's only login (Auggie, OpenCode 1.x), now with the env you set for the agent. OpenCode 1.x's bare opencode stays as the agent wrote it; that goes to OpenCode as a note.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions