@@ -24,6 +24,7 @@ import { createOpencodeClient, type OpencodeClient, type ToolPart } from "@openc
2424import { Agent } from "@/agent/agent"
2525import { Permission } from "@/permission"
2626import { RuntimeFlags } from "@/effect/runtime-flags"
27+ import { InstanceRef } from "@/effect/instance-ref"
2728import { FormatError , FormatUnknownError } from "../error"
2829import { INTERACTIVE_INPUT_ERROR , resolveInteractiveStdin } from "./run/runtime.stdin"
2930
@@ -236,6 +237,7 @@ export const RunCommand = effectCmd({
236237 handler : Effect . fn ( "Cli.run" ) ( function * ( args ) {
237238 const agentSvc = yield * Agent . Service
238239 const flags = yield * RuntimeFlags . Service
240+ const localInstance = yield * InstanceRef
239241 yield * Effect . promise ( async ( ) => {
240242 const rawMessage = [ ...args . message , ...( args [ "--" ] || [ ] ) ] . join ( " " )
241243 const thinking = args . interactive ? ( args . thinking ?? true ) : ( args . thinking ?? false )
@@ -508,7 +510,9 @@ export const RunCommand = effectCmd({
508510 if ( ! args . agent ) return undefined
509511 const name = args . agent
510512
511- const entry = await Effect . runPromise ( agentSvc . get ( name ) )
513+ const entry = await Effect . runPromise (
514+ agentSvc . get ( name ) . pipe ( Effect . provideService ( InstanceRef , localInstance ) ) ,
515+ )
512516 if ( ! entry ) {
513517 UI . println (
514518 UI . Style . TEXT_WARNING_BOLD + "!" ,
0 commit comments