Codebuff

code-reviewer-best-of-n-gpt-5

v0.0.2
Published Nov 20, 2025

Usage Statistics
v0.0.2

Definition

const agentDefinition = {
id: "code-reviewer-best-of-n-gpt-5",
displayName: "Best-of-N GPT-5 Code Reviewer",
publisher: "codebuff",
version: "0.0.2",
model: "openai/gpt-5.1",
toolNames: [
"spawn_agents"
],
spawnableAgents: [
"codebuff/code-reviewer-selector@0.0.2"
],
inputSchema: {
params: {
type: "object",
properties: {
n: {
type: "number",
description: "Number of parallel reviewer agents to spawn. Defaults to 5. Use fewer for simple reviews and max of 10 for complex reviews."
}
}
}
},
includeMessageHistory: true,
outputMode: "last_message",
spawnerPrompt: `Reviews code by orchestrating multiple reviewer agents to generate review proposals, selects the best one, and provides the final review. Do not specify an input prompt for this agent; it reads the context from the message history.`,
systemPrompt: ``,
instructionsPrompt: `You are one agent within the code-reviewer-best-of-n. You were spawned to generate a comprehensive code review for the recent changes.
Your task is to provide helpful critical feedback on the last file changes made by the assistant. You should find ways to improve the code changes made recently in the above conversation.
Be brief: If you don't have much critical feedback, simply say it looks good in one sentence. No need to include a section on the good parts or "strengths" of the changes -- we just want the critical feedback for what could be improved.
NOTE: You cannot make any changes directly! Nor cany you spawn any other agents, or use any tools. You can only suggest changes.
# Guidelines
- Focus on giving feedback that will help the assistant get to a complete and correct solution as the top priority.
- Make sure all the requirements in the user's message are addressed. You should call out any requirements that are not addressed -- advocate for the user!
- Try to keep any changes to the codebase as minimal as possible.
- Simplify any logic that can be simplified.
- Where a function can be reused, reuse it and do not create a new one.
- Make sure that no new dead code is introduced.
- Make sure there are no missing imports.
- Make sure no sections were deleted that weren't supposed to be deleted.
- Make sure the new code matches the style of the existing code.
- Make sure there are no unnecessary try/catch blocks. Prefer to remove those.
- Look for logical errors in the code.
- Look for missed cases in the code.
- Look for any other bugs.
- Look for opportunities to improve the code's readability.
**Important**: Do not use any tools! You are only reviewing!
For reference, here is the original user request:
<user_message>
{CODEBUFF_USER_INPUT_PROMPT}
</user_message>
Now, give your review. Be concise and focus on the most important issues that need to be addressed.
Be extremely concise and focus on the most important issues that need to be addressed.`,
stepPrompt: ``,
handleSteps: function* handleStepsGpt5({
agentState,
params
}) {
const n = Math.min(10, Math.max(1, params?.n ?? 5)), { nResponses = [] } = yield {
type: "GENERATE_N",
n
}, reviews = nResponses.map((content, index) => ({
id: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[index],
content
})), { toolResult: selectorResult } = yield {
toolName: "spawn_agents",
input: {
agents: [
{
agent_type: "code-reviewer-selector",
params: { reviews }
}
]
},
includeToolCall: !1
}, selectorOutput = extractSpawnResults(selectorResult)[0];
function extractSpawnResults(results) {
if (!results)
return [];
return results.filter((result) => result.type === "json").map((result) => result.value).flat().map((result) => result.value.value ?? {
errorMessage: result.value.errorMessage ?? "Error extracting spawn results"
});
}
if ("errorMessage" in selectorOutput) {
yield {
type: "STEP_TEXT",
text: selectorOutput.errorMessage
};
return;
}
const { reviewId } = selectorOutput, chosenReview = reviews.find((review) => review.id === reviewId);
if (!chosenReview) {
yield {
type: "STEP_TEXT",
text: "Failed to find chosen review."
};
return;
}
yield {
type: "STEP_TEXT",
text: chosenReview.content
};
},
mcpServers: {},
inheritParentSystemPrompt: true
}