When using the Agents endpoint with Claude via AWS Bedrock and a custom RAG tool, the tool input parsing fails. The error occurs because the input is a plain string, not a JSON object as expected.
Root Cause: The JSON.parse(args) is failing because the string "How to write a unit test in XY? Include best practices and examples." is not a valid JSON string.
Set up LibreChat with Agents endpoint using Claude via AWS Bedrock
Attach a custom RAG tool to the agent
Use the RAG tool during a conversation
a) How implement a unit test in [PRODUCT-NAME]
b) And how write a unit test for a resolver in [PRODUCT-NAME]?
Observe the error in the logs
What browsers are you seeing the problem on?
Chrome
Relevant log output
SyntaxError: Unexpected token H in JSON at position 0
at JSON.parse (<anonymous>)
at formatAgentMessages (api/app/clients/prompts/formatMessages.js:192:23)
at AgentClient.chatCompletion (api/server/controllers/agents/client.js:482:24)
Screenshots
No response
Code of Conduct
[X] I agree to follow this project's Code of Conduct
What happened?
When using the Agents endpoint with Claude via AWS Bedrock and a custom RAG tool, the tool input parsing fails. The error occurs because the input is a plain string, not a JSON object as expected.
Root Cause: The JSON.parse(args) is failing because the string "How to write a unit test in XY? Include best practices and examples." is not a valid JSON string.
https://github.com/danny-avila/LibreChat/blob/main/api/app/clients/prompts/formatMessages.js#L191-L195
Possible Fix: Modify the code to handle different input types:
If you want, I can create a PR?
Thanks for checking.
Steps to Reproduce
What browsers are you seeing the problem on?
Chrome
Relevant log output
Screenshots
No response
Code of Conduct