mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-22 17:48:15 +00:00
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.
This commit is contained in:
1 parent
b7ec77cd63
commit
193f03f6c5
2 files changed
+16
-1
No files matched your search
@@ -550,7 +550,7 @@ function textParts(text: string, quote?: Parameters<typeof fitsMessage>[2]): str
|
|||||||
|
|
||||||
function isRefusedQuote(error: unknown): boolean {
|
function isRefusedQuote(error: unknown): boolean {
|
||||||
const chatError = chatErrorOf(error)
|
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 {
|
function sessionDataOf(customData: object | undefined): SessionGroupData | undefined {
|
||||||
|
|||||||
@@ -660,6 +660,21 @@ describe("session channel", () => {
|
|||||||
expect(answers(chat)).toEqual([[{text: "Fixed.", quotedItemId: undefined}], [{text: "Session 1 is not running.", quotedItemId: undefined}]])
|
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 () => {
|
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 chat = new FakeChat()
|
||||||
const {hub, session} = await channel(chat)
|
const {hub, session} = await channel(chat)
|
||||||
|
|||||||
Reference in new issue
Block a user