cortex.cpp icon indicating copy to clipboard operation
cortex.cpp copied to clipboard

bug: Streaming chat completion API returns empty response with tools

Open jkohen opened this issue 9 months ago • 0 comments

Cortex version

v1.0.12

Describe the issue and expected behaviour

The following code works as expected:

    output = client.chat.completions.create(
        model=session.model_id,
        messages=messages,
        stream=True,
    )
    print(f'Output: {list(output)}')

However, when I add tools=my_tools, the response becomes the empty list. If I then remove stream=True, the response is again correct, only that streaming being disable, it's returned all at once.

I expected stream=True and tools=... to work together as per https://platform.openai.com/docs/guides/function-calling#streaming.

Steps to Reproduce

No response

Screenshots / Logs

No response

What is your OS?

  • [x] Windows
  • [ ] Mac Silicon
  • [ ] Mac Intel
  • [ ] Linux / Ubuntu

What engine are you running?

  • [x] cortex.llamacpp (default)
  • [ ] cortex.tensorrt-llm (Nvidia GPUs)
  • [ ] cortex.onnx (NPUs, DirectML)

Hardware Specs eg OS version, GPU

No response

jkohen avatar Apr 14 '25 20:04 jkohen