-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Comments
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! |
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.The text was updated successfully, but these errors were encountered: