Move Agent abortSignal to stream/generate options, instead of Agent constructor options
#9145
Replies: 1 comment
-
|
This discussion was automatically locked because it has not been updated in over 30 days. If you still have questions about this topic, please ask us at community.vercel.com/ai-sdk |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm glad to see that the Agent class is no longer marked as experimental!
One of the reasons to use it is to "Reuse configurations - Same model settings, tools, and prompts across different parts of your application"
While using it though, I noticed that the
abortSignalis passed directly to the Agent constructor. In my opinion it would make more sense to have it available at the function calling level though, likeagent.stream. Because the agent isn't reusable currently.Example
To clarify, I would like to define some agents which can later be used in an api route. The route handler will have the
request.signalavailable to pass to theagent.streamcall. Currently I cannot define these agents before the route has been called.This is what I would like to do:
We have multiple agents and depending on the question the right agent will answer. It would be create to be able to define these agents and than pick the correct one.
Workaround
Currently I need an agent factory to pass the abortSignal to the agent on creation. So instead of defining and exporting each agent directly, each agent needs a wrapper.
Other considerations
abortSignalmight not be the only one available on request time.experimental_contextis another.Beta Was this translation helpful? Give feedback.
All reactions