Skip to content

Question about Tool Call Streaming #326

Open
@Lightblues

Description

@Lightblues

I found that OpenAIChatCompletionsModel can only stream out text, but cannot stream out tool_call deltas. But I think streaming is an important feature for application that need instant responses.

There is a comment in the code that "Because we don't know the name of the function until the end of the stream, we'll save everything and yield events at the end", but I don't understand it. Could you clarify the reason why we cannot just yield ResponseFunctionCallArgumentsDeltaEvent (openai.types.responses.response_function_call_arguments_delta_event) in ChatCompletions API?

Activity

rm-openai

rm-openai commented on Mar 25, 2025

@rm-openai
Collaborator

We get deltas that contain:

  • deltas of the function name
  • deltas of the function args

So e.g. if your function is called "get_weather", the first delta might have get_ and the second might have weather. So until we receive the last delta, we don't know the name of the function.

rm-openai

rm-openai commented on Mar 25, 2025

@rm-openai
Collaborator

In practice this doesn't seem to be a real issue so maybe we should fix this

added
enhancementNew feature or request
and removed
questionQuestion about using the SDK
on Mar 25, 2025
Lightblues

Lightblues commented on Mar 28, 2025

@Lightblues
Author

Thank you for your attention to this issue. I appreciate your insights and look forward to seeing progress on this issue.

ixjx

ixjx commented on Apr 10, 2025

@ixjx

+1 for this feature! I also need the ability to stream tool_call deltas. This would be crucial for applications that require real-time tool invocation and instant responses.

cm2435

cm2435 commented on May 16, 2025

@cm2435

just FYI for people in this thread: ResponseOutputItemAddedEvent is the first outputted token of a streamed function call and contains the entire function name.

See https://platform.openai.com/docs/guides/function-calling?api-mode=responses#streaming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ixjx@Lightblues@cm2435@rm-openai

        Issue actions

          Question about Tool Call Streaming · Issue #326 · openai/openai-agents-python