Skip to content
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

ZeroShotAgentOutputParser trims quotes regardless of whether they match #1200

Closed
jollytoad opened this issue May 10, 2023 · 1 comment
Closed

Comments

@jollytoad
Copy link
Contributor

jollytoad commented May 10, 2023

ZeroShotAgentOutputParser strips all leading and trailing double quotes from the tool input string, regardless of whether they actually match, this can produce an unexpected effect such as an infinite loop.

For example, if the following is generated:

Action Input: foo = "Foo"

and you have that fed into a tool to validate the syntax, the regex in ZeroShotAgentOutputParser mistakenly strips the last quote, so the tool gets:

foo = "Foo

and the tool will return an error due to the invalid syntax, if that error states the closing quote is missing, then the feedback misleads the model, and then the next generation may include additional quotes, which also gets stripped, and you end up in a feedback loop of nonsense.

I think a less surprising behaviour would be to trim matching quotes only, so that the quotes are not stripped from the above, but it would strip something like """hello""" for example.

This is the existing replacement: .replace(/^"+|"+$/g, ""), that strips all leading and trailing quotes regardless.

And this is an alternative: .replace(/^(\"+)(.*?)(\1)$/, '$2'), that will only strip matching leading and trailing quotes.

@dosubot
Copy link

dosubot bot commented Aug 17, 2023

Hi, @jollytoad! I'm here to help the LangChain team manage their backlog and I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue you raised is about the ZeroShotAgentOutputParser trimming all leading and trailing double quotes from the tool input string, even if they don't match. This can lead to issues like infinite loops. The suggested resolution is to change the behavior to only trim matching quotes.

Since there hasn't been any activity on this issue yet, we would like to confirm if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to LangChain!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Aug 17, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant