@@ -36,14 +36,15 @@ import { NamedError } from "@opencode-ai/shared/util/error"
3636import { SessionProcessor } from "./processor"
3737import { Tool } from "@/tool"
3838import { Permission } from "@/permission"
39+ import { Instance } from "@/project/instance"
3940import { SessionStatus } from "./status"
4041import { LLM } from "./llm"
4142import { Shell } from "@/shell/shell"
4243import { AppFileSystem } from "@opencode-ai/shared/filesystem"
4344import { Truncate } from "@/tool"
4445import { decodeDataUrl } from "@/util/data-url"
4546import { Process } from "@/util"
46- import { Cause , Effect , Exit , Layer , Option , Scope , Context } from "effect"
47+ import { Cause , Effect , Exit , Fiber , Layer , Option , Scope , Context } from "effect"
4748import { EffectLogger } from "@/effect"
4849import { InstanceState } from "@/effect"
4950import { TaskTool , type TaskPromptOps } from "@/tool/task"
@@ -986,19 +987,20 @@ NOTE: At any point in time through this workflow you should feel free to ask the
986987
987988 let retried = false
988989 let reason : SandboxSpawn . RetryReason | undefined
989- let result
990- try {
991- result = yield * exec ( proactive ? raw : call )
992- } catch ( error ) {
990+ let result : { code : number ; stderr : string }
991+ const first = yield * exec ( proactive ? raw : call ) . pipe ( Effect . exit )
992+ if ( Exit . isFailure ( first ) ) {
993+ const error = Cause . squash ( first . cause )
993994 if ( rejected && ! proactive && sandbox . active ) {
994995 const message = error instanceof Error ? error . message : String ( error )
995996 throw new Error (
996997 `Explicit unsandboxed request was rejected; sandboxed fallback failed before command start: ${ message } ` ,
997998 error instanceof Error ? { cause : error } : undefined ,
998999 )
9991000 }
1000- throw error
1001+ return yield * Effect . failCause ( first . cause )
10011002 }
1003+ result = first . value
10021004
10031005 if ( ! proactive ) {
10041006 reason = SandboxSpawn . retryReason ( {
0 commit comments