You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(llm): split system/user prompts to enable provider-side caching
DeterministicChain now accepts WithSystemPrompt() to send a stable
System message separate from the variable User template. Providers
cache byte-identical system messages across calls (Anthropic 90%
discount, OpenAI 50%, Google 75%).
Split clarify, planning, decompose, and expand templates into
stable system prompts and per-call user templates. Bootstrap agent
templates left as-is (single-use, caching has no benefit).
Copy file name to clipboardExpand all lines: internal/config/prompts.go
+46-42Lines changed: 46 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -490,9 +490,9 @@ CLASSIFICATION RULES:
490
490
491
491
JSON ONLY, no explanation:`
492
492
493
-
// SystemPromptClarifyingAgent is the system prompt for the Clarifying Agent.
494
-
// Use with Eino ChatTemplate.
495
-
constSystemPromptClarifyingAgent=`You are a Senior Technical Architect helping a user refine their software engineering goal.
493
+
// ClarifyingAgentSystemPrompt is the stable system message for the Clarifying Agent.
494
+
// Sent as a System message to enable provider-side prompt caching.
495
+
constClarifyingAgentSystemPrompt=`You are a Senior Technical Architect helping a user refine their software engineering goal.
496
496
Your job is to ask clarifying questions to turn a vague request into a concrete specification.
497
497
498
498
**Guidelines:**
@@ -512,26 +512,26 @@ Every question MUST include concrete options so the user can pick, modify, or ex
512
512
Format: "[Topic]: [Option A] vs [Option B]. [Brief tradeoff]."
513
513
This lets the user reply "first one" or "B but also add X" instead of writing paragraphs.
514
514
515
-
**Input Context:**
516
-
Goal: {{.Goal}}
517
-
{{if .Context}}
518
-
Architectural Knowledge:
519
-
{{.Context}}
520
-
{{end}}
521
-
{{if .History}}Previous Clarifications:
522
-
{{.History}}{{end}}
523
-
524
515
**Output Format (JSON):**
525
516
{
526
517
"questions": ["Topic: Option A vs Option B. Tradeoff note."],
527
518
"goal_summary": "Concise one-line summary for UI display (max 80 chars)",
528
519
"enriched_goal": "A detailed technical specification using facts from context...",
529
520
"is_ready_to_plan": boolean // true if sufficient info gathered
530
-
}
531
-
`
521
+
}`
532
522
533
-
// SystemPromptPlanningAgent is the system prompt for the Planning Agent.
534
-
constSystemPromptPlanningAgent=`You are an Engineering Lead creating a development plan.
523
+
// ClarifyingAgentUserTemplate is the per-call user message template (variable content).
524
+
constClarifyingAgentUserTemplate=`Goal: {{.Goal}}
525
+
{{if .Context}}
526
+
Architectural Knowledge:
527
+
{{.Context}}
528
+
{{end}}
529
+
{{if .History}}Previous Clarifications:
530
+
{{.History}}{{end}}`
531
+
532
+
533
+
// PlanningAgentSystemPrompt is the stable system message for the Planning Agent.
534
+
constPlanningAgentSystemPrompt=`You are an Engineering Lead creating a development plan.
535
535
Your input is an "Enriched Goal" and relevant context from the project knowledge graph.
536
536
Your job is to decompose this goal into a sequential list of actionable execution tasks.
537
537
@@ -547,10 +547,6 @@ Use the minimum number of tasks needed. Do NOT over-decompose.
547
547
4. **Verification**: Each task needs acceptance criteria and a validation command.
548
548
5. **No Overlap**: Do NOT split implementation and testing of the same feature into separate tasks. When explicit tasks are provided, use them directly.
549
549
550
-
**Input Context:**
551
-
- Enriched Goal: {{.Goal}}
552
-
- Knowledge Graph: {{.Context}}
553
-
554
550
**Output Format (JSON):**
555
551
{
556
552
"tasks": [
@@ -566,12 +562,17 @@ Use the minimum number of tasks needed. Do NOT over-decompose.
566
562
}
567
563
],
568
564
"rationale": "Why this approach and how it respects architectural constraints..."
569
-
}
570
-
`
565
+
}`
566
+
567
+
// PlanningAgentUserTemplate is the per-call user message template.
0 commit comments