Add Runtime.DynamicIdentityHint, a live, per-turn identity fact
Runtime.StaticSystemPrompt is cached and reused verbatim every turn — right for anything that doesn't change mid-conversation, wrong for a fact a caller needs to update live (e.g. after a runtime model switch) and have the model actually notice. A model tends to just repeat what it already told the user earlier in the same conversation over a background instruction it read once near the top of a large cached block, so updating only the static prompt after a switch left the model insisting it was still whatever it started as. DynamicIdentityHint rides the same per-turn (uncached) system prompt slot Run/RunTurn already use for the date line and KG hint, so setting it takes effect on the very next turn with the same recency the model grants its own last statement.
This commit is contained in:
1 parent
f624e4c7bd
commit
0ccfdb2a24
5 files changed
+41
-14
No files matched your search
+3
-2
@@ -84,9 +84,10 @@ func (r *Runtime) RunTurn(ctx context.Context, userMsg string, images []llm.Imag
|
||||
cancel()
|
||||
}
|
||||
|
||||
dynamicSuffix := buildDynamicSystemPromptSuffix(r.DynamicIdentityHint, "", kgHint)
|
||||
parts := []llm.SystemPromptPart{{Text: r.StaticSystemPrompt, Cache: true}}
|
||||
if kgHint != "" {
|
||||
parts = append(parts, llm.SystemPromptPart{Text: kgHint, Cache: false})
|
||||
if dynamicSuffix != "" {
|
||||
parts = append(parts, llm.SystemPromptPart{Text: dynamicSuffix, Cache: false})
|
||||
}
|
||||
req := llm.ChatRequest{
|
||||
Model: r.Model,
|
||||
|
||||
Reference in new issue
Block a user