langchain
langchain copied to clipboard
Adds Reflexion (solves #2316)
Adds Reflexion (solves #2316)
Introduces the concept of trials to AgentExecutor and implements Reflexion as re-try method. I.e., when the Agent fails, it thinks about what it could have done better & attempts the task again. Based on https://arxiv.org/abs/2303.11366.
Fixes #2316
Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: @vowelparrot
Twitter: @UmerHAdil | Discord: RicChilligerDude#7589
cc @mbchang
cc @noahshinn024
Nice!
This is really cool! And thank you for the PR and patience! The reason I'm taking some time to review this is that it changes a couple pretty core pieces - the agent executor and callback managers. While you do an excellent job of making sure it's all compatible, we may want to look into if a lighter-touch implementation would be appropriate here. I think @hwchase17 will have some stronger opinions than I right now in terms of how the agent framework should evolve
This is really cool! And thank you for the PR and patience! The reason I'm taking some time to review this is that it changes a couple pretty core pieces - the agent executor and callback managers. While you do an excellent job of making sure it's all compatible, we may want to look into if a lighter-touch implementation would be appropriate here. I think @hwchase17 will have some stronger opinions than I right now in terms of how the agent framework should evolve
Sure! 100% no hurt feelings.
I think we have 2 options:
- Implement Reflexion as an agent type. Then there's no need for changes in agent executor & callback managers, but we won't be able to use Reflexion with new agent types.
- Introduce the concept of re-trys. Then we can use Reflexion with any agent type, but this requires changes in agent executor & callback managers.
I went with 2 because @noahshinn024 explicitly stated "Reflexion is not a replacement for [...] any [....] decision-guiding approach! It is a simple retry technique that can be used (to) enhance other approaches."
How would you design a light-version? Am happy to implement :)
Edit: formatting
Hey @hwchase17 any comments?
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| langchain | ⬜️ Ignored (Inspect) | Jul 14, 2023 3:41am |
Hi @hinthornw! I saw you're now the maintainer for Agents / Tools / Toolkits, so am pinging you. Would love to get a rough direction on this, so I can adjust this to the LC team's preferences and get it merged.
@UmerHA Hi , could you, please, resolve the merging issues? After that ping me and I push this PR for the review. Thanks! Please, let me know if you need help!
Hi @leo-gan, nice to see you're an LC collaborator - congrats! :)
I would rather not fix this PR, because @vowelparrot said the key change in this PR needs to be discussed first. This PR introduces the concept of 'trials'. When an agent execution fails, a new run (new 'trial') is started.
From @vowelparrot's comment, LC's preference is to implement this differently - maybe as a chain?
Would love to get clarity on this issue before investing the effort of bringing this PR up-to-date.
@hwchase17 Please, give a feedback to this important PR. Thanks!
Hopping into this one - @UmerHA would you be game to implement this using Runnables (LCEL) in a template? https://github.com/langchain-ai/langchain/blob/master/templates/docs/CONTRIBUTING.md
Would require starting over for the most part, but I don't think this PR is mergable in its current state anyways (library has evolved a lot since this was last worked on!). Let me know how you'd like to proceed! Happy to close this and you can open a new PR, or you're welcome to work from this PR's current state.
Hey @efriis, I can't promise to work on this due to time constraints, so feel free to close this. If I find time to adapt this, I'll open a new PR!
Sounds great - thanks @UmerHA !