@@ -627,6 +627,11 @@ async function uploadTaskFiles(
627627 return results ;
628628}
629629
630+ /** Max length the server stores for a chat history summary; longer values
631+ * are rejected by the database, which would roll back the status update sent
632+ * with it. The full text is preserved in the task's end step. */
633+ const MAX_CHAT_HISTORY_SUMMARY_LENGTH = 1024 ;
634+
630635export interface StartTaskOptions {
631636 preserveTaskId ?: boolean ;
632637 skipHistoryCreate ?: boolean ;
@@ -2367,7 +2372,9 @@ const chatStore = (initial?: Partial<ChatStore>) =>
23672372 agentMessages . data ! . summary_task ?. split ( '|' ) [ 0 ] || '' ;
23682373 const obj = {
23692374 project_name : projectName ,
2370- summary : agentMessages . data ! . summary_task ?. split ( '|' ) [ 1 ] || '' ,
2375+ summary : (
2376+ agentMessages . data ! . summary_task ?. split ( '|' ) [ 1 ] || ''
2377+ ) . slice ( 0 , MAX_CHAT_HISTORY_SUMMARY_LENGTH ) ,
23712378 status : 1 ,
23722379 tokens : getTokens ( currentTaskId ) ,
23732380 } ;
@@ -2750,7 +2757,9 @@ const chatStore = (initial?: Partial<ChatStore>) =>
27502757 tasks [ currentTaskId ] . summaryTask . split ( '|' ) [ 0 ] ;
27512758 const obj = {
27522759 project_name : projectName ,
2753- summary : tasks [ currentTaskId ] . summaryTask . split ( '|' ) [ 1 ] ,
2760+ summary : (
2761+ tasks [ currentTaskId ] . summaryTask . split ( '|' ) [ 1 ] || ''
2762+ ) . slice ( 0 , MAX_CHAT_HISTORY_SUMMARY_LENGTH ) ,
27542763 status : 1 ,
27552764 tokens : getTokens ( currentTaskId ) ,
27562765 } ;
@@ -3618,7 +3627,10 @@ const chatStore = (initial?: Partial<ChatStore>) =>
36183627 const projectName = parts [ 0 ] || '' ;
36193628 const obj = {
36203629 project_name : projectName ,
3621- summary : completionSummary ,
3630+ summary : completionSummary . slice (
3631+ 0 ,
3632+ MAX_CHAT_HISTORY_SUMMARY_LENGTH
3633+ ) ,
36223634 status : wasStoppedByUser ? 1 : 2 ,
36233635 tokens : getTokens ( currentTaskId ) ,
36243636 } ;
0 commit comments