Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return #259

Open
ChrisDelClea opened this issue Mar 20, 2025 · 4 comments
Open

Return #259

ChrisDelClea opened this issue Mar 20, 2025 · 4 comments
Labels
question Question about using the SDK

Comments

@ChrisDelClea
Copy link

ChrisDelClea commented Mar 20, 2025

Please read this first

  • Have you read the docs? yes
  • Have you searched for related issues? yes

Question

During streaming a response with :

result = Runner.run_streamed(starting_agent=agent, input=inputs)
async for event in result.stream_events():
data = event.data

i found multiple Delta and Event objects from openai.types.responses that can be used e.g.:

 ResponseFunctionCallArgumentsDeltaEvent, ResponseFunctionCallArgumentsDoneEvent, ResponseFunctionToolCall

Yet, after the run when i do:

        for msg in result.to_input_list():
            print(msg)

(ToolCallOutputItem)

i get a entry:

{'call_id': 'call_xxxx', 'output': "{'assistant': 'Assistent'}", 'type': 'function_call_output'}

So my question is, how can i capture the function_call_output via event during streaming?

@ChrisDelClea ChrisDelClea added the question Question about using the SDK label Mar 20, 2025
@DanieleMorotti
Copy link

Hi, I think this example in the documentation may be what you're looking for. Hope it's helpful!

@ChrisDelClea
Copy link
Author

Great, thank you.

@ChrisDelClea
Copy link
Author

ChrisDelClea commented Mar 20, 2025

But well, what actually would be great too: if i can output the result from the called function tool directly. Does that make sense?

@rm-openai
Copy link
Collaborator

But well, what actually would be great too: if i can output the result from the called function tool directly. Does that make sense?

Does this code from the example not work?

        # When items are generated, print them
        elif event.type == "run_item_stream_event":
            elif event.item.type == "tool_call_output_item":
                print(f"-- Tool output: {event.item.output}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

3 participants