const agentDefinition = {
id: "planner",
displayName: "Peter Plan",
publisher: "codebuff",
version: "0.0.1",
model: "openai/gpt-5-chat",
toolNames: [
"spawn_agents",
"read_files",
"end_turn",
"set_output"
],
spawnableAgents: [
"codebuff/file-explorer@0.0.2",
"codebuff/web-researcher@0.0.1",
"codebuff/docs-researcher@0.0.1",
"codebuff/thinker-gpt-5-high@0.0.1"
],
inputSchema: {
prompt: {
type: "string",
description: "The task to plan for"
}
},
includeMessageHistory: true,
outputMode: "structured_output",
spawnerPrompt: `Creates comprehensive plans by exploring the codebase, doing research on the web, and thinking deeply. You can also use it get deep answer to any question. This is a slow agent -- prefer to use it for complex tasks that require thinking.`,
systemPrompt: `You are an expert programmer, architect, researcher, and general problem solver.
You spawn agents to help you gather information which will be used to create a plan.
{CODEBUFF_FILE_TREE_PROMPT}
{CODEBUFF_KNOWLEDGE_FILES_CONTENTS}`,
instructionsPrompt: `You are gathering information which will be used to create a plan.
- It's helpful to spawn a file-explorer to find all the relevant parts of the codebase. In parallel as part of the same spawn_agents tool call, you may also spawn a web-researcher or docs-researcher to search the web or technical documentation for relevant information.
- After you are satisfied with the information you have gathered from these agents, stop and use the end_turn tool. The plan will be created in a separate step. Do not spawn thinker-gpt-5-high in this step.`,
stepPrompt: ``,
handleSteps: function* ({ prompt }) {
const { agentState } = yield "STEP_ALL", messagesBlob = agentState.messageHistory.slice(2).map((message) => typeof message.content === "string" ? message.content : message.content.map((content) => content.type === "text" ? content.text : "").join(`
`)).join(`
`);
yield {
toolName: "read_files",
input: {
paths: parseFilePathsFromToolResult(messagesBlob)
}
};
const { toolResult: deepThinkerToolResult } = yield {
toolName: "spawn_agents",
input: {
agents: [
{
agent_type: "thinker-gpt-5-high",
prompt: `Create a clear implementation plan for the following task, with a focus on simplicity and making the minimal changes necessary for an awesome implementation. Prompt: ${prompt}`
}
]
}
};
yield {
toolName: "set_output",
input: {
plan: deepThinkerToolResult
}
};
function parseFilePathsFromToolResult(content) {
const filePaths = [], filePathRegex = /(?:^|\s|\*\s*)((?:[\w-]+\/)*[\w.-]+\.[a-zA-Z]{1,4})(?=\s|$|,|\.|:)/gm;
let match;
while ((match = filePathRegex.exec(content)) !== null) {
const filePath = match[1];
if (filePath && !filePath.startsWith("http") && !filePath.includes("@") && filePath.length > 3 && filePath.split("/").length <= 10)
filePaths.push(filePath);
}
const backtickPathRegex = /`([^`]+\.[a-zA-Z]{1,4})`/g;
while ((match = backtickPathRegex.exec(content)) !== null) {
const filePath = match[1];
if (filePath && !filePath.startsWith("http") && !filePath.includes("@"))
filePaths.push(filePath);
}
return [...new Set(filePaths)];
}
}
}