File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ export const env = createEnv({
107107 AWS_REGION : z . string ( ) . optional ( ) ,
108108
109109 SOURCEBOT_CHAT_MODEL_TEMPERATURE : numberSchema . default ( 0.3 ) ,
110- SOURCEBOT_CHAT_MAX_STEP_COUNT : numberSchema . default ( 20 ) ,
110+ SOURCEBOT_CHAT_MAX_STEP_COUNT : numberSchema . default ( 10 ) ,
111111
112112 DEBUG_WRITE_CHAT_MESSAGES_TO_FILE : booleanSchema . default ( 'false' ) ,
113113 } ,
Original file line number Diff line number Diff line change @@ -71,6 +71,13 @@ export const createAgentStream = async ({
7171 }
7272 }
7373
74+ if ( stepNumber === env . SOURCEBOT_CHAT_MAX_STEP_COUNT - 1 ) {
75+ return {
76+ system : `**CRITICAL**: You have reached the maximum number of steps!! YOU MUST PROVIDE YOUR FINAL ANSWER NOW. DO NOT KEEP RESEARCHING.\n\n${ answerInstructions } ` ,
77+ activeTools : [ ] ,
78+ }
79+ }
80+
7481 return undefined ;
7582 } ,
7683 temperature : env . SOURCEBOT_CHAT_MODEL_TEMPERATURE ,
@@ -170,6 +177,11 @@ During the research phase, you have these tools available:
170177Use these tools to gather comprehensive context before answering. Always explain why you're using each tool.
171178</research_phase_instructions>
172179
180+ ${ answerInstructions }
181+ ` ;
182+ }
183+
184+ const answerInstructions = `
173185<answer_instructions>
174186When you have sufficient context, output your answer as a structured markdown response.
175187
@@ -196,7 +208,6 @@ Authentication in Sourcebot is built on NextAuth.js with a session-based approac
196208
197209</answer_instructions>
198210` ;
199- }
200211
201212interface FileSourcesSystemPromptOptions {
202213 files : {
You can’t perform that action at this time.
0 commit comments