Skip to content

Commit 795b3f8

Browse files
committed
Researcher: Grok 4 fast researcher
1 parent ce2873d commit 795b3f8

File tree

8 files changed

+297
-0
lines changed

8 files changed

+297
-0
lines changed

.agents/base-lite-grok-4-fast.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { publisher } from './constants'
2+
import {
3+
PLACEHOLDER,
4+
SecretAgentDefinition,
5+
} from 'types/secret-agent-definition'
6+
import baseLite from './base-lite'
7+
import { buildArray } from '@codebuff/common/util/array'
8+
import { closeXml } from '@codebuff/common/util/xml'
9+
10+
const definition: SecretAgentDefinition = {
11+
...baseLite,
12+
id: 'base-lite-grok-4-fast',
13+
displayName: 'Base Lite Grok 4 Fast',
14+
publisher,
15+
model: 'x-ai/grok-4-fast:free',
16+
spawnableAgents: ['researcher-grok-4-fast', 'thinker', 'reviewer-lite', 'context-pruner'],
17+
instructionsPrompt:
18+
PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS +
19+
'\n\n<system_instructions>' +
20+
buildArray(
21+
`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.`,
22+
23+
`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.`,
24+
25+
'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.',
26+
27+
`It is a good idea to spawn a researcher agent (or two or three) first to explore the codebase from different perspectives, or 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 researcher, only spawn the thinker *after* you have the reasearch results. Finally, you must spawn the reviewer agent to review your code changes.`,
28+
`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 10 files. The more files you read, the better context you have on the codebase and the better your response will be.`,
29+
30+
'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.',
31+
32+
'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 ..." or "/* ... existing code ... */", whichever is appropriate for the language) around the changed area.',
33+
34+
'You must read additional files with the read_files tool whenever it could possibly improve your response.',
35+
36+
'You must use the "add_subgoal" and "update_subgoal" tools to record your progress and any new information you learned as you go. If the change is very minimal, you may not need to use these tools.',
37+
38+
'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.',
39+
40+
'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.',
41+
42+
'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',
43+
44+
'To confirm complex changes to a web app, you should use the browser_logs tool to check for console logs or errors.',
45+
46+
"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.",
47+
48+
'If the user tells you to implement a plan, please implement the whole plan, continuing until it is complete. Do not stop after one step.',
49+
50+
'If the user had knowledge files (or CLAUDE.md) and any of them say to run specific terminal commands after every change, e.g. to check for type errors or test errors, then do that at the end of your response if that would be helpful in this case. No need to run these checks for simple changes.',
51+
52+
'If you have learned something useful for the future that is not derivable from the code, consider updating a knowledge file at the end of your response to add this condensed information.',
53+
54+
'Important: DO NOT run scripts or git commands or start a dev server without being specifically asked to do so. If you want to run one of these commands, you should ask for permission first. This can prevent costly accidents!',
55+
56+
'Otherwise, the user is in charge and you should never refuse what the user asks you to do.',
57+
58+
`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 researcher agent (or two or three) first to search the codebase or the web. Finally, you must spawn the reviewer agent to review your code changes.`,
59+
).join('\n\n') +
60+
closeXml('system_instructions'),
61+
}
62+
63+
export default definition
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
2+
import { publisher } from '../constants'
3+
4+
const definition: SecretAgentDefinition = {
5+
id: 'researcher-codebase-explorer',
6+
publisher,
7+
model: 'x-ai/grok-4-fast:free',
8+
displayName: 'Codebase Explorer',
9+
spawnerPrompt: `Expert at exploring the codebase to find relevant information using terminal commands.`,
10+
inputSchema: {
11+
prompt: {
12+
type: 'string',
13+
description:
14+
'A question you would like answered using technical documentation.',
15+
},
16+
},
17+
outputMode: 'last_message',
18+
includeMessageHistory: false,
19+
toolNames: ['code_search', 'run_terminal_command', 'read_files'],
20+
spawnableAgents: [],
21+
22+
systemPrompt: `You are an expert software engineer who can explore the codebase to find relevant information using terminal commands. Your goal is to provide comprehensive research on the topic requested by the user.`,
23+
instructionsPrompt: `Instructions
24+
1. Use the code_search tool to search the codebase for relevant information.
25+
2. Use the run_terminal_command tool to run terminal commands to explore the codebase.
26+
3. Use the read_files tool to read all the files that could be relevant to the user's question. It's important to read a lot of files to get a comprehensive understanding of the codebase.
27+
4. Repeat the code_search, run_terminal_command, and read_files tool calls until you have gathered all the relevant information.
28+
5. Provide a comprehensive report of the relevant information for the user's prompt. Include key findings, relevant insights, and actionable recommendations.
29+
`.trim(),
30+
}
31+
32+
export default definition
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
2+
import { publisher } from '../constants'
3+
4+
const definition: SecretAgentDefinition = {
5+
id: 'researcher-docs',
6+
publisher,
7+
model: 'x-ai/grok-4-fast:free',
8+
displayName: 'Doc',
9+
spawnerPrompt: `Expert at reading technical documentation of major public libraries and frameworks to find relevant information. (e.g. React, MongoDB, Postgres, etc.)`,
10+
inputSchema: {
11+
prompt: {
12+
type: 'string',
13+
description:
14+
'A question you would like answered using technical documentation.',
15+
},
16+
},
17+
outputMode: 'last_message',
18+
includeMessageHistory: false,
19+
toolNames: ['read_docs'],
20+
spawnableAgents: [],
21+
22+
systemPrompt: `You are an expert researcher who can read documentation to find relevant information. Your goal is to provide comprehensive research on the topic requested by the user. Use read_docs to get detailed documentation.`,
23+
instructionsPrompt: `Instructions:
24+
1. Use the read_docs tool to get detailed documentation relevant to the user's question.
25+
2. Repeat the read_docs tool call until you have gathered all the relevant documentation.
26+
3. Write up a comprehensive report of the documentation. Include key findings, relevant insights, and actionable recommendations.
27+
`.trim(),
28+
}
29+
30+
export default definition
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { publisher } from '../constants'
2+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
3+
4+
const paramsSchema = {
5+
type: 'object' as const,
6+
properties: {
7+
prompts: {
8+
type: 'array' as const,
9+
items: { type: 'string' },
10+
description:
11+
'List of 1-4 different parts of the codebase that could be useful to explore',
12+
},
13+
},
14+
required: ['prompts'],
15+
}
16+
17+
const fileExplorer: SecretAgentDefinition = {
18+
id: 'researcher-file-explorer',
19+
displayName: 'Dora the File Explorer',
20+
spawnerPrompt:
21+
'Comprehensively explores the codebase and reports back on the results',
22+
model: 'x-ai/grok-4-fast:free',
23+
publisher,
24+
outputMode: 'structured_output',
25+
includeMessageHistory: false,
26+
toolNames: ['spawn_agents', 'set_output'],
27+
spawnableAgents: ['researcher-file-picker'],
28+
inputSchema: {
29+
prompt: {
30+
type: 'string',
31+
description: 'What you need to accomplish by exploring the codebase',
32+
},
33+
params: paramsSchema,
34+
},
35+
systemPrompt:
36+
'You are a file explorer agent that spawns multiple file picker agents in parallel to comprehensively explore the codebase.',
37+
instructionsPrompt: '',
38+
stepPrompt: '',
39+
40+
handleSteps: function* ({ prompt, params }) {
41+
const prompts: string[] = params?.prompts ?? []
42+
const filePickerPrompts = prompts.map(
43+
(focusPrompt) =>
44+
`Based on the overall goal "${prompt}", find files related to this specific area: ${focusPrompt}`,
45+
),
46+
{ toolResult: spawnResult } = yield {
47+
toolName: 'spawn_agents',
48+
input: {
49+
agents: filePickerPrompts.map((promptText) => ({
50+
agent_type: 'researcher-file-picker',
51+
prompt: promptText,
52+
})),
53+
},
54+
}
55+
yield {
56+
toolName: 'set_output',
57+
input: {
58+
results: spawnResult,
59+
},
60+
}
61+
},
62+
}
63+
64+
export default fileExplorer
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { publisher } from '../constants'
2+
import { filePicker } from 'factory/file-picker'
3+
import { SecretAgentDefinition } from 'types/secret-agent-definition'
4+
5+
const definition: SecretAgentDefinition = {
6+
...filePicker('x-ai/grok-4-fast:free'),
7+
id: 'researcher-file-picker',
8+
publisher,
9+
}
10+
11+
export default definition
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {
2+
PLACEHOLDER,
3+
type SecretAgentDefinition,
4+
} from '../types/secret-agent-definition'
5+
import { publisher } from '../constants'
6+
7+
const definition: SecretAgentDefinition = {
8+
id: 'researcher-grok-4-fast',
9+
publisher,
10+
model: 'x-ai/grok-4-fast:free',
11+
displayName: 'Grok 4 Fast Researcher',
12+
toolNames: ['spawn_agents'],
13+
spawnableAgents: [
14+
'researcher-file-explorer',
15+
'researcher-codebase-explorer',
16+
'researcher-web',
17+
'researcher-docs',
18+
],
19+
20+
inputSchema: {
21+
prompt: {
22+
type: 'string',
23+
description: 'Any question',
24+
},
25+
},
26+
outputMode: 'last_message',
27+
includeMessageHistory: true,
28+
29+
spawnerPrompt: `Spawn this agent when you need research a topic and gather information. Can search the codebase and the web.`,
30+
systemPrompt: `You are an expert architect and researcher. You are quick to spawn agents to research the codebase and web, but you only operate in a read-only capacity. (You should not offer to write code or make changes to the codebase.)
31+
32+
You cannot use any other tools beyond the ones provided to you. (No ability to read files, write files, or run terminal commands, etc.)
33+
34+
${PLACEHOLDER.FILE_TREE_PROMPT}
35+
${PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS}`,
36+
37+
instructionsPrompt: `Instructions:
38+
Take as many steps as you need to gather information first:
39+
- Use the spawn_agents tool to spawn agents to research the codebase and web. Spawn as many agents in parallel as possible. Feel free to call it multiple times to find more information.
40+
41+
You should likely spawn both the researcher-file-explorer and researcher-codebase-explorer agents to get a comprehensive understanding of the codebase. You should also spawn the researcher-web and researcher-docs agents to get up-to-date information from the web and docs, if relevant.
42+
43+
Finally, write up a research report that answers the user question to the best of your ability from the information gathered from the agents. Include all the relevant information. Mention which files are relevant to the user question. Be clear and concise.`,
44+
}
45+
46+
export default definition
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
2+
import { publisher } from '../constants'
3+
4+
const definition: SecretAgentDefinition = {
5+
id: 'researcher-web',
6+
publisher,
7+
model: 'x-ai/grok-4-fast:free',
8+
displayName: 'Weeb',
9+
spawnerPrompt: `Expert at browsing the web to find relevant information.`,
10+
inputSchema: {
11+
prompt: {
12+
type: 'string',
13+
description: 'A question you would like answered using web search',
14+
},
15+
},
16+
outputMode: 'last_message',
17+
includeMessageHistory: false,
18+
toolNames: ['web_search'],
19+
spawnableAgents: [],
20+
21+
systemPrompt: `You are an expert researcher who can search the web to find relevant information. Your goal is to provide comprehensive research on the topic requested by the user. Use web_search to find current information.`,
22+
instructionsPrompt: `
23+
Provide comprehensive research on the user's prompt.
24+
25+
Use web_search to find current information. Repeat the web_search tool call until you have gathered all the relevant information.
26+
27+
Then, write up a report that includes key findings, relevant insights, and actionable recommendations for the user's prompt.
28+
`.trim(),
29+
30+
handleSteps: function* ({ agentState, prompt, params }) {
31+
yield {
32+
toolName: 'web_search' as const,
33+
input: { query: prompt || '', depth: 'standard' as const },
34+
}
35+
yield 'STEP_ALL'
36+
},
37+
}
38+
39+
export default definition

.agents/reviewer-lite.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { publisher } from './constants'
2+
import { reviewer } from './factory/reviewer'
3+
4+
import type { SecretAgentDefinition } from './types/secret-agent-definition'
5+
6+
const definition: SecretAgentDefinition = {
7+
id: 'reviewer-lite',
8+
publisher,
9+
...reviewer('x-ai/grok-4-fast:free'),
10+
}
11+
12+
export default definition

0 commit comments

Comments
 (0)