mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-06 21:42:13 +00:00
fix: Caching and prompting fixes (#474)
This commit is contained in:
parent
1d7ddf22a5
commit
12a9d357a1
4 changed files with 15 additions and 15 deletions
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue