Skip to content

Commit cb69a18

Browse files
committed
Update base-lite to use gpt-5 medium effort. Overhaul prompting: no end_turn tool, must use a tool per response unless done.
1 parent 9e0f21a commit cb69a18

File tree

6 files changed

+97
-28
lines changed

6 files changed

+97
-28
lines changed

.agents/base-lite.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
import { publisher } from './constants'
2-
import { base } from './factory/base'
1+
import { publisher } from './constants.ts'
2+
import { base } from './factory/base.ts'
33

4-
import type { SecretAgentDefinition } from './types/secret-agent-definition'
4+
import type { SecretAgentDefinition } from './types/secret-agent-definition.ts'
55

66
const definition: SecretAgentDefinition = {
77
id: 'base-lite',
88
publisher,
9-
...base('openai/gpt-5-chat', 'lite'),
9+
...base('openai/gpt-5', 'lite'),
10+
reasoningOptions: {
11+
enabled: true,
12+
effort: 'medium',
13+
exclude: true,
14+
},
15+
toolNames: [
16+
'create_plan',
17+
'run_terminal_command',
18+
'str_replace',
19+
'write_file',
20+
'spawn_agents',
21+
'spawn_agent_inline',
22+
'add_subgoal',
23+
'browser_logs',
24+
'code_search',
25+
'read_files',
26+
'update_subgoal',
27+
],
1028
spawnableAgents: [
1129
'file-explorer',
12-
'file-picker',
1330
'web-researcher',
1431
'docs-researcher',
1532
'context-pruner',

.agents/base-quick.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { publisher } from './constants'
2+
import { base } from './factory/base'
3+
4+
import type { SecretAgentDefinition } from './types/secret-agent-definition'
5+
6+
const definition: SecretAgentDefinition = {
7+
id: 'base-quick',
8+
publisher,
9+
...base('openai/gpt-5-chat', 'lite'),
10+
toolNames: [
11+
'create_plan',
12+
'run_terminal_command',
13+
'str_replace',
14+
'write_file',
15+
'spawn_agents',
16+
'spawn_agent_inline',
17+
'add_subgoal',
18+
'browser_logs',
19+
'code_search',
20+
'read_files',
21+
'update_subgoal',
22+
],
23+
spawnableAgents: [
24+
'file-explorer',
25+
'web-researcher',
26+
'docs-researcher',
27+
'context-pruner',
28+
],
29+
}
30+
31+
export default definition

.agents/factory/base.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
baseAgentSystemPrompt,
66
baseAgentUserInputPrompt,
77
} from '../prompts'
8-
import { AgentTemplateTypes } from '../types/secret-agent-definition'
98

109
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
1110
import type { ModelName } from 'types/agent-definition'
@@ -50,15 +49,15 @@ export const base = (
5049
'update_subgoal',
5150
],
5251
spawnableAgents: [
53-
AgentTemplateTypes.file_explorer,
54-
AgentTemplateTypes.file_picker,
55-
AgentTemplateTypes.researcher,
56-
AgentTemplateTypes.thinker,
57-
AgentTemplateTypes.reviewer,
52+
'file-explorer',
53+
'file-picker',
54+
'researcher',
55+
'thinker',
56+
'reviewer',
5857
'context-pruner',
5958
],
6059

61-
systemPrompt: baseAgentSystemPrompt(model),
60+
systemPrompt: baseAgentSystemPrompt(model, mode),
6261
instructionsPrompt: baseAgentUserInputPrompt(model, mode),
6362
stepPrompt: baseAgentAgentStepPrompt(model),
6463

.agents/factory/thinking-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const thinkingBase = (
5353
? (allAvailableAgents as any[])
5454
: baseAgentSubagents,
5555

56-
systemPrompt: baseAgentSystemPrompt(model),
56+
systemPrompt: baseAgentSystemPrompt(model, 'normal'),
5757
instructionsPrompt: baseAgentUserInputPrompt(model, 'normal'),
5858
stepPrompt: baseAgentAgentStepPrompt(model),
5959

.agents/prompts/base-prompts.ts

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import { PLACEHOLDER } from '../types/secret-agent-definition'
77

88
import type { Model } from '@codebuff/common/old-constants'
99

10-
export const baseAgentSystemPrompt = (model: Model) => {
10+
export const baseAgentSystemPrompt = (
11+
model: Model,
12+
mode: 'lite' | 'normal' | 'max' | 'experimental',
13+
) => {
1114
const isGPT5 = model === models.openrouter_gpt5
15+
const isLite = mode === 'lite'
1216

1317
return `# Persona: ${PLACEHOLDER.AGENT_NAME}
1418
@@ -61,7 +65,7 @@ Messages from the system are surrounded by <system>${closeXml('system')} or <sys
6165
- **MANDATORY EMPTY LINES:** Tool calls **MUST** be surrounded by a _single empty line_ both before the opening tag (e.g., \`<tool_name>\`) and after the closing tag (e.g., \`${closeXml('tool_name')}\`). See the example below. **Failure to include these empty lines will break the process.**
6266
- **NESTED ELEMENTS ONLY:** Tool parameters **MUST** be specified using _only_ nested XML elements, like \`<parameter_name>value${closeXml('parameter_name')}\`. You **MUST NOT** use XML attributes within the tool call tags (e.g., writing \`<tool_name attribute="value">\`). Stick strictly to the nested element format shown in the example response below. This is absolutely critical for the parser.
6367
- **User Questions:** If the user is asking for help with ideas or brainstorming, or asking a question, then you should directly answer the user's question, but do not make any changes to the codebase. Do not call modification tools like \`write_file\` or \`str_replace\`.
64-
${isGPT5 ? '- **Proactive Execution:** Use tools comprehensively — read files, search code, spawn agents, run commands that enhance delivery. Work autonomously across multiple tool calls; only call end_turn when complete or explicitly blocked.\n' : ''}
68+
${isGPT5 ? '- **Proactive Execution:** Use tools comprehensively — read files, search code, spawn agents, run commands that enhance delivery. Work autonomously across multiple tool calls; only stop when complete or explicitly blocked.\n' : ''}
6569
- **Handling Requests:**
6670
- For complex requests, create a subgoal using \`add_subgoal\` to track objectives from the user request. Use \`update_subgoal\` to record progress. Put summaries of actions taken into the subgoal's \`log\`.
6771
- For straightforward requests, proceed directly without adding subgoals.
@@ -88,11 +92,15 @@ ${isGPT5 ? '- **Proactive Execution:** Use tools comprehensively — read files
8892
8993
- **Don't summarize your changes** Omit summaries as much as possible${model === models.openrouter_gpt5 ? '' : '. Be extremely concise when explaining the changes you made'}. There's no need to write a long explanation of what you did. Keep it to 1-2 two sentences max.
9094
- **Ending Your Response:** Your aim should be to completely fulfill the user's request before using ending your response. DO NOT END TURN IF YOU ARE STILL WORKING ON THE USER'S REQUEST. If the user's request requires multiple steps, please complete ALL the steps before stopping, even if you have done a lot of work so far.
91-
- **FINALLY, YOU MUST USE THE END TURN TOOL** When you have fully answered the user _or_ you are explicitly waiting for the user's next typed input, always conclude the message with a standalone \`${getToolCallString('end_turn', {})}\` tool call (surrounded by its required blank lines). This should be at the end of your message, e.g.:
95+
${
96+
!isGPT5 &&
97+
`- **FINALLY, YOU MUST USE THE END TURN TOOL** When you have fully answered the user _or_ you are explicitly waiting for the user's next typed input, always conclude the message with a standalone \`${getToolCallString('end_turn', {})}\` tool call (surrounded by its required blank lines). This should be at the end of your message, e.g.:
9298
<example>
9399
User: Hi
94100
Assisistant: Hello, what can I do for you today?\\n\\n${getToolCallString('end_turn', {})}
95101
${closeXml('example')}
102+
`
103+
}
96104
97105
## Verifying Your Changes at the End of Your Response
98106
@@ -141,7 +149,7 @@ ${getToolCallString('run_terminal_command', { command: 'npm run typecheck' })}
141149
142150
I see that my changes went through correctly. What would you like to do next?
143151
144-
${getToolCallString('end_turn', {})}
152+
${isGPT5 ? '' : getToolCallString('end_turn', {})}
145153
146154
${PLACEHOLDER.TOOLS_PROMPT}
147155
@@ -210,7 +218,7 @@ To stop a background process, attempt to close the process using the appropriate
210218
211219
When you want to restart a background process, make sure to run the terminal command in the background.
212220
213-
${PLACEHOLDER.FILE_TREE_PROMPT}
221+
${isLite ? PLACEHOLDER.FILE_TREE_PROMPT_SMALL : PLACEHOLDER.FILE_TREE_PROMPT}
214222
215223
${PLACEHOLDER.SYSTEM_INFO_PROMPT}
216224
@@ -225,21 +233,24 @@ export const baseAgentUserInputPrompt = (
225233
model === models.gemini2_5_flash ||
226234
model === models.gemini2_5_flash_thinking
227235
const isGeminiPro = model === models.gemini2_5_pro_preview
228-
const isGPT5 = model === models.openrouter_gpt5
236+
const isGPT5 =
237+
model === models.openrouter_gpt5 || model === models.openrouter_gpt5_chat
229238
const isLite = mode === 'lite'
230239

231240
return (
232241
PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS +
233242
'\n\n<system_instructions>' +
234243
buildArray(
235-
`Proceed toward the user request and any subgoals. Please either 1. clarify the request or 2. complete the entire user request. ${isLite ? '' : 'If you made any changes to the codebase, you must spawn the reviewer agent to review your changes. '}Then, finally you must use the end_turn tool at the end of your response. If you have already completed the user request, write nothing at all and end your response.`,
244+
`Proceed toward the user request and any subgoals. Please either 1. clarify the request or 2. complete the entire user request. ${isLite ? '' : 'If you made any changes to the codebase, you must spawn the reviewer agent to review your changes. '}${isGPT5 ? '' : 'Then, finally you must use the end_turn tool at the end of your response. '}If you have already completed the user request, write nothing at all and end your response.`,
236245

237-
"If there are multiple ways the user's request could be interpreted that would lead to very different outcomes, ask at least one clarifying question that will help you understand what they are really asking for, and then use the end_turn tool.",
246+
`If there are multiple ways the user's request could be interpreted that would lead to very different outcomes (not just minor differences), ask at least one clarifying question that will help you understand what they are really asking for${isGPT5 ? '.' : ', and then use the end_turn tool.'}`,
238247

239248
'Use the spawn_agents tool (and not spawn_agent_inline!) to spawn agents to help you complete the user request. You can spawn as many agents as you want.',
240249

241250
`It is a good idea to spawn a file explorer agent first to explore the codebase from different perspectives. Use the researcher agent to help you get up-to-date information from docs and web results too. After that, for complex requests, you should spawn the thinker agent to do deep thinking on a problem, but do not spawn it at the same time as the file picker, only spawn it *after* you have the file picker results. ${isLite ? '' : 'Finally, you must spawn the reviewer agent to review your code changes.'}`,
242-
"Important: you *must* read as many files with the read_files tool as possible from the results of the file picker agents. Don't be afraid to read 20 files. The more files you read, the better context you have on the codebase and the better your response will be.",
251+
isGPT5 &&
252+
'Important: You must spawn a file-explorer agent first to explore the codebase from different perspectives for non-trivial requests. This is an inexpensive way to get a lot of context on the codebase.',
253+
`Important: you *must* read as many files with the read_files tool as possible from the results of the file picker agents. Don't be afraid to read ${isLite ? '8' : '20'} files. The more files you read, the better context you have on the codebase and the better your response will be.`,
243254

244255
'If the users uses "@AgentName" in their message, you must spawn the agent with the name "@AgentName". Spawn all the agents that the user mentions.',
245256

@@ -264,6 +275,8 @@ export const baseAgentUserInputPrompt = (
264275

265276
'Preserve as much of the existing code, its comments, and its behavior as possible. Make minimal edits to accomplish only the core of what is requested. Pay attention to any comments in the file you are editing and keep original user comments exactly as they were, line for line.',
266277

278+
'Never write out a tool_result yourself: e.g. {\n "type": "tool_result", "toolCallId": "...",\n // ...\n}. These are generated automatically by the system in response to the tool calls that you make.',
279+
267280
'If you are trying to kill background processes, make sure to kill the entire process GROUP (or tree in Windows), and always prefer SIGTERM signals. If you restart the process, make sure to do so with process_type=BACKGROUND',
268281

269282
!isFlash &&
@@ -272,7 +285,8 @@ export const baseAgentUserInputPrompt = (
272285
(isFlash || isGeminiPro) &&
273286
'Important: When using write_file, do NOT rewrite the entire file. Only show the parts of the file that have changed and write "// ... existing code ..." comments (or "# ... existing code ..", "/* ... existing code ... */", "<!-- ... existing code ... -->", whichever is appropriate for the language) around the changed area. Additionally, in order to delete any code, you must include a deletion comment.',
274287

275-
'If the user request is very complex, consider invoking think_deeply.',
288+
!isGPT5 &&
289+
'If the user request is very complex, consider invoking think_deeply.',
276290

277291
"If the user asks to create a plan, invoke the create_plan tool. Don't act on the plan created by the create_plan tool. Instead, wait for the user to review it.",
278292

@@ -291,12 +305,20 @@ export const baseAgentUserInputPrompt = (
291305
(isLite || isFlash || isGeminiPro) &&
292306
`You must use the spawn_agents tool to spawn agents to help you complete the user request. You can spawn as many agents as you want. It is a good idea to spawn a file explorer agent first to explore the codebase. ${isLite ? '' : 'Finally, you must spawn the reviewer agent to review your code changes.'}`,
293307

294-
'Finally, you must use the end_turn tool at the end of your response when you have completed the user request or want the user to respond to your message.',
308+
!isGPT5 &&
309+
'Finally, you must use the end_turn tool at the end of your response when you have completed the user request or want the user to respond to your message.',
295310

296311
isGPT5 &&
297-
'Work autonomously within single turns using comprehensive tool usage. Take thorough action: read extensively, search patterns, spawn agents for complex tasks, validate quality. Avoid excessive caution when actions serve user interests without permanent damage. \
298-
\
299-
Note: end_turn signals desire for user feedback, not response termination. Use when work chunk complete and need review/direction.',
312+
`Work autonomously within single turns using comprehensive tool usage. Take thorough action: read extensively, search patterns, spawn agents for complex tasks, validate quality. Avoid excessive caution when actions serve user interests without permanent damage. Proactively make decisions that the user would want you to make without needing to be told to do so.
313+
Note: If you seek feedback from the user, don't use any tools, just ask the user a question, but this should be done sparingly.
314+
315+
IMPORTANT: Use must use at least one tool call in every response unless you are done.
316+
For example, if you write something like:
317+
"I'll verify and finish the requested type updates by inspecting the current files and making any remaining edits."
318+
Then you must also include a tool call, e.g.:
319+
"I'll verify and finish the requested type updates by inspecting the current files and making any remaining edits. ${getToolCallString('read_files', { paths: ['src/components/foo.tsx'] })}"
320+
If you don't do this, then your response will be cut off and the turn will be ended automatically.
321+
`,
300322
).join('\n\n') +
301323
closeXml('system_instructions')
302324
)

backend/src/templates/strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export async function formatPrompt(
6060
),
6161
[PLACEHOLDER.FILE_TREE_PROMPT]: getProjectFileTreePrompt(
6262
fileContext,
63-
20_000,
63+
10_000,
6464
'agent',
6565
),
6666
[PLACEHOLDER.GIT_CHANGES_PROMPT]: getGitChangesPrompt(fileContext),

0 commit comments

Comments
 (0)