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

Attempt to decode tool_input as a JSON #1167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

meetwudi
Copy link

We currently evaluate tool_input as a Python object. However, self._validate_tool_input may return a JSON string instead. This causes an error when tool_input contains lowercase true/false, which are valid JSON values but not valid Python (True/False).

As a result, the agent could enter an infinite loop if tool_input keeps resolving to a JSON string like:

{"timeMin": "2024-08-12T00:00:00Z", "timeMax": "2024-08-13T00:00:00Z", "single_events": true, "order_by": "startTime", "calendar_id": "primary"}

This commit addresses the issue by ensuring that tool_input is correctly parsed as JSON when necessary, preventing the infinite loop.

We currently evaluate tool_input as a Python object. However, self._validate_tool_input may return a JSON string instead. This causes an error when tool_input contains lowercase true/false, which are valid JSON values but not valid Python (True/False).

As a result, the agent could enter an infinite loop if tool_input keeps resolving to a JSON string like:

```
{"timeMin": "2024-08-12T00:00:00Z", "timeMax": "2024-08-13T00:00:00Z", "single_events": true, "order_by": "startTime", "calendar_id": "primary"}
```

This commit addresses the issue by ensuring that tool_input is correctly parsed as JSON when necessary, preventing the infinite loop.
@theCyberTech theCyberTech added the bug Something isn't working label Aug 13, 2024
Copy link
Collaborator

@pythonbyte pythonbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @meetwudi
Can you provide a test case for this issue?
And fix the conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants