Move Agent abortSignal
to stream/generate options, instead of Agent constructor options
#9145
jamiter
started this conversation in
Ideas & Feedback
Replies: 0 comments
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
abortSignal
is 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.signal
available to pass to theagent.stream
call. 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
abortSignal
might not be the only one available on request time.experimental_context
is another.Beta Was this translation helpful? Give feedback.
All reactions