feat(memos-cloud-server): add --messages-file flag to add_message CLI - #16
Open
DDmouth wants to merge 1 commit into
Open
feat(memos-cloud-server): add --messages-file flag to add_message CLI#16DDmouth wants to merge 1 commit into
DDmouth wants to merge 1 commit into
Conversation
Allow loading the messages payload from a UTF-8 file path instead of the positional `messages` arg. This bypasses the Windows ~32KB argv size limit that breaks large session uploads (e.g. multi-day chat backups). - cli.py: add --messages-file option; make positional `messages` optional - operations.py: read messages from file when --messages-file is set - tests/test_cli.py: 2 new tests covering file path and override behavior Use case: an Agent persisting a long conversation (e.g. 200+ messages, 50KB+ payload) can write messages to disk and pass the path, avoiding the OS-dependent 'Argument list too long' failure that breaks mcporter-style invocations on Windows.
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
The
add_messageCLI currently takes the messages payload as a positionalargparseargument. On Windows, this fails for any payload larger than ~32KB withArgument list too long(the OS argv limit), breaking long-session backups (e.g. multi-day chat uploads, tool-heavy sessions).This PR adds
--messages-file <path>to load the messages JSON from a UTF-8 file instead, mirroring the existing--stdinpattern onadd_kb_doc.Changes
memos_cloud/cli.pymessagesoptional (nargs="?", default"")--messages-file PATHflagmessages_filethroughdispatch()memos_cloud/operations.pyadd_message()accepts newmessages_file: Optional[str]parametermessages_json_strbefore payload constructionmessages_json_strandmessages_fileare set, the file winstests/test_cli.py— 2 new tests:test_cli_add_message_with_messages_file— basic file-based loadingtest_cli_add_message_messages_file_overrides_positional— file takes precedenceAll 49 tests pass (
47 original + 2 new).Usage
Context
Reported by an integration user (Hermes Agent —
memos-backup-workflowskill) running on Windows. Real-world failure case: a 158-message / 113KB session upload succeeded via Python SDK but the CLI subcommand path crashed at the OS layer before reaching the API. The fix is local (no behavior change for existing invocations) and additive (existing positional callers keep working).Backward compatibility
messagesargument is nownargs="?"instead of required, so existing CLI invocations that already pass it continue to work unchanged.messages_fileparameter defaults toNone, so SDK callers see no behavior change.