Repository navigation
Go: porting #18663 - #18726
Go: porting #18663#18726
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe chat pipeline now normalizes messages to the chat-completions schema and preserves name, function-call, refusal, audio, and tool-call fields. Message assembly no longer drops messages solely because content is nil. ChangesChat message schema preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change updates chat pipeline handling and related model types; no actionable merge-blocking risk remains in the supplied evidence. Sequence Diagram(s)sequenceDiagram
participant AsyncChat
participant normalizeLLMMessage
participant LLMDriver
AsyncChat->>normalizeLLMMessage: Normalize history message
normalizeLLMMessage-->>AsyncChat: Return supported schema fields
AsyncChat->>LLMDriver: Send normalized messages
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
wangq8
left a comment
There was a problem hiding this comment.
This is an AI review comment.
Thanks for porting #18663 to Go. The allowlist approach correctly stops bookkeeping keys (id, created_at, conversationId, doc_ids) from reaching strict providers, and threading name / tool_calls / tool_call_id / function_call / refusal / audio through Message is consistent with the Python LLM_MESSAGE_FIELDS set. A few things to address before merge:
-
Missing tests. The Python PR ships 4 regression tests; this port adds none.
normalizeLLMMessageandmodelMessageFromMap(especially thetool_callstype-switch between[]map[string]interface{}and[]interface{}) are exactly the kind of code that silently regresses. Please add Go unit tests covering: bookkeeping keys dropped,tool_calls/tool_call_idpreserved, caller map not mutated, and multimodal content-part arrays forwarded unchanged. -
content == nilguard dropped inbuildChatMessages(chat_pipeline.go). The old code skipped messages withcontent == nil; the new code only skipsrole == "". A stored message with a role but nilcontentand notool_callswill now be serialized bybase_model.goas"content": null, which a strict provider (Groq is the very provider this targets) may reject. Suggest keeping the guard but allowing tool-call messages, e.g. skip only whenrole == "" || (content == nil && no tool_calls && no tool_call_id). -
Scope is broader than the Python original. In Python,
async_chat/async_chat_solostill rebuild messages as role/content only; the allowlist was applied torag_agentalone. HereAsyncChat/AsyncChatSolonow forwardname/tool_calls/function_call/refusal/audioon all paths, not just the reasoning path. That is arguably a correctness improvement (tool history is no longer dropped), but it is a behavior change beyond the port — please confirm it is intended. -
Message.Nameis typedinterface{}. OpenAI'snamefield is a string, and the other scalar field (ToolCallID) usesstring. Usinginterface{}loses type safety and forces themsg.Name != nilcheck inbase_model.goto rely on interface nil-ness. Preferstring(withomitempty) or*string.
Minor: modelMessageFromMap reuses stringFromMap from bot.go, which is documented for entity.JSONMap (prompt_config) reads. It works because map[string]interface{} is assignable to entity.JSONMap, but a dedicated helper in this file would be clearer.
This is an AI review comment.
No description provided.