Commit fc167c1
authored
fix(oci): uppercase tool type field for OCI V2 API compatibility (#758)
* fix(oci): uppercase tool type field for OCI V2 API compatibility
OCI Generative AI expects tool type as "FUNCTION" (uppercase) but the
SDK passes through the Cohere format "function" (lowercase), causing
a 400 error. Transform tool types to uppercase like we do for message
roles and content types.
* 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.
* fix(oci): complete casing audit for OCI field transformations
Fix remaining casing issues found during systematic audit:
- V1 tools: uppercase type field (same fix as V2)
- tool_calls in messages: uppercase type when sending tool results back
in multi-turn conversations
- Response tool_calls: lowercase type from OCI's "FUNCTION" back to
"function" for Cohere SDK compatibility
- safety_mode: uppercase defensively (CONTEXTUAL/STRICT/OFF)
Integration tests added for each:
- test_chat_tool_use_response_type_lowered: verifies tool_call.type
is "function" (not "FUNCTION") in responses
- test_chat_multi_turn_tool_use_v2: full tool use round-trip (call →
result → final response)
- test_chat_safety_mode_v2: verifies safety_mode works on OCI
* fix(oci): fix embed embedding_types casing and handle embeddingsByType response
- embedding_types: OCI expects lowercase (float, int8) not uppercase.
The .upper() was breaking all embedding_types requests.
- Response: OCI returns "embeddingsByType" (not "embeddings") when
embeddingTypes is specified. Handle both response keys.
- Unit test updated to expect lowercase.
- Integration tests added: embedding_types=["float"] and truncate modes.
* fix(oci): guard safety_mode.upper() against None value
Address Cursor Bugbot review: safety_mode is Optional, so the SDK can
pass None when the user explicitly sets safety_mode=None. Guard with
a None check before calling .upper() on both V1 and V2 paths.1 parent b911acf commit fc167c1
2 files changed
Lines changed: 189 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | | - | |
| 672 | + | |
| 673 | + | |
673 | 674 | | |
674 | 675 | | |
675 | 676 | | |
| |||
728 | 729 | | |
729 | 730 | | |
730 | 731 | | |
731 | | - | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
732 | 739 | | |
733 | 740 | | |
734 | 741 | | |
| |||
756 | 763 | | |
757 | 764 | | |
758 | 765 | | |
759 | | - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
760 | 773 | | |
761 | 774 | | |
762 | 775 | | |
| |||
765 | 778 | | |
766 | 779 | | |
767 | 780 | | |
768 | | - | |
769 | | - | |
| 781 | + | |
| 782 | + | |
770 | 783 | | |
771 | 784 | | |
772 | 785 | | |
| |||
810 | 823 | | |
811 | 824 | | |
812 | 825 | | |
813 | | - | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
814 | 833 | | |
815 | 834 | | |
816 | 835 | | |
817 | 836 | | |
818 | | - | |
819 | | - | |
| 837 | + | |
| 838 | + | |
820 | 839 | | |
821 | 840 | | |
822 | 841 | | |
| |||
857 | 876 | | |
858 | 877 | | |
859 | 878 | | |
860 | | - | |
| 879 | + | |
| 880 | + | |
861 | 881 | | |
862 | 882 | | |
863 | 883 | | |
| |||
911 | 931 | | |
912 | 932 | | |
913 | 933 | | |
914 | | - | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
915 | 940 | | |
916 | 941 | | |
917 | 942 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
193 | 322 | | |
194 | 323 | | |
195 | 324 | | |
| |||
389 | 518 | | |
390 | 519 | | |
391 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
392 | 545 | | |
393 | 546 | | |
394 | 547 | | |
| |||
652 | 805 | | |
653 | 806 | | |
654 | 807 | | |
655 | | - | |
| 808 | + | |
656 | 809 | | |
657 | 810 | | |
658 | 811 | | |
| |||
0 commit comments