Skip to content

fix: OCI tool use returns 400 — tool type field not uppercased #759

@fede-kamel

Description

@fede-kamel

Bug

OciClientV2.chat() with tools parameter returns a 400 error from OCI Generative AI:

status_code: 400, body: {'message': 'Please pass in correct format of request.'}

Root Cause

OCI Generative AI expects all enum fields uppercased. The SDK already transforms message roles ("user""USER") and content types ("text""TEXT"), but passes the tool type field through as-is ("function" instead of "FUNCTION").

Reproduction

import cohere

client = cohere.OciClientV2(
    oci_region="us-chicago-1",
    oci_compartment_id="ocid1.compartment.oc1...",
)

# This returns 400
response = client.chat(
    model="command-a-03-2025",
    messages=[{"role": "user", "content": "What's the weather in Toronto?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]},
        },
    }],
)

Expected

Tool use works — OCI returns finish_reason=TOOL_CALL with tool_calls.

Impact

All tool use via OciClientV2 is broken on OCI on-demand inference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions