[PR #6541] fix: skip local agent validation in attach mode #11967

Closed
opened 2026-02-16 18:16:54 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6541

State: closed
Merged: No


Summary

  • Skip local agent validation when using --attach flag to connect to a remote server
  • Fixes regression introduced in #5843 where Agent.get() requires Instance context that isn't available in attach mode

Problem

When running:

opencode run --attach "http://server:4096" --agent "explore" "prompt"

The CLI crashes with:

Error: instance: No context found for instance
    at use (src/util/context.ts:16:21)
    at directory (src/project/instance.ts:41:20)
    ...

Root Cause

PR #5843 added agent validation that calls Agent.get() which requires Instance context from bootstrap(). In attach mode, bootstrap() is never called, so there's no context available.

Solution

Add early return in the agent validation block to skip local validation when in attach mode. The remote server handles agent validation instead.

if (args.attach) return args.agent

Fixes #6489

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6541 **State:** closed **Merged:** No --- ## Summary - Skip local agent validation when using `--attach` flag to connect to a remote server - Fixes regression introduced in #5843 where `Agent.get()` requires `Instance` context that isn't available in attach mode ## Problem When running: ```bash opencode run --attach "http://server:4096" --agent "explore" "prompt" ``` The CLI crashes with: ``` Error: instance: No context found for instance at use (src/util/context.ts:16:21) at directory (src/project/instance.ts:41:20) ... ``` ## Root Cause PR #5843 added agent validation that calls `Agent.get()` which requires `Instance` context from `bootstrap()`. In attach mode, `bootstrap()` is never called, so there's no context available. ## Solution Add early return in the agent validation block to skip local validation when in attach mode. The remote server handles agent validation instead. ```typescript if (args.attach) return args.agent ``` Fixes #6489
yindo added the pull-request label 2026-02-16 18:16:54 -05:00
yindo closed this issue 2026-02-16 18:16:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11967