Conversation
- Implement intelligent JSON-aware truncation that preserves structure - Add error handling for failed decision parsing (prevents NULL results) - Improve parameter serialization using JSON instead of Debug format - Include complete tool output for all action types (Remember, Wait, Explore) - Remove redundant tool_result_* memory entries (outputs only in decisions) - Add metadata fields (_truncated, _original_size) for truncated outputs - Recursively handle nested objects in truncation algorithm These improvements build on PR #23's foundation by adding: 1. Smart truncation vs basic string cutting 2. Error result handling for invalid actions 3. Better parameter display format 4. Complete output tracking for all actions
douglaz
added a commit
that referenced
this pull request
Sep 1, 2025
- Attempt to parse tool text content as JSON before wrapping - If content is valid JSON, return it directly to preserve structure - Only fall back to simplified format for non-JSON content - Complements PR #25's smart truncation by ensuring structured data flows cleanly This allows tools to return complex structured data like: {"files": [...], "stats": {...}, "metadata": {...}} Instead of flattening everything to: {"success": true, "content": "...stringified JSON..."} The combination of this change with PR #25's smart truncation ensures that structured tool outputs are preserved and intelligently truncated throughout the entire decision tracking pipeline.
4 tasks
douglaz
added a commit
that referenced
this pull request
Sep 1, 2025
* feat: preserve JSON structure in MCP tool results - Attempt to parse tool text content as JSON before wrapping - If content is valid JSON, return it directly to preserve structure - Only fall back to simplified format for non-JSON content - Complements PR #25's smart truncation by ensuring structured data flows cleanly This allows tools to return complex structured data like: {"files": [...], "stats": {...}, "metadata": {...}} Instead of flattening everything to: {"success": true, "content": "...stringified JSON..."} The combination of this change with PR #25's smart truncation ensures that structured tool outputs are preserved and intelligently truncated throughout the entire decision tracking pipeline. * feat: add debug logging for non-JSON tool results Log a debug message when tool results fall back to simplified format, showing a preview of the content. This helps developers understand: - When tools are returning plain text vs structured data - Why certain results aren't being preserved as JSON - What the actual content looks like (first 100 chars)
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 builds upon PR #23's foundation by adding intelligent improvements to decision tracking and tool output handling.
What PR #23 Added
PR #23 introduced
tool_nameandtool_outputfields to DecisionResult, providing basic tool output visibility.What This PR Adds Beyond PR #23
1. Smart JSON-Aware Truncation
_truncated,_original_size)2. Error Handling for Failed Decisions
3. Improved Parameter Serialization
{:?}) for parameters4. Complete Tool Output for All Actions
5. Removed Redundant Memory Storage
tool_result_*memory entriesChanges
src/lib.rsTest Plan
Breaking Changes
None - backward compatible enhancements only