@@ -1555,12 +1555,13 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
15551555 return Option . some ( yield * effect ) ;
15561556 } ) ,
15571557 ) ;
1558- const registerNativeResponseAcknowledgement = (
1559- generation : number ,
1560- transportRequestId : string ,
1561- acknowledgement : Deferred . Deferred < void , EffectAcpErrors . AcpError > ,
1562- ) =>
1563- Effect . gen ( function * ( ) {
1558+ const registerNativeResponseAcknowledgement =
1559+ /* Provider events include streaming deltas; avoid a span for each update. */
1560+ Effect . fnUntraced ( function * (
1561+ generation : number ,
1562+ transportRequestId : string ,
1563+ acknowledgement : Deferred . Deferred < void , EffectAcpErrors . AcpError > ,
1564+ ) {
15641565 yield * Ref . update ( nativeResponseAcknowledgements , ( current ) => {
15651566 const updated = new Map ( current ) ;
15661567 updated . set ( transportRequestId , { acknowledgement, generation } ) ;
@@ -1800,8 +1801,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
18001801 const endedBackgroundTaskIds = yield * Ref . make < ReadonlySet < string > > ( new Set ( ) ) ;
18011802 const endedBackgroundTaskIdLimit = 128 ;
18021803
1803- const setBackgroundTaskRunning = ( taskId : string , running : boolean ) =>
1804- Effect . gen ( function * ( ) {
1804+ const setBackgroundTaskRunning =
1805+ /* Provider events include streaming deltas; avoid a span for each update. */
1806+ Effect . fnUntraced ( function * ( taskId : string , running : boolean ) {
18051807 if ( running && ( yield * Ref . get ( endedBackgroundTaskIds ) ) . has ( taskId ) ) {
18061808 return ;
18071809 }
@@ -1836,10 +1838,11 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
18361838 ? setBackgroundTaskRunning ( mutation . taskId , true )
18371839 : markBackgroundTaskEnded ( mutation . taskId ) ;
18381840
1839- const trackRunningBackgroundTools = (
1840- notification : EffectAcpSchema . SessionNotification ,
1841- ) : Effect . Effect < void > =>
1842- Effect . gen ( function * ( ) {
1841+ const trackRunningBackgroundTools =
1842+ /* Provider events include streaming deltas; avoid a span for each update. */
1843+ Effect . fnUntraced ( function * (
1844+ notification : EffectAcpSchema . SessionNotification ,
1845+ ) : Effect . fn . Return < void > {
18431846 if ( flavor . extractBackgroundTaskId === undefined ) return ;
18441847 for ( const event of parseSessionUpdateEvent ( notification ) . events ) {
18451848 if ( event . _tag !== "ToolCallUpdated" ) continue ;
@@ -2780,8 +2783,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
27802783 return false ;
27812784 } ;
27822785
2783- const rearmDeferredFinalize = ( context : ActiveAcpTurn ) =>
2784- Effect . gen ( function * ( ) {
2786+ const rearmDeferredFinalize =
2787+ /* Provider events include streaming deltas; avoid a span for each update. */
2788+ Effect . fnUntraced ( function * ( context : ActiveAcpTurn ) {
27852789 if ( ! flavor . deferFinalizeForBackgroundWork ) return ;
27862790 if ( ! context . promptSettled || context . finalized ) return ;
27872791 if ( hasDeferredBackgroundWork ( context ) ) return ;
@@ -2795,8 +2799,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
27952799 projectedStatus ?: ProjectedToolStatus ,
27962800 ) => Effect . Effect < void > = ( ) => Effect . void ;
27972801
2798- const markAwaitingBackgroundHydration = ( context : ActiveAcpTurn , taskId : string ) =>
2799- Effect . gen ( function * ( ) {
2802+ const markAwaitingBackgroundHydration =
2803+ /* Provider events include streaming deltas; avoid a span for each update. */
2804+ Effect . fnUntraced ( function * ( context : ActiveAcpTurn , taskId : string ) {
28002805 if ( context . awaitingBackgroundHydration . has ( taskId ) ) return ;
28012806 context . awaitingBackgroundHydration . add ( taskId ) ;
28022807 yield * Effect . gen ( function * ( ) {
@@ -2815,8 +2820,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
28152820 } ) . pipe ( Effect . forkIn ( sessionScope ) , Effect . asVoid ) ;
28162821 } ) ;
28172822
2818- const markPendingInjectedReport = ( context : ActiveAcpTurn , taskId : string ) =>
2819- Effect . gen ( function * ( ) {
2823+ const markPendingInjectedReport =
2824+ /* Provider events include streaming deltas; avoid a span for each update. */
2825+ Effect . fnUntraced ( function * ( context : ActiveAcpTurn , taskId : string ) {
28202826 if ( ! context . promptSettled ) return ;
28212827 if ( context . pendingInjectedReport . has ( taskId ) ) return ;
28222828 context . pendingInjectedReport . add ( taskId ) ;
@@ -3365,13 +3371,14 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
33653371 } ) ;
33663372 } ) ;
33673373
3368- const appendLoadedHistory = (
3369- notification : EffectAcpSchema . SessionNotification ,
3370- role : "user" | "assistant" | "thought" ,
3371- text : string ,
3372- replace = false ,
3373- ) =>
3374- Effect . gen ( function * ( ) {
3374+ const appendLoadedHistory =
3375+ /* Provider events include streaming deltas; avoid a span for each update. */
3376+ Effect . fnUntraced ( function * (
3377+ notification : EffectAcpSchema . SessionNotification ,
3378+ role : "user" | "assistant" | "thought" ,
3379+ text : string ,
3380+ replace = false ,
3381+ ) {
33753382 if ( text . length === 0 && ! replace ) return ;
33763383 const now = yield * DateTime . now ;
33773384 yield * Ref . update ( snapshot , ( current ) => {
@@ -5032,47 +5039,47 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
50325039 }
50335040 } ) ;
50345041
5035- const projectAcpRuntimeSessionUpdateEffect = (
5036- rawNotification : EffectAcpSchema . SessionNotification ,
5037- ) =>
5038- Effect . gen ( function * ( ) {
5039- if ( clientTerminals !== undefined ) {
5040- const embedded = embeddedTerminalIdsFromSessionUpdate ( rawNotification ) ;
5041- if ( embedded !== undefined ) {
5042- rememberEmbeddedTerminals ( {
5043- ...embedded ,
5044- sessionId : rawNotification . sessionId ,
5045- } ) ;
5042+ const projectAcpRuntimeSessionUpdateEffect =
5043+ /* Provider events include streaming deltas; avoid a span for each update. */
5044+ Effect . fnUntraced (
5045+ function * ( rawNotification : EffectAcpSchema . SessionNotification ) {
5046+ if ( clientTerminals !== undefined ) {
5047+ const embedded = embeddedTerminalIdsFromSessionUpdate ( rawNotification ) ;
5048+ if ( embedded !== undefined ) {
5049+ rememberEmbeddedTerminals ( {
5050+ ...embedded ,
5051+ sessionId : rawNotification . sessionId ,
5052+ } ) ;
5053+ }
50465054 }
5047- }
5048- const notification =
5049- clientTerminals === undefined
5050- ? rawNotification
5051- : resolveEmbeddedTerminalContent (
5052- rawNotification ,
5053- clientTerminals . readOutputSnapshot ,
5054- ) ;
5055- if ( notification . update . sessionUpdate === "available_commands_update" ) {
5056- yield * (
5057- flavor . onAvailableCommandsUpdate ?.( notification . update . availableCommands ) ??
5058- Effect . void
5059- ) ;
5060- }
5061- if (
5062- notification . update . sessionUpdate === "config_option_update" ||
5063- notification . update . sessionUpdate === "current_mode_update"
5064- ) {
5065- yield * (
5066- flavor . onSessionConfigurationUpdate ?.(
5067- yield * runtime . getConfigOptions ,
5068- yield * runtime . getModeState ,
5069- ) ?? Effect . void
5055+ const notification =
5056+ clientTerminals === undefined
5057+ ? rawNotification
5058+ : resolveEmbeddedTerminalContent (
5059+ rawNotification ,
5060+ clientTerminals . readOutputSnapshot ,
5061+ ) ;
5062+ if ( notification . update . sessionUpdate === "available_commands_update" ) {
5063+ yield * (
5064+ flavor . onAvailableCommandsUpdate ?.( notification . update . availableCommands ) ??
5065+ Effect . void
5066+ ) ;
5067+ }
5068+ if (
5069+ notification . update . sessionUpdate === "config_option_update" ||
5070+ notification . update . sessionUpdate === "current_mode_update"
5071+ ) {
5072+ yield * (
5073+ flavor . onSessionConfigurationUpdate ?.(
5074+ yield * runtime . getConfigOptions ,
5075+ yield * runtime . getModeState ,
5076+ ) ?? Effect . void
5077+ ) ;
5078+ }
5079+ yield * handleSessionUpdate (
5080+ flavor . normalizeSessionUpdate ?.( notification ) ?? notification ,
50705081 ) ;
5071- }
5072- yield * handleSessionUpdate (
5073- flavor . normalizeSessionUpdate ?.( notification ) ?? notification ,
5074- ) ;
5075- } ) . pipe (
5082+ } ,
50765083 Effect . mapError (
50775084 ( cause ) =>
50785085 new EffectAcpErrors . AcpTransportError ( {
0 commit comments