feat(llm): add prompt-cache observability and wiki cache-friendly prompts
Normalize provider-specific cache counters into TokenUsage, propagate call purpose and prefix fingerprints through context for logging and Langfuse, and restructure wiki page-modify prompts with warmup/singleflight to improve prefix cache hit rates during reduce batches.
This commit is contained in:
@@ -41,6 +41,8 @@ func (e *AgentEngine) streamLLMToEventBus(
|
||||
|
||||
messages = e.sourceRefs.EncodeMessages(messages)
|
||||
messages = e.resourceRefs.EncodeMessages(messages)
|
||||
prefixFingerprint := chat.PromptPrefixFingerprint(messages, opts)
|
||||
llmCtx = types.WithLLMCallMetadata(llmCtx, "agent_round", prefixFingerprint)
|
||||
stream, err := e.chatModel.ChatStream(llmCtx, messages, opts)
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "[Agent][Stream] Failed to start LLM stream: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user