Skip to content

Commit a737165

Browse files
shellygrclaude
andauthored
Cache initial prompt (#65)
* cache initial prompt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * update graphcore to cacheInitialPrompt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * update graphcore with mypy fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 86d7b89 commit a737165

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

analyzer/analysis.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,21 @@ def _analyze_core(
286286

287287
system_prompt = load_jinja_template("analyzer_system_prompt.j2")
288288

289+
# Wrap initial_prompt with cache_control for prompt caching
290+
initial_prompt_with_cache = {
291+
"type": "text",
292+
"text": initial_prompt,
293+
"cache_control": {"type": "ephemeral"}
294+
}
295+
289296
graph = build_workflow(
290297
input_type=FlowInput,
291298
context_schema=ExplainerContext,
292299
output_key="result",
293300
tools_list=tools,
294301
unbound_llm=llm,
295302
sys_prompt=system_prompt,
296-
initial_prompt=initial_prompt,
303+
initial_prompt=initial_prompt_with_cache,
297304
state_class=SimpleState
298305
)[0].compile(checkpointer=InMemorySaver())
299306

0 commit comments

Comments
 (0)