Skip to content

Conversation

@shubham-021
Copy link

Description:

Fixed an issue in AIMessage.toFormattedString() where nested objects in tool call arguments were being displayed as [object Object] instead of their actual JSON representation.

Changes

  • Modified convertToPrettyString() in libs/langchain-core/src/messages/format.ts to use JSON.stringify() for object values when formatting tool call arguments

Testing

Added a new test case "formats an AI message with nested objects in tool call args" that verifies:

  • Nested objects are serialized as JSON strings
  • The output does not contain [object Object]

Fixes #9504

@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2025

🦋 Changeset detected

Latest commit: d16c7e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@langchain/core Patch
@langchain/standard-tests Patch
langchain Patch
@langchain/google-cloud-sql-pg Patch
@langchain/google-common Patch
@langchain/google-genai Patch
@langchain/google-webauth Patch
@langchain/google-vertexai-web Patch
@langchain/google-vertexai Patch
@langchain/google-gauth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Successfully merging this pull request may close these issues.

convertToFormattedString doesn't properly format non-primitive tool arguments

1 participant