feat: serialize non-string content with json.dumps#199
Open
ezyang wants to merge 2 commits into
Open
Conversation
ezyang
added a commit
that referenced
this pull request
Mar 24, 2025
When the content parameter to codemcp in codemcp/main.py is not a string, instead of rejecting it, let's serialize it to a string using json.dumps and then proceed. Add a test for this with WriteFile. ```git-revs 5ca0f3c (Base revision) fe0cb53 Add json import for serializing non-string content e1eb78a Add serialization of non-string content using json.dumps 295b775 Add json import for testing non-string content serialization 80c9601 Add test_write_non_string_content method to test JSON serialization of non-string content HEAD Auto-commit format changes ``` codemcp-id: 0-feat-serialize-non-string-content-with-json-dumps ghstack-source-id: 7ee8e1f Pull-Request-resolved: #199
ezyang
added a commit
that referenced
this pull request
Mar 24, 2025
When the content parameter to codemcp in codemcp/main.py is not a string, instead of rejecting it, let's serialize it to a string using json.dumps and then proceed. Add a test for this with WriteFile. ```git-revs 5ca0f3c (Base revision) fe0cb53 Add json import for serializing non-string content e1eb78a Add serialization of non-string content using json.dumps 295b775 Add json import for testing non-string content serialization 80c9601 Add test_write_non_string_content method to test JSON serialization of non-string content e0062bc Auto-commit format changes 7f2a343 Update content parameter type signature to accept any object type, not just strings 42a2ac7 Add stdio_client E2E test for non-string content serialization c3607c2 Update documentation to clarify content parameter can be any serializable object 7c83adb Update WriteFile tool description to mention content can be any JSON-serializable object adbf9f7 Update Summary section to clarify content parameter can be any JSON-serializable object 42b5c14 Fix stdio test to handle response content when it's a list of TextContent objects cbc62d6 Fix verification of success message in stdio test 2cfb7da Fix checking of ReadFile result in stdio test b170b04 Fix ReadFile result comparison to handle line numbers and formatting differences f48e993 Auto-commit format changes 9abc240 Replace direct session.call_tool call with call_tool_assert_success helper for InitProject 06ee6cb Fix chat_id extraction after changing to call_tool_assert_success f8f2877 Replace direct session.call_tool calls with call_tool_assert_success for both WriteFile and ReadFile HEAD Fix extraction since we already have content directly from call_tool_assert_success ``` codemcp-id: 0-feat-serialize-non-string-content-with-json-dumps ghstack-source-id: 9b94c3e Pull-Request-resolved: #199
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.
Stack from ghstack (oldest at bottom):
When the content parameter to codemcp in codemcp/main.py is not a string, instead of rejecting it, let's serialize it to a string using json.dumps and then proceed. Add a test for this with WriteFile.
codemcp-id: 0-feat-serialize-non-string-content-with-json-dumps