From 193f03f6c5abf9fc0ca39bc1caa92a3890a75eb0 Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Sun, 8 Nov 2026 18:25:43 +0000 Subject: [PATCH] mcp: a reply too large with its quote is posted without it Claude's posts with a quote are sent again without it also when the core refuses them with largeMsg, as replies that quote a message near the size limit are. --- packages/simplex-chat-mcp/src/hub.ts | 2 +- .../simplex-chat-mcp/test/unit/sessions.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/simplex-chat-mcp/src/hub.ts b/packages/simplex-chat-mcp/src/hub.ts index 7fcb798153..c3456fec62 100644 --- a/packages/simplex-chat-mcp/src/hub.ts +++ b/packages/simplex-chat-mcp/src/hub.ts @@ -550,7 +550,7 @@ function textParts(text: string, quote?: Parameters[2]): str function isRefusedQuote(error: unknown): boolean { const chatError = chatErrorOf(error) - return chatError?.type === "errorStore" && (chatError.storeError.type === "invalidQuote" || chatError.storeError.type === "chatItemNotFound") + return chatError?.type === "errorStore" && (chatError.storeError.type === "invalidQuote" || chatError.storeError.type === "chatItemNotFound" || chatError.storeError.type === "largeMsg") } function sessionDataOf(customData: object | undefined): SessionGroupData | undefined { diff --git a/packages/simplex-chat-mcp/test/unit/sessions.test.ts b/packages/simplex-chat-mcp/test/unit/sessions.test.ts index 89ef000d0d..7c38bc2b2e 100644 --- a/packages/simplex-chat-mcp/test/unit/sessions.test.ts +++ b/packages/simplex-chat-mcp/test/unit/sessions.test.ts @@ -660,6 +660,21 @@ describe("session channel", () => { expect(answers(chat)).toEqual([[{text: "Fixed.", quotedItemId: undefined}], [{text: "Session 1 is not running.", quotedItemId: undefined}]]) }) + it("posts the replies to a member's message without the quote when the core refuses them as too large with it", async () => { + const chat = new FakeChat() + const {session} = await channel(chat) + const send = chat.apiSendMessages.bind(chat) + chat.apiSendMessages = async (ref, messages) => { + if (messages.some(({quotedItemId}) => quotedItemId !== undefined)) throw new core.ChatAPIError("Chat command error", {type: "errorStore", storeError: {type: "largeMsg"}} as unknown as T.ChatError) + return send(ref, messages) + } + session.onLine = undefined + session.onMessage(event(sessionGroup, item(43, "a".repeat(15_400), from(invitedAlice)))) + session.onMessage(event(sessionGroup, item(44, "!ls", from(invitedAlice)))) + await until(() => answers(chat).length === 2) + expect(answers(chat)).toEqual([[{text: "Session 1 is not running.", quotedItemId: undefined}], [{text: "Messages starting with ! reach Claude only from owners, as /!command.", quotedItemId: undefined}]]) + }) + it("posts an answer with a new effort level before the prompt of the next turn, and then the description", async () => { const chat = new FakeChat() const {hub, session} = await channel(chat)