You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/src/templates/base-prompts.ts
+8-14Lines changed: 8 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -84,22 +84,17 @@ Messages from the system are surrounded by <system>${closeXml('system')} or <sys
84
84
- Create an impressive demonstration showcasing web development capabilities
85
85
86
86
- **Don't summarize your changes** Omit summaries as much as possible. 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.
87
-
- **end_turn:** Use end_turn only when waiting for the user's next input or when the task is fully complete; never immediately after planning or non-final tools (read_files, code_search, spawn_agents, think_deeply, create_plan, add_subgoal, update_subgoal, or diagnostic run_terminal_command).
88
-
89
-
90
-
91
-
92
-
- **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.:
87
+
- **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.
88
+
- **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.:
93
89
<example>
94
90
User: Hi
95
-
Assisistant: Hello, what can I do for you today?\n\n${getToolCallString('end_turn',{})}
91
+
Assisistant: Hello, what can I do for you today?\\n\\n${getToolCallString('end_turn',{})}
96
92
${closeXml('example')}
97
93
98
-
99
-
100
-
- **Finally:** When waiting for the user's next input or fully done, end with a standalone ${getToolCallString('end_turn',{})} (with required blank lines); e.g.:
101
94
## Verifying Your Changes at the End of Your Response
95
+
102
96
### User has a \`codebuff.json\`
97
+
103
98
If the user has a \`codebuff.json\` with the appropriate \`fileChangeHooks\`, there is no need to run any commands.
104
99
105
100
If the \`fileChangeHooks\` are not configured, inform the user about the \`fileChangeHooks\` parameter.
'Proceed toward the user request and any subgoals. Please either 1. clarify the request or 2. complete the entire user request. If you made any changes to the codebase, you must spawn the reviewer agent to review your changes. If you have already completed the user request, write nothing at all and end your response.',
227
+
'Proceed toward the user request and any subgoals. Please either 1. clarify the request or 2. complete the entire user request. 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.',
233
228
234
-
"Ask clarifying questions only when ambiguity would materially change the implementation; otherwise make a reasonable assumption (state it briefly) and proceed, or ask one targeted, non-blocking question. When clarifying, do not spawn the reviewer or other agents yet. Wait for the user's reply so you don't hide information.",
229
+
"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.",
235
230
236
231
'Use the spawn_agents tool to spawn subagents to help you complete the user request. You can spawn as many subagents as you want.',
'You must use the spawn_agents tool to spawn subagents to help you complete the user request. You can spawn as many subagents as you want. It is a good idea to spawn a file explorer agent first to explore the codebase. Finally, you must spawn the reviewer agent to review your code changes.',
289
284
290
-
"Use end_turn only when waiting for the user's next input or fully done; never immediately after planning or non-final tools (read_files, code_search, spawn_agents, think_deeply, create_plan, add_subgoal, update_subgoal, or a non-final run_terminal_command).",
291
-
'Never call end_turn immediately after read_files, code_search, spawn_agents, think_deeply, create_plan, add_subgoal, update_subgoal, or a non-final run_terminal_command; keep working or ask one concise question first.',
285
+
'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.',
// event includes streamed updates like assistant messages and tool calls
61
61
console.log('event:', event)
62
62
},
63
+
64
+
// Custom agents (optional)
65
+
agentConfigs: [
66
+
{
67
+
id: 'my-awesome-agent',
68
+
model: 'openai/gpt-5',
69
+
displayName: 'My awesome agent'
70
+
instructionsPrompt: 'Do something awesome'
71
+
// ... other AgentConfig properties
72
+
},
73
+
],
63
74
})
64
75
```
65
76
77
+
## API Reference
78
+
79
+
### `client.run(options)`
80
+
81
+
Runs a Codebuff agent with the specified options.
82
+
83
+
#### Parameters
84
+
85
+
-**`agent`** (string, required): The agent to run. Use `'base'` for the default agent, or specify a custom agent ID if you made your own agent config.
86
+
87
+
-**`prompt`** (string, required): The user prompt describing what you want the agent to do.
88
+
89
+
-**`params`** (object, optional): Additional parameters for the agent. Most agents don't use this, but some custom agents can take a JSON object as input in addition to the user prompt string.
90
+
91
+
-**`handleEvent`** (function, optional): Callback function that receives every event during execution (assistant messages, tool calls, etc.). This allows you to stream the agent's progress in real-time. We will likely add a token-by-token streaming callback in the future.
92
+
93
+
-**`previousRun`** (object, optional): JSON state returned from a previous `run()` call. Use this to continue a conversation or session with the agent, maintaining context from previous interactions.
94
+
95
+
-**`projectFiles`** (object, optional): All the files in your project as a plain JavaScript object. Keys should be the full path from your current directory to each file, and values should be the string contents of the file. Example: `{ "src/index.ts": "console.log('hi')" }`. This helps Codebuff pick good source files for context. Note: This parameter was previously named `allFiles` but has been renamed for clarity.
96
+
97
+
-**`knowledgeFiles`** (object, optional): Knowledge files to inject into every `run()` call. Uses the same schema as `projectFiles` - keys are file paths and values are file contents. These files are added directly to the agent's context.
98
+
99
+
-**`agentConfigs`** (array, optional): Array of custom agent configurations. Each object should satisfy the AgentConfig type.
100
+
-**`maxAgentSteps`** (number, optional): Maximum number of steps the agent can take before stopping. Use this as a safety measure in case your agent starts going off the rails. A reasonable number is around 20.
101
+
102
+
#### Returns
103
+
104
+
Returns a Promise that resolves to a `RunState` object containing:
105
+
106
+
-`sessionState`: The current session state that can be passed to subsequent runs
107
+
-`toolResults`: Results from any tools that were executed during the run
0 commit comments