MCPcopy Create free account
hub / github.com/cloudwego/eino-examples / NormalizeForSession

Function NormalizeForSession

quickstart/chatwitheino/msgops/normalize.go:37–46  ·  view source on GitHub ↗

NormalizeForSession returns a provider-safe message for chatwitheino's JSONL session store. Agentic model implementations attach Responses API item IDs to content blocks, and those IDs are required when replaying provider-native output items such as assistant messages, reasoning blocks, and tool cal

(msg M)

Source from the content-addressed store, hash-verified

35// output items such as assistant messages, reasoning blocks, and tool calls.
36// The examples persist those IDs while dropping streaming-only metadata.
37func NormalizeForSession[M adk.MessageType](msg M) M {
38 if KindOf[M]() != KindAgentic {
39 return msg
40 }
41 agenticMsg, ok := any(msg).(*schema.AgenticMessage)
42 if !ok || agenticMsg == nil {
43 return msg
44 }
45 return any(normalizeAgenticMessage(agenticMsg)).(M)
46}
47
48// NormalizeMessagesForModelInput prepares stored messages before passing them
49// back to Runner/ChatModel. Today this matches NormalizeForSession; keeping the

Callers 4

AppendMethod · 0.92
loadSessionFunction · 0.92
UnmarshalMessageFunction · 0.85

Calls 1

normalizeAgenticMessageFunction · 0.85

Tested by

no test coverage detected