Skip to content

Commit 44dc124

Browse files
zerone0xclaude
andcommitted
fix(cli): skip local agent validation in attach mode
When using `opencode run --attach` with the `--agent` flag, the CLI would crash with "No context found for instance" because Agent.get() requires the Instance context that is only available after bootstrap(). In attach mode, bootstrap() is never called since we're connecting to a remote server. This fix skips local agent validation in attach mode, allowing the remote server to handle agent validation instead. Fixes anomalyco#6489 anomalyco#8094 Co-Authored-By: Claude <[email protected]>
1 parent 520a814 commit 44dc124

File tree

1 file changed

+2
-0
lines changed
  • packages/opencode/src/cli/cmd

1 file changed

+2
-0
lines changed

packages/opencode/src/cli/cmd/run.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ export const RunCommand = cmd({
231231
// Validate agent if specified
232232
const resolvedAgent = await (async () => {
233233
if (!args.agent) return undefined
234+
// Skip local agent validation in attach mode - the remote server handles it
235+
if (args.attach) return args.agent
234236
const agent = await Agent.get(args.agent)
235237
if (!agent) {
236238
UI.println(

0 commit comments

Comments
 (0)