From 8bc7de441676cc11c60ea69a845285964479d43b Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sun, 2 Nov 2025 03:05:30 +0530 Subject: [PATCH] SimpleChatTC:TC Result truncating only if needed As I was seeing the truncated message even for stripped plain text web acces, relooking at that initial go at truncating, revealed a oversight, which had the truncation logic trigger anytime the iResultMaxDataLength was greater than 0, irrespective of whether the actual result was smaller than the allowed limit or not, thus adding that truncated message to end of result unnecessarily. Have fixed that oversight Also recent any number of args based simpleprox handshake helper in toolweb seems to be working (atleast for the existing single arg based calls). --- tools/server/public_simplechat/readme.md | 2 +- tools/server/public_simplechat/simplechat.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index 7b98b832ac..326c9120a3 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -261,7 +261,7 @@ It is attached to the document object. Some of these can also be updated using t * iResultMaxDataLength - specify what amount of any tool call result should be sent back to the ai engine server. - * specifying 0 disables this truncating of the results. + * specifying 0 disables this truncating of the results, and inturn full result will be sent to the ai engine server. * toolCallResponseTimeoutMS - specifies the time (in msecs) for which the logic should wait for a tool call to respond before a default timed out error response is generated and control given back to end user, for them to decide whether diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index c780373783..317637a59e 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -1093,7 +1093,9 @@ class MultiChatUI { let chat = this.simpleChats[cid]; let limitedData = data if (gMe.tools.iResultMaxDataLength > 0) { - limitedData = data.slice(0, gMe.tools.iResultMaxDataLength) + `\n\n\nALERT: Data too long, was chopped ....` + if (data.length > gMe.tools.iResultMaxDataLength) { + limitedData = data.slice(0, gMe.tools.iResultMaxDataLength) + `\n\n\nALERT: Data too long, was chopped ....` + } } chat.add(new ChatMessageEx(Roles.ToolTemp, ChatMessageEx.createToolCallResultAllInOne(tcid, name, limitedData))) if (this.chat_show(cid)) {