File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -231,12 +231,16 @@ const taskToToolCall = (task: Task): ChatCompletionMessageToolCall => ({
231231
232232/**
233233 * Converts a Task result to ActionChatMessageContent
234- * Assumes task.result is always a string
234+ * Ensures task.result is converted to string before adding to content
235235 */
236236const taskResultToContent = ( task : Task ) : ActionChatMessageContent => {
237+ const content = typeof task . result === 'string'
238+ ? task . result
239+ : JSON . stringify ( task . result )
240+
237241 return {
238242 type : 'BLANK' ,
239- content : task . result as string ,
243+ content,
240244 renderInfo : {
241245 text : '' ,
242246 code : undefined ,
Original file line number Diff line number Diff line change @@ -523,14 +523,29 @@ const migrations = {
523523 let newState = { ...state }
524524 newState . settings . useTeamMemory = false
525525 return newState
526+ } ,
527+ 59 : ( state : RootState ) => {
528+ let newState = { ...state }
529+ // Ensure all tool call responses in chat messages are strings
530+ newState . chat . threads . forEach ( ( thread ) => {
531+ thread . messages . forEach ( ( message ) => {
532+ if ( message . role === 'tool' && message . content && message . content . content !== undefined ) {
533+ // If content is not already a string, convert it to string
534+ if ( typeof message . content . content !== 'string' ) {
535+ message . content . content = JSON . stringify ( message . content . content )
536+ }
537+ }
538+ } )
539+ } )
540+ return newState
526541 }
527542}
528543
529544const BLACKLIST = [ 'billing' , 'cache' , userStateApi . reducerPath , atlasApi . reducerPath ]
530545
531546const persistConfig = {
532547 key : 'root' ,
533- version : 57 ,
548+ version : 59 ,
534549 storage,
535550 blacklist : BLACKLIST ,
536551 // @ts -ignore
You can’t perform that action at this time.
0 commit comments