fix(mcp): handle non-object checkpoint acknowledgements - #2273
Draft
fallenmi wants to merge 1 commit into
Draft
Conversation
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.
What does this PR do?
Fixes #2272.
json.loads()accepts scalar and array roots, buttool_memories_filed_away()assumed the decoded checkpoint was an object. It unlinked the one-shotlast_checkpointmarker and then called.get(), so MCP clients received an internal error with no acknowledgement marker left to retry.This change:
dictbefore readingmsgsorts;null, array, string, number, and boolean roots to the same content-freestatus: errorresponse already used for malformed JSON syntax;The scope is intentionally limited to valid non-object JSON roots. Invalid UTF-8, unlink races/failures, and malformed fields inside an object remain separate concerns.
How to test
python -m pytest -q tests/test_mcp_server.py tests/test_mcp_http_transport.py tests/test_hooks_cli.py— 548 passed, 1 skippedpre-commit run --all-filesThe regression matrix covers all five non-object JSON root types, a valid checkpoint object, invalid JSON syntax, a missing marker, marker consumption, and rejected-payload non-reflection. The existing HTTP read-only acknowledgement contract also remains green.
Checklist