Skip to content

feat: serialize non-string content with json.dumps#199

Open
ezyang wants to merge 2 commits into
gh/ezyang/150/basefrom
gh/ezyang/150/head
Open

feat: serialize non-string content with json.dumps#199
ezyang wants to merge 2 commits into
gh/ezyang/150/basefrom
gh/ezyang/150/head

Conversation

@ezyang
Copy link
Copy Markdown
Owner

@ezyang ezyang commented Mar 24, 2025

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.

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-poisoned]
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
[ghstack-poisoned]
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
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.

1 participant