Add a handoffs/message_filter sample, fix passing parameters to activity tools, fix ActivityModelInput serialization#16
Conversation
|
|
||
| json_obj = ModelResponse.__pydantic_serializer__.to_json(result) | ||
| return json_obj.decode() | ||
| # Use safe/public Pydantic API when possible. Prefer model_dump_json if result is a BaseModel |
There was a problem hiding this comment.
This is fine, but I think there's another serializer function used elsewhere; I wonder if we can combine them at some point.
Also, I wonder if we should add a layer of indirection in the output of the activity rather than return OpenAI types directly, just in case we need to make versioning adjustments in the future--else we may be subject to breaking OpenAI changes. (I had a change in progress that did this.)
There was a problem hiding this comment.
This is fine, but I think there's another serializer function used elsewhere; I wonder if we can combine them at some point.
Sure, let's do it later.
Also, I wonder if we should add a layer of indirection in the output of the activity rather than return OpenAI types directly, just in case we need to make versioning adjustments in the future--else we may be subject to breaking OpenAI changes. (I had a change in progress that did this.)
Are you talking about a situation when activity output is saved in the orchestration history, then the user upgrades their app to a new OpenAI SDK version, and they expect this orchestration to continue after an upgrade? Yes, we should be able to eventually handle that, good catch.
There was a problem hiding this comment.
Yes, that's what I was referring to. Though, thinking about it again, I suppose it doesn't really matter whether the OpenAI type is returned directly or wrapped in an outer type (e.g. ActivityModelOutput). We can still add logic to the post-activity-call handler to make any adjustments needed before passing it back to the OpenAI SDK layer.
Ported
handoffs/message_filtersample from OpenAI Agents SDK:function_app.pyFixed two issues exposed by this sample:
inputparameter ofRunner.run_sync, theActivityModelInputobject failed to serialize to JSON{"max":100}- fixed by parsing this and extracting the value properly