Skip to content

Conversation

philliphoff
Copy link
Collaborator

Allow developers to return "raw" agent output from orchestrations rather than be forced to deal with specific Durable semantics (i.e. that orchestrations must return strings even though activities can return objects (that meet certain requirements)).

Now, if an agent returns a Durable model, Pydantic model, or typed dictionary, the object will be implicitly serialized to a string.

@philliphoff philliphoff marked this pull request as ready for review September 9, 2025 22:36
@AnatoliB
Copy link
Owner

Now, if an agent returns [...]

@philliphoff Do I understand it correctly that this is not about an Agent instance output, but about orchestrator function output? In this case, I'm a bit worried about us special-casing this specifically for the OpenAI integration. Someone could try to return objects of this kind from a regular orchestrator, and now they will suddenly encounter a different behavior.

If returning objects like this is common (but still not mandatory) in OpenAI Agents scenarios, perhaps we should expose the serializing utility as public API, so that the user can be explicit about this choice?

@philliphoff
Copy link
Collaborator Author

If returning objects like this is common (but still not mandatory) in OpenAI Agents scenarios, perhaps we should expose the serializing utility as public API, so that the user can be explicit about this choice?

@AnatoliB It was common enough to be the cause of all of the broken samples, which followed a pattern of returning the final_output directly, so it seemed like something we ought to manage automatically. The fact that activity outputs are automatically serialized but orchestration outputs must be strings I find a inconsistent quirk of Durable Functions, one that OpenAI developers shouldn't have to worry about.

I don't like exposing this (only) as a public API as it'd not be very discoverable, in particular, to OpenAI developers. (I'd rather instead push the DF SDK to do similar serialization under the covers.)

@AnatoliB
Copy link
Owner

@philliphoff Ok, this is fair, let's go with what you've implemented and perhaps adjust the regular DF SDK to match this behavior later.

@philliphoff philliphoff merged commit 0a8b3b0 into durable-openai-agent Sep 12, 2025
4 checks passed
@philliphoff philliphoff deleted the philliphoff-better-serialization branch September 12, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants