fix: Caching and prompting fixes (#474)

This commit is contained in:
Brace Sproul 2025-07-22 12:37:37 -07:00 • committed by GitHub
parent 1d7ddf22a5
commit 12a9d357a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 15 deletions

View file

@ -86,12 +86,10 @@ export async function generateAction(
`MCP tools added to Planner: ${mcpTools.map((t) => t.name).join(", ")}`, `MCP tools added to Planner: ${mcpTools.map((t) => t.name).join(", ")}`,
); );
// Cache Breakpoint 1: Add cache_control marker to the last tool for tools definition caching // Cache Breakpoint 1: Add cache_control marker to the last tool for tools definition caching
if (tools.length > 0) { tools[tools.length - 1] = {
tools[tools.length - 1] = { ...tools[tools.length - 1],
...tools[tools.length - 1], cache_control: { type: "ephemeral" },
cache_control: { type: "ephemeral" }, } as any;
} as any;
}
const modelWithTools = model.bindTools(tools, { const modelWithTools = model.bindTools(tools, {
tool_choice: "auto", tool_choice: "auto",

View file

@ -137,14 +137,11 @@ export async function generateAction(
logger.info( logger.info(
`MCP tools added to Programmer: ${mcpTools.map((t) => t.name).join(", ")}`, `MCP tools added to Programmer: ${mcpTools.map((t) => t.name).join(", ")}`,
); );
// Cache Breakpoint 1: Add cache_control marker to the last tool for tools definition caching // Cache Breakpoint 1: Add cache_control marker to the last tool for tools definition caching
if (tools.length > 0) { tools[tools.length - 1] = {
tools[tools.length - 1] = { ...tools[tools.length - 1],
...tools[tools.length - 1], cache_control: { type: "ephemeral" },
cache_control: { type: "ephemeral" }, } as any;
} as any;
}
const modelWithTools = model.bindTools(tools, { const modelWithTools = model.bindTools(tools, {
tool_choice: "auto", tool_choice: "auto",

View file

@ -120,6 +120,11 @@ export async function generateReviewActions(
createShellTool(state), createShellTool(state),
createInstallDependenciesTool(state), createInstallDependenciesTool(state),
]; ];
tools[tools.length - 1] = {
...tools[tools.length - 1],
cache_control: { type: "ephemeral" },
} as any;
const modelWithTools = model.bindTools(tools, { const modelWithTools = model.bindTools(tools, {
tool_choice: "auto", tool_choice: "auto",
...(modelSupportsParallelToolCallsParam ...(modelSupportsParallelToolCallsParam

View file

@ -89,10 +89,10 @@ export function formatUserRequestPrompt(
const userFollowupRequest = getRecentUserRequest(messages); const userFollowupRequest = getRecentUserRequest(messages);
if (userFollowupRequest) { if (userFollowupRequest) {
return singleRequestPrompt return followupRequestPrompt
.replace("{USER_REQUEST}", userRequest) .replace("{USER_REQUEST}", userRequest)
.replace("{USER_FOLLOWUP_REQUEST}", userFollowupRequest); .replace("{USER_FOLLOWUP_REQUEST}", userFollowupRequest);
} }
return followupRequestPrompt.replace("{USER_REQUEST}", userRequest); return singleRequestPrompt.replace("{USER_REQUEST}", userRequest);
} }