Skip to content

Commit ec9e58b

Browse files
committed
test(oci): add integration test for tool use on OCI on-demand
The missing integration test allowed the tool type casing bug to ship undetected. This test calls OCI with a tool definition and verifies the response contains tool_calls with the correct function name and arguments.
1 parent 3c124a5 commit ec9e58b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/test_oci_client.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,36 @@ def test_chat_v2(self):
185185
self.assertIsNotNone(response)
186186
self.assertIsNotNone(response.message)
187187

188+
def test_chat_tool_use_v2(self):
189+
"""Test tool use with v2 client on OCI on-demand inference."""
190+
response = self.client.chat(
191+
model="command-a-03-2025",
192+
messages=[{"role": "user", "content": "What's the weather in Toronto?"}],
193+
max_tokens=200,
194+
tools=[{
195+
"type": "function",
196+
"function": {
197+
"name": "get_weather",
198+
"description": "Get current weather for a location",
199+
"parameters": {
200+
"type": "object",
201+
"properties": {
202+
"location": {"type": "string", "description": "City name"}
203+
},
204+
"required": ["location"],
205+
},
206+
},
207+
}],
208+
)
209+
210+
self.assertIsNotNone(response)
211+
self.assertIsNotNone(response.message)
212+
self.assertEqual(response.finish_reason, "TOOL_CALL")
213+
self.assertTrue(len(response.message.tool_calls) > 0)
214+
tool_call = response.message.tool_calls[0]
215+
self.assertEqual(tool_call.function.name, "get_weather")
216+
self.assertIn("Toronto", tool_call.function.arguments)
217+
188218
def test_chat_stream_v2(self):
189219
"""Test streaming chat with v2 client."""
190220
events = []

0 commit comments

Comments
 (0)