feat(langchain): Add comprehensive ToolMessage support with metadata preservation#10
Merged
feat(langchain): Add comprehensive ToolMessage support with metadata preservation#10
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the LangChain adapter with comprehensive ToolMessage support and introduces a metadata preservation system to maintain message properties during compression workflows. The key improvement is ensuring that complex message types with tool calls, function calls, and associated metadata are correctly preserved throughout the compression process.
Key Changes
- Extended SlimContextMessage interface with optional metadata field for preserving message properties
- Enhanced LangChain adapter with comprehensive ToolMessage handling and metadata preservation
- Added fallback content preservation for complex message types when extractContent returns empty
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/interfaces.ts | Added optional metadata field to SlimContextMessage interface |
| src/adapters/langchain.ts | Enhanced message conversion with metadata preservation and ToolMessage support |
| tests/langchain.test.ts | Added comprehensive test coverage for tool messages and metadata preservation |
| package.json | Version bump to 2.1.3 |
| CHANGELOG.md | Added release notes for version 2.1.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the LangChain adapter with comprehensive ToolMessage support and a robust metadata preservation system. The changes ensure that complex message types (tool calls, function calls, etc.) and their associated metadata are correctly preserved throughout compression workflows.
Changes Made
Core Enhancements
Key Features
tool_call_idand other tool-specific fieldsextractContentcannot process complex contentVersion
Backward Compatibility
✅ Fully backward compatible - all existing code will continue to work without changes. The new metadata field is optional and only added when there are fields to preserve.
Related Issues
Addresses the need for better tool message support and metadata preservation in LangChain workflows, particularly for complex AI agent interactions involving tool calls and function calls.