@@ -1140,7 +1140,7 @@ export class Cline {
11401140 const contextWindow = this . api . getModel ( ) . info . contextWindow || 64_000 // minimum context (Deepseek)
11411141 const maxAllowedSize = getMaxAllowedSize ( contextWindow )
11421142
1143- const terminalInfo = await this . terminalManager . getOrCreateTerminal ( cwd )
1143+ const terminalInfo = await this . terminalManager . getOrCreateTerminal ( cwd , contextWindow )
11441144 terminalInfo . terminal . show ( ) // weird visual bug when creating new terminals (even manually) where there's an empty space at the top.
11451145 const process = this . terminalManager . runCommand ( terminalInfo , command , maxAllowedSize )
11461146
@@ -1188,7 +1188,7 @@ export class Cline {
11881188 // the correct order of messages (although the webview is smart about
11891189 // grouping command_output messages despite any gaps anyways)
11901190 await delay ( 50 )
1191-
1191+ // AKF TODO -> investigate failed results
11921192 result = result . trim ( )
11931193
11941194 if ( userFeedback ) {
@@ -1314,10 +1314,6 @@ export class Cline {
13141314 const { tokensIn, tokensOut, cacheWrites, cacheReads } : ClineApiReqInfo = JSON . parse ( previousRequest . text )
13151315 const totalTokens = ( tokensIn || 0 ) + ( tokensOut || 0 ) + ( cacheWrites || 0 ) + ( cacheReads || 0 )
13161316 let contextWindow = this . api . getModel ( ) . info . contextWindow || 64_000 // minimum context (Deepseek)
1317- // FIXME: hack to get anyone using openai compatible with deepseek to have the proper context window instead of the default 128k. We need a way for the user to specify the context window for models they input through openai compatible
1318- if ( this . api instanceof OpenAiHandler && this . api . getModel ( ) . id . toLowerCase ( ) . includes ( "deepseek" ) ) {
1319- contextWindow = 64_000
1320- }
13211317 const maxAllowedSize = getMaxAllowedSize ( contextWindow )
13221318
13231319 // This is the most reliable way to know when we're close to hitting the context window.
@@ -1964,17 +1960,15 @@ export class Cline {
19641960 }
19651961 // Get context window and used context from API model
19661962 const contextWindow = this . api . getModel ( ) . info . contextWindow || 64_000 // minimum context (Deepseek)
1967- const maxAllowedSize = getMaxAllowedSize ( contextWindow )
19681963
1969- // now execute the tool like normal
1970- const content = await extractTextFromFile ( absolutePath , maxAllowedSize )
1964+ // Pass the raw context window size - extractTextFromFile will calculate the appropriate limit
1965+ const content = await extractTextFromFile ( absolutePath , contextWindow )
19711966 pushToolResult ( content )
19721967
19731968 break
19741969 }
19751970 } catch ( error ) {
19761971 await handleError ( "reading file" , error )
1977-
19781972 break
19791973 }
19801974 }
@@ -2969,6 +2963,16 @@ export class Cline {
29692963 throw new Error ( "Cline instance aborted" )
29702964 }
29712965
2966+ // Log file content being passed to model
2967+ userContent . forEach ( ( block ) => {
2968+ if ( block . type === "text" && block . text ) {
2969+ // Look for file content markers
2970+ if ( block . text . includes ( "<file_content" ) || block . text . includes ( "<final_file_content" ) ) {
2971+ console . log ( `[MODEL_INPUT] File content being passed to model. Content length: ${ block . text . length } chars` )
2972+ }
2973+ }
2974+ } )
2975+
29722976 if ( this . consecutiveMistakeCount >= 3 ) {
29732977 if ( this . autoApprovalSettings . enabled && this . autoApprovalSettings . enableNotifications ) {
29742978 showSystemNotification ( {
@@ -3438,33 +3442,44 @@ export class Cline {
34383442 if ( busyTerminals . length > 0 ) {
34393443 // terminals are cool, let's retrieve their output
34403444 terminalDetails += "\n\n# Actively Running Terminals"
3441- for ( const busyTerminal of busyTerminals ) {
3442- terminalDetails += `\n## Original command: \`${ busyTerminal . lastCommand } \``
3443- const newOutput = this . terminalManager . getUnretrievedOutput ( busyTerminal . id )
3444- if ( newOutput ) {
3445- terminalDetails += `\n### New Output\n${ newOutput } `
3446- } else {
3447- // details += `\n(Still running, no new output)` // don't want to show this right after running the command
3445+ const contextWindow = this . api . getModel ( ) . info . contextWindow || 64_000 // minimum context (Deepseek)
3446+
3447+ // Get output from all busy terminals
3448+ const busyOutputs = await Promise . all (
3449+ busyTerminals . map ( async ( terminal ) => {
3450+ const output = await this . terminalManager . getUnretrievedOutput ( terminal . id , contextWindow )
3451+ return { terminal, output }
3452+ } ) ,
3453+ )
3454+
3455+ // Add output to details
3456+ for ( const { terminal, output } of busyOutputs ) {
3457+ terminalDetails += `\n## Original command: \`${ terminal . lastCommand } \``
3458+ if ( output ) {
3459+ terminalDetails += `\n### New Output\n${ output } `
34483460 }
34493461 }
34503462 }
3463+
34513464 // only show inactive terminals if there's output to show
34523465 if ( inactiveTerminals . length > 0 ) {
3453- const inactiveTerminalOutputs = new Map < number , string > ( )
3454- for ( const inactiveTerminal of inactiveTerminals ) {
3455- const newOutput = this . terminalManager . getUnretrievedOutput ( inactiveTerminal . id )
3456- if ( newOutput ) {
3457- inactiveTerminalOutputs . set ( inactiveTerminal . id , newOutput )
3458- }
3459- }
3460- if ( inactiveTerminalOutputs . size > 0 ) {
3466+ const contextWindow = this . api . getModel ( ) . info . contextWindow || 64_000 // minimum context (Deepseek)
3467+
3468+ // Get output from all inactive terminals
3469+ const inactiveOutputs = await Promise . all (
3470+ inactiveTerminals . map ( async ( terminal ) => {
3471+ const output = await this . terminalManager . getUnretrievedOutput ( terminal . id , contextWindow )
3472+ return { terminal, output }
3473+ } ) ,
3474+ )
3475+
3476+ // Filter and add outputs that have content
3477+ const outputsWithContent = inactiveOutputs . filter ( ( { output } ) => output )
3478+ if ( outputsWithContent . length > 0 ) {
34613479 terminalDetails += "\n\n# Inactive Terminals"
3462- for ( const [ terminalId , newOutput ] of inactiveTerminalOutputs ) {
3463- const inactiveTerminal = inactiveTerminals . find ( ( t ) => t . id === terminalId )
3464- if ( inactiveTerminal ) {
3465- terminalDetails += `\n## ${ inactiveTerminal . lastCommand } `
3466- terminalDetails += `\n### New Output\n${ newOutput } `
3467- }
3480+ for ( const { terminal, output } of outputsWithContent ) {
3481+ terminalDetails += `\n## ${ terminal . lastCommand } `
3482+ terminalDetails += `\n### New Output\n${ output } `
34683483 }
34693484 }
34703485 }
0 commit comments