File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export function installFetchWrapper(
2828 prompts : SynthPrompts
2929) : ( ) => void {
3030 const originalGlobalFetch = globalThis . fetch
31-
31+
3232 const ctx : FetchHandlerContext = {
3333 state,
3434 logger,
@@ -39,6 +39,14 @@ export function installFetchWrapper(
3939 }
4040
4141 globalThis . fetch = async ( input : any , init ?: any ) => {
42+ // Skip all DCP processing for subagent sessions
43+ if ( state . lastSeenSessionId && state . subagentSessions . has ( state . lastSeenSessionId ) ) {
44+ logger . debug ( "fetch-wrapper" , "Skipping DCP processing for subagent session" , {
45+ sessionId : state . lastSeenSessionId . substring ( 0 , 8 )
46+ } )
47+ return originalGlobalFetch ( input , init )
48+ }
49+
4250 if ( init ?. body && typeof init . body === 'string' ) {
4351 try {
4452 const body = JSON . parse ( init . body )
@@ -74,14 +82,12 @@ export function installFetchWrapper(
7482 init . body = JSON . stringify ( body )
7583 }
7684 } catch ( e ) {
77- // Silently ignore parsing errors - pass through to original fetch
7885 }
7986 }
8087
8188 return originalGlobalFetch ( input , init )
8289 }
8390
84- // Return cleanup function to restore original fetch
8591 return ( ) => {
8692 globalThis . fetch = originalGlobalFetch
8793 }
Original file line number Diff line number Diff line change @@ -72,6 +72,20 @@ export function createChatParamsHandler(
7272 providerID = input . message . model . providerID
7373 }
7474
75+ // Track the last seen session ID for fetch wrapper correlation
76+ state . lastSeenSessionId = sessionId
77+
78+ // Check if this is a subagent session and track it to skip fetch wrapper processing
79+ if ( ! state . subagentSessions . has ( sessionId ) ) {
80+ const isSubagent = await isSubagentSession ( client , sessionId )
81+ if ( isSubagent ) {
82+ state . subagentSessions . add ( sessionId )
83+ logger . info ( "chat.params" , "Detected subagent session, will skip DCP processing" , {
84+ sessionId : sessionId . substring ( 0 , 8 )
85+ } )
86+ }
87+ }
88+
7589 // Cache model info for the session
7690 if ( providerID && modelID ) {
7791 state . model . set ( sessionId , {
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ export interface PluginState {
2222 googleToolCallMapping : Map < string , Map < string , string > >
2323 /** Set of session IDs that have been restored from disk */
2424 restoredSessions : Set < string >
25+ /** Set of session IDs that are subagents (have a parentID) - used to skip fetch wrapper processing */
26+ subagentSessions : Set < string >
27+ /** The most recent session ID seen in chat.params - used to correlate fetch requests */
28+ lastSeenSessionId : string | null
2529}
2630
2731export interface ToolParameterEntry {
@@ -45,6 +49,8 @@ export function createPluginState(): PluginState {
4549 model : new Map ( ) ,
4650 googleToolCallMapping : new Map ( ) ,
4751 restoredSessions : new Set ( ) ,
52+ subagentSessions : new Set ( ) ,
53+ lastSeenSessionId : null ,
4854 }
4955}
5056
You can’t perform that action at this time.
0 commit comments