Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the FunctionCall struct in llm/transformer/openai/model.go by adding the omitempty tag to the Name field's JSON definition. This change allows the field to be excluded from JSON serialization when it is empty. There are no review comments to address, and I have no further feedback to provide.
Greptile SummaryThis PR fixes a serialization issue where an empty
Confidence Score: 4/5The change is isolated to one JSON struct tag, only affects marshaling (not unmarshaling), and corrects a real compatibility problem with providers that reject "name":"". Safe to merge. The one-line tag addition correctly eliminates an empty name field from serialized function call payloads, which is the right behavior for both streaming aggregation and pass-through scenarios. The only gap is the absence of a direct unit test asserting the new serialization behavior, leaving the fix unguarded against future regressions. llm/transformer/openai/model.go — the only changed file; no new test accompanies the fix. Important Files Changed
Sequence DiagramsequenceDiagram
participant Stream as Streaming Provider
participant Agg as aggregator.go
participant Conv as outbound_convert.go (ToolCallFromLLM)
participant JSON as JSON Serializer
participant Downstream as Downstream LLM Provider
Stream->>Agg: "delta chunk (name="", arguments="")"
Note over Agg: Initialize ToolCall with empty Name
Agg->>Agg: "delta chunk (name="get_weather", arguments="{}")"
Note over Agg: Update Name to "get_weather"
Agg->>Conv: "llm.ToolCall{Name: ""} [partial/forwarded]"
Conv->>JSON: "FunctionCall{Name: "", Arguments: "..."}"
Note over JSON: Before fix: emits name:""<br/>After fix (omitempty): name key omitted
JSON->>Downstream: "{"function": {"arguments": "..."}}"
Note over Downstream: Accepts payload without empty name field
Reviews (1): Last reviewed commit: "fix: should omit empty name for function..." | Re-trigger Greptile |
| Name string `json:"name,omitempty"` | ||
| Arguments string `json:"arguments"` |
There was a problem hiding this comment.
Missing test for the new serialization behavior. The fix is correct, but no test verifies that marshaling a
FunctionCall with an empty Name omits the name key from JSON output. Without it, a future refactor that reverts or misapplies the tag (e.g., moving to a custom marshaler) would silently reintroduce the bug. A small table-driven test in model_test.go marshaling FunctionCall{Name: "", Arguments: "{}"} and asserting the key is absent would be sufficient.
No description provided.