Skip to content

Commit 7f70d1b

Browse files
committed
Get prompt caching working for decomposing thinker
1 parent ad8f54f commit 7f70d1b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.agents/thinker/decomposing-thinker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const definition: SecretAgentDefinition = {
4444

4545
if (prompts.length > 1) {
4646
// Prompt cache with a dummy thinker first!
47-
const prompt = `This request was cancelled. Please respond with an empty message only. Do not write any text at all.`
47+
const prompt = `We are prompt caching the above files. This is a warm-up request so that subsequent (parallel!) requests can be cached. Please respond with just the phrase: 'The context is now cached!'. It's important that you don't include any other text or reasoning in your response, since that would increase latency and cost for this request, which is just meant to warm up the cache before firing off the real requests in parallel.`
4848
yield {
4949
toolName: 'spawn_agents',
5050
input: {

.agents/thinker/thinker-with-files-input.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { publisher } from '../constants'
22

33
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
import type { ToolMessage } from '../types/util-types'
45

56
const definition: SecretAgentDefinition = {
67
id: 'thinker-with-files-input',
@@ -63,9 +64,16 @@ You must be extremely concise and to the point.
6364
)
6465
const promptMessages = messageHistory.slice(0, lastAssistantMessageIndex)
6566
const readFilesMessages = messageHistory.slice(lastAssistantMessageIndex)
67+
const readFilesToolResult = readFilesMessages[
68+
readFilesMessages.length - 1
69+
] as ToolMessage
70+
// For getting prompt caching to work, we need to remove the unique tool call id from the tool result.
71+
delete (readFilesToolResult.content as any).toolCallId
72+
6673
yield {
6774
toolName: 'set_messages',
6875
input: { messages: [...readFilesMessages, ...promptMessages] },
76+
includeToolCall: false,
6977
}
7078
}
7179

0 commit comments

Comments
 (0)