#How to pass existing messages as model context in Agents SDK

1 messages · Page 1 of 1 (latest)

latent totem
#

I'm trying to update my app from the Assistants API to the Agents SDK and I need to pass the Agent and/or Runner some preexisting chat messages as context for the model. I can see Runner.run takes an input parameter that is an array of TResponseInputItem, which seems to be an alias of ResponseInputItemParam but I can't find any info about that type. I've searched the docs and looked for posts online but I can't find any clear examples.

For context, the way my app works is the Agent is summoned into an ongoing conversation, so I need the Agent to be aware of existing messages in the convo before it joined. Does anyone know how I can package the previous messages in a way that I can pass to the Agent/Runner? I'm currently passing an array of objects with fields for "role" and "content", which worked for the Assistants API, but here I'm getting TypeError: Runner.run() got multiple values for argument 'input'