Skip to content

Commit 1efd144

Browse files
committed
add AGENTS_PROMPT to system prompt if not provided
1 parent 8266929 commit 1efd144

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

backend/src/templates/strings.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ export async function collectParentInstructions(
122122
return instructions
123123
}
124124

125+
const additionalPlaceholders = {
126+
systemPrompt: [PLACEHOLDER.TOOLS_PROMPT, PLACEHOLDER.AGENTS_PROMPT],
127+
instructionsPrompt: [],
128+
stepPrompt: [],
129+
} satisfies Record<StringField, string[]>
125130
export async function getAgentPrompt<T extends StringField>(
126131
agentTemplate: AgentTemplate,
127132
promptType: { type: T },
@@ -130,13 +135,9 @@ export async function getAgentPrompt<T extends StringField>(
130135
agentRegistry: AgentRegistry,
131136
): Promise<string | undefined> {
132137
let promptValue = agentTemplate[promptType.type]
133-
addToolsPromptToSystemPrompt: if (promptType.type === 'systemPrompt') {
134-
if (promptValue === undefined) {
135-
promptValue = PLACEHOLDER.TOOLS_PROMPT
136-
break addToolsPromptToSystemPrompt
137-
}
138-
if (!promptValue.includes(PLACEHOLDER.TOOLS_PROMPT)) {
139-
promptValue += `\n\n${PLACEHOLDER.TOOLS_PROMPT}`
138+
for (const placeholder of additionalPlaceholders[promptType.type]) {
139+
if (!promptValue.includes(placeholder)) {
140+
promptValue += `\n\n${placeholder}`
140141
}
141142
}
142143

0 commit comments

Comments
 (0)