@@ -7081,6 +7081,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
70817081 readonly context : ActiveClaudeTurnContext ;
70827082 readonly nativeItemId : string ;
70837083 readonly nativeRequestId : string ;
7084+ readonly parentNodeId ?: OrchestrationV2ExecutionNode [ "id" ] ;
70847085 readonly requestKind : OrchestrationV2RuntimeRequest [ "kind" ] ;
70857086 readonly prompt ?: string ;
70867087 readonly appName ?: string ;
@@ -7116,10 +7117,12 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
71167117 id : nodeId ,
71177118 threadId : input . context . input . threadId ,
71187119 runId : input . context . input . runId ,
7119- parentNodeId : idAllocator . derive . nodeFromProviderItem ( {
7120- driver : CLAUDE_PROVIDER ,
7121- nativeItemId : input . nativeItemId ,
7122- } ) ,
7120+ parentNodeId :
7121+ input . parentNodeId ??
7122+ idAllocator . derive . nodeFromProviderItem ( {
7123+ driver : CLAUDE_PROVIDER ,
7124+ nativeItemId : input . nativeItemId ,
7125+ } ) ,
71237126 rootNodeId : input . context . input . rootNodeId ,
71247127 kind : input . questions === undefined ? "approval_request" : "user_input_request" ,
71257128 status : "waiting" ,
@@ -9556,6 +9559,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
95569559 toolName : Parameters < CanUseTool > [ 0 ] ,
95579560 toolInput : Parameters < CanUseTool > [ 1 ] ,
95589561 callbackOptions : Parameters < CanUseTool > [ 2 ] ,
9562+ options ?: { readonly startToolCall ?: boolean } ,
95599563 ) {
95609564 const context = yield * Ref . get ( activeTurn ) ;
95619565 if ( context === null ) {
@@ -9569,6 +9573,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
95699573 const nativeRequestId = callbackOptions . toolUseID ;
95709574 const nativeToolInput = claudeNativeToolInputFromRecord ( toolInput ) ;
95719575 const heldForEcho = context . heldRootFrames . length > 0 ;
9576+ const startToolCall = toolName !== "Agent" && options ?. startToolCall !== false ;
95729577 if ( toolName === "Agent" ) {
95739578 rememberClaudeSubagentLaunch (
95749579 subagentModelCatalog ,
@@ -9578,7 +9583,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
95789583 nativeToolInput ,
95799584 null ,
95809585 ) ;
9581- } else if ( ! heldForEcho ) {
9586+ } else if ( startToolCall && ! heldForEcho ) {
95829587 yield * ensureToolCallStarted ( {
95839588 context,
95849589 nativeItemId : nativeRequestId ,
@@ -9595,7 +9600,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
95959600 ) {
95969601 // The SDK blocks prompt echoes on permission answers; release held output except for ExitPlanMode.
95979602 yield * releaseHeldRootFrames ( context ) ;
9598- if ( toolName !== "Agent" ) {
9603+ if ( startToolCall ) {
95999604 yield * ensureToolCallStarted ( {
96009605 context,
96019606 nativeItemId : nativeRequestId ,
@@ -9612,6 +9617,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
96129617 context,
96139618 nativeItemId : nativeRequestId ,
96149619 nativeRequestId,
9620+ // No tool node exists for a control request to hang under.
9621+ ...( options ?. startToolCall === false
9622+ ? { parentNodeId : context . input . rootNodeId }
9623+ : { } ) ,
96159624 requestKind : "user_input" ,
96169625 questions,
96179626 } ) ;
@@ -9973,6 +9982,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
99739982 requestId : callbackOptions . requestId ,
99749983 toolUseID : request . toolUseID ?? callbackOptions . requestId ,
99759984 } ,
9985+ // The dialog is a control request, not a tool call, so no
9986+ // tool_result would ever settle a tool row started for it.
9987+ { startToolCall : false } ,
99769988 ) ;
99779989 if ( result . behavior !== "allow" ) return { behavior : "cancelled" as const } ;
99789990 const answers =
0 commit comments