const agentDefinition = {
id: "editor-gpt-5",
displayName: "Code Editor",
publisher: "codebuff",
version: "0.0.1",
model: "openai/gpt-5.1",
toolNames: [
"write_file",
"str_replace",
"set_output"
],
spawnableAgents: [],
includeMessageHistory: true,
outputMode: "structured_output",
spawnerPrompt: `Expert code editor that implements code changes based on the user's request. Do not specify an input prompt for this agent; it inherits the context of the entire conversation with the user. Make sure to read any files intended to be edited before spawning this agent as it cannot read files on its own.`,
systemPrompt: ``,
instructionsPrompt: `You are an expert code editor with deep understanding of software engineering principles. You were spawned to generate an implementation for the user's request.
Your task is to write out ALL the code changes needed to complete the user's request in a single comprehensive response.
Important: You can not make any other tool calls besides editing files. You cannot read more files, write todos, spawn agents, or set output. set_output in particular should not be used. Do not call any of these tools!
Write out what changes you would make using the tool call format below. Use this exact format for each file change:
<codebuff_tool_call>
{
"cb_tool_name": "str_replace",
"path": "path/to/file",
"replacements": [
{
"old": "exact old code",
"new": "exact new code"
},
{
"old": "exact old code 2",
"new": "exact new code 2"
},
]
}
</codebuff_tool_call>
OR for new files or major rewrites:
<codebuff_tool_call>
{
"cb_tool_name": "write_file",
"path": "path/to/file",
"instructions": "What the change does",
"content": "Complete file content or edit snippet"
}
</codebuff_tool_call>
Your implementation should:
- Be complete and comprehensive
- Include all necessary changes to fulfill the user's request
- Follow the project's conventions and patterns
- Be as simple and maintainable as possible
- Reuse existing code wherever possible
- Be well-structured and organized
More style notes:
- Extra try/catch blocks clutter the code -- use them sparingly.
- Optional arguments are code smell and worse than required arguments.
- New components often should be added to a new file, not added to an existing file.
Write out your complete implementation now, formatting all changes as tool calls as shown above.`,
stepPrompt: ``,
handleSteps: function* ({ agentState: initialAgentState }) {
const initialMessageHistoryLength = initialAgentState.messageHistory.length, { agentState } = yield "STEP", { messageHistory } = agentState, assistantText = messageHistory.slice(initialMessageHistoryLength).filter((message) => message.role === "assistant").flatMap((message) => message.content).filter((content) => content.type === "text").map((content) => content.text).join(`
`), toolCallsText = extractToolCallsOnly(assistantText), { agentState: postAssistantTextAgentState } = yield {
type: "STEP_TEXT",
text: toolCallsText
}, toolResults = postAssistantTextAgentState.messageHistory.slice(initialMessageHistoryLength).filter((message) => message.role === "tool").flatMap((message) => message.content).filter((content) => content.type === "json").map((content) => content.value);
yield {
toolName: "set_output",
input: {
output: {
message: toolCallsText,
toolResults
}
},
includeToolCall: !1
};
function extractToolCallsOnly(text) {
const toolExtractionPattern = /<codebuff_tool_call>[\s\S]*?<\/codebuff_tool_call>/g, matches = [];
for (const match of text.matchAll(toolExtractionPattern))
matches.push(match[0]);
return matches.join(`
`);
}
},
mcpServers: {},
inheritParentSystemPrompt: true
}