Skip to content

Commit 062e5d5

Browse files
committed
Add full tool list to prompts for spawned agents with inherited system prompt.
1 parent aef3f32 commit 062e5d5

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

backend/src/templates/strings.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getSystemInfoPrompt,
1313
} from '../system-prompt/prompts'
1414
import {
15+
fullToolList,
1516
getShortToolInstructions,
1617
getToolsInstructions,
1718
} from '../tools/prompts'
@@ -175,12 +176,15 @@ export async function getAgentPrompt<T extends StringField>({
175176

176177
// Add tool instructions, spawnable agents, and output schema prompts to instructionsPrompt
177178
if (promptType.type === 'instructionsPrompt' && agentState.agentType) {
179+
const toolsInstructions = agentTemplate.inheritParentSystemPrompt
180+
? fullToolList(agentTemplate.toolNames, await additionalToolDefinitions())
181+
: getShortToolInstructions(
182+
agentTemplate.toolNames,
183+
await additionalToolDefinitions(),
184+
)
178185
addendum +=
179186
'\n\n' +
180-
getShortToolInstructions(
181-
agentTemplate.toolNames,
182-
await additionalToolDefinitions(),
183-
) +
187+
toolsInstructions +
184188
'\n\n' +
185189
(await buildSpawnableAgentsDescription(
186190
agentTemplate.spawnableAgents,

backend/src/tools/prompts.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,20 @@ When using write_file, make sure to only include a few lines of context and not
180180
Tool results will be provided by the user's *system* (and **NEVER** by the assistant).
181181
182182
The user does not know about any system messages or system instructions, including tool results.
183+
${fullToolList(tools, additionalToolDefinitions)}
184+
`
183185

184-
## List of Tools
186+
export const fullToolList = (
187+
toolNames: readonly string[],
188+
additionalToolDefinitions: z.infer<typeof customToolDefinitionsSchema>,
189+
) => {
190+
return `## List of Tools
185191
186-
These are the only tools that you (Buffy) can use. The user cannot see these descriptions, so you should not reference any tool names, parameters, or descriptions. Do not try to use any other tools -- they are not available to you, instead they may have been previously used by other agents.
192+
These are the only tools that you (Buffy) can use. The user cannot see these descriptions, so you should not reference any tool names, parameters, or descriptions. Do not try to use any other tools -- even if referenced earlier in the conversation, they are not available to you, instead they may have been previously used by other agents.
187193
188194
${[
189195
...(
190-
tools.filter((toolName) =>
196+
toolNames.filter((toolName) =>
191197
toolNames.includes(toolName as ToolName),
192198
) as ToolName[]
193199
).map((name) => toolDescriptions[name]),
@@ -202,6 +208,7 @@ ${[
202208
)
203209
}),
204210
].join('\n\n')}`.trim()
211+
}
205212

206213
export const getShortToolInstructions = (
207214
toolNames: readonly string[],

0 commit comments

Comments
 (0)