fix(Anthropic): messages.X.content.Y.tool_use.input: Input should be a valid dictionary

This commit is contained in:
Danny Avila 2024-09-03 22:52:08 -04:00
parent 9ff43bf958
commit 0c04018bb3
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
2 changed files with 10 additions and 2 deletions

View file

@ -170,7 +170,15 @@ const formatAgentMessages = (payload) => {
}
// Note: `tool_calls` list is defined when constructed by `AIMessage` class, and outputs should be excluded from it
const { output, ...tool_call } = part.tool_call;
const { output, args: _args, ...tool_call } = part.tool_call;
// TODO: investigate; args as dictionary may need to be provider-or-tool-specific
let args = _args;
try {
args = JSON.parse(args);
} catch (e) {
// failed to parse, leave as is
}
tool_call.args = args;
lastAIMessage.tool_calls.push(tool_call);
// Add the corresponding ToolMessage

View file

@ -464,7 +464,7 @@ class AgentClient extends BaseClient {
);
},
});
logger.info(this.contentParts, { depth: null });
logger.debug(this.contentParts, { depth: null });
} catch (err) {
if (!abortController.signal.aborted) {
logger.error(