@@ -18,10 +18,7 @@ import type {
1818 ToolResultPart ,
1919} from '@codebuff/common/types/messages/content-part'
2020import type { PrintModeEvent } from '@codebuff/common/types/print-mode'
21- import type {
22- AgentState ,
23- AgentTemplateType ,
24- } from '@codebuff/common/types/session-state'
21+ import type { AgentState } from '@codebuff/common/types/session-state'
2522import type { ProjectFileContext } from '@codebuff/common/util/file'
2623import type { WebSocket } from 'ws'
2724
@@ -54,7 +51,6 @@ export async function runProgrammaticStep(
5451 clientSessionId,
5552 fingerprintId,
5653 onResponseChunk,
57- agentType,
5854 fileContext,
5955 ws,
6056 localAgentTemplates,
@@ -68,7 +64,6 @@ export async function runProgrammaticStep(
6864 clientSessionId : string
6965 fingerprintId : string
7066 onResponseChunk : ( chunk : string | PrintModeEvent ) => void
71- agentType : AgentTemplateType
7267 fileContext : ProjectFileContext
7368 ws : WebSocket
7469 localAgentTemplates : Record < string , AgentTemplate >
@@ -194,9 +189,9 @@ export async function runProgrammaticStep(
194189 )
195190 }
196191
192+ const excludeToolFromMessageHistory = toolCall ?. includeToolCall === false
197193 // Add assistant message with the tool call before executing it
198- // Exception: don't add tool call message for add_message since it adds its own message
199- if ( toolCall ?. includeToolCall !== false ) {
194+ if ( ! excludeToolFromMessageHistory ) {
200195 const toolCallString = getToolCallString (
201196 toolCall . toolName ,
202197 toolCall . input ,
@@ -232,6 +227,7 @@ export async function runProgrammaticStep(
232227 state,
233228 userId,
234229 autoInsertEndStepParam : true ,
230+ excludeToolFromMessageHistory,
235231 } )
236232
237233 // TODO: Remove messages from state and always use agentState.messageHistory.
0 commit comments