litellm/tests/test_litellm/integrations/test_lunary.py
Tin Chi Lo bbba450301 fix(litellm): honor dict-form reasoning_effort in the bridge escape hatch and serialize custom tool calls in helicone and lunary logs
The bridge gate compared reasoning_effort against the string "none", so
litellm's dict form ({"effort": "none"}) wrongly bridged; the gate now
reads the effort value from either form and treats a summary inside the
dict as Responses-only regardless of effort. Helicone and lunary
previously skipped custom tool calls entirely; both now serialize them
(helicone as a tool_use block from the custom payload, lunary with the
custom name and input in its function fields, keeping type custom), with
new mapped tests for both integrations
2026-08-01 11:26:09 -07:00

40 lines
1.1 KiB
Python

import os
import sys
sys.path.insert(0, os.path.abspath("../../.."))
from litellm.integrations.lunary import parse_tool_calls
from litellm.types.utils import (
ChatCompletionMessageCustomToolCall,
ChatCompletionMessageToolCall,
Function,
)
def test_parse_tool_calls_serializes_custom_tool_calls():
custom_call = ChatCompletionMessageCustomToolCall(
id="call_c",
custom={"name": "ApplyPatch", "input": "*** Begin Patch"},
)
function_call = ChatCompletionMessageToolCall(
id="call_f",
type="function",
function=Function(name="read_file", arguments='{"path": "a.py"}'),
)
parsed = parse_tool_calls([custom_call, function_call])
assert parsed == [
{
"type": "custom",
"id": "call_c",
"function": {"name": "ApplyPatch", "arguments": "*** Begin Patch"},
},
{
"type": "function",
"id": "call_f",
"function": {"name": "read_file", "arguments": '{"path": "a.py"}'},
},
]
def test_parse_tool_calls_none_passthrough():
assert parse_tool_calls(None) is None