-
Notifications
You must be signed in to change notification settings - Fork 285
Allow agents to be reusable with context #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
Hello! Thank you for a contribution! |
Hello! Thanks for the feedback! I understand the current preference for using The This change enables that context reuse with ease. Since the old, single run behavior remains the default, it's non-breaking and allows building such stateful agents out of the box easily. How can we align this stateful capability with the architectural paradigm? |
I understand this scenario, but by default we don't want agent to be implicitly stateful. For these scenarios you could use Persistence feature or pass context to agent input between runs yourself. |
@Rizzen why not add the option to make it stateful and keep the default as it is? |
I think this will not be an issue because this PR keeps the default functionality as is. It will only be "stateful", when toggled by the flag. Otherwise the current behavior remains as is. |
Motivation and Context
Currently, the default agent types are designed to be used only once; they throws an
IllegalStateExceptionif you try to run it a second time. This prevents the creation of conversational, or manual feedback based agents.This change introduces a flag (
enforceSingleRun) that allows the agent to be reused for multiple interactions. When reused, the agent keeps its context history and state across runs.This enables the development of conversational agents that can remember what happened in the previous step.
The change also updates the core run logic to ensure the agent's initial setup is only done once, guaranteeing the reuse of the context object for subsequent calls while correctly tracking the session.
Closes #1217
Example usage:
Breaking Changes
No. The default behavior of
StatefulAIAgentremains single-use (by assumingenforceSingleRun = trueif not specified), replicating current behavior and throwing theIllegalStateExceptionon the second run. People wishing to enable reuse must explicitly set the new parameter tofalse.Type of the changes
Checklist
developas the base branchAdditional steps for pull requests adding a new feature