ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
{
"version": "2026.6.33",
"sourceSha256": "d367be489643dd21006b3fcae9ac18c4ea896a4cdfb947cf534d602394048f82",
"patchedSha256": "af840987b7eb1efe129222478026795a002a0d7fcab80a4143f0f7581054abcf",
"replacements": [
[
"/**\n* Truncate oversized tool results in an array of messages (in-memory).\n* Returns a new array with truncated messages.\n*\n* This is used as a pre-emptive guard before sending messages to the LLM,\n* without modifying the session file.\n*/\nfunction truncateOversizedToolResultsInMessages(messages, contextWindowTokens, maxCharsOverride, aggregateMaxCharsOverride, projectionState) {\n\tconst maxChars = Math.max(1, maxCharsOverride ?? calculateMaxToolResultChars(contextWindowTokens));\n\tconst aggregateBudgetChars = calculateRecoveryAggregateToolResultChars(contextWindowTokens, maxChars, aggregateMaxCharsOverride);\n\tconst projectionKeys = projectionState ? getToolResultProjectionKeys(messages, projectionState) : [];\n\tconst branch = messages.map((message, index) => {\n\t\tconst projectionKey = projectionKeys[index];\n\t\tconst projectedMessage = projectionKey ? projectionState?.replacements.get(projectionKey) : void 0;\n\t\tif (projectionKey && projectionState && !projectionState.sourceTextByKey.has(projectionKey)) projectionState.sourceTextByKey.set(projectionKey, getToolResultTextBlocks(message));\n\t\tconst mergedMessage = projectedMessage ? mergeProjectedToolResultMessage(message, projectedMessage, projectionState?.sourceTextByKey.get(projectionKey ?? \"\")) : message;\n\t\treturn {\n\t\t\tid: `message-${index}`,\n\t\t\ttype: \"message\",\n\t\t\tmessage: mergedMessage,\n\t\t\taggregateEligible: !projectionKey || !projectionState?.frozen.has(projectionKey) || projectedMessage !== void 0 && mergedMessage === message\n\t\t};\n\t});\n\tconst plan = buildToolResultReplacementPlan({\n\t\tbranch,\n\t\tmaxChars,\n\t\taggregateBudgetChars,\n\t\tminKeepChars: RECOVERY_MIN_KEEP_CHARS\n\t});\n\tif (projectionState) for (const [index] of messages.entries()) {\n\t\tconst projectionKey = projectionKeys[index];\n\t\tif (projectionKey) projectionState.frozen.add(projectionKey);\n\t}\n\tif (plan.replacements.length === 0) {\n\t\tconst projectedMessages = branch.map((entry) => entry.message);\n\t\treturn {\n\t\t\tmessages: projectedMessages.some((message, index) => message !== messages[index]) ? projectedMessages : messages,\n\t\t\ttruncatedCount: 0\n\t\t};\n\t}\n\tconst replacementIds = new Set(plan.replacements.map((replacement) => replacement.entryId));\n\tconst replacedBranch = applyToolResultReplacementsToBranch(branch, plan.replacements);\n\tif (projectionState) for (const [index, originalMessage] of messages.entries()) {\n\t\tconst projectedMessage = replacedBranch[index]?.message;\n\t\tconst projectionKey = projectionKeys[index];\n\t\tif (projectionKey) {\n\t\t\tprojectionState.frozen.add(projectionKey);\n\t\t\tif (projectedMessage && projectedMessage !== originalMessage) projectionState.replacements.set(projectionKey, projectedMessage);\n\t\t}\n\t}\n\treturn {\n\t\tmessages: replacedBranch.map((entry) => entry.message),\n\t\ttruncatedCount: replacementIds.size\n\t};\n}",
"// ODS: the live prompt projection must never starve a new tool result.\n// Each result reaches the model whole (within the per-result cap) when it is\n// first sent. Only when all results exceed the aggregate budget are older\n// results reduced to a notice, oldest first and down to a low watermark in one\n// step, so the sent prefix changes rarely. Short results stay whole. The choice\n// depends only on transcript order, so later calls and later attempts send the\n// same bytes for the same history.\nconst LIVE_TOOL_RESULT_LOW_WATERMARK = .5;\nconst LIVE_TOOL_RESULT_KEEP_WHOLE_CHARS = 320;\nfunction reduceLiveToolResultToNotice(message, originalChars) {\n\tconst content = message.content;\n\tif (!Array.isArray(content)) return message;\n\tlet noticePlaced = false;\n\tconst nextContent = [];\n\tfor (const block of content) {\n\t\tif (!isToolResultTextBlock(block)) {\n\t\t\tnextContent.push(block);\n\t\t\tcontinue;\n\t\t}\n\t\tif (noticePlaced) continue;\n\t\tnoticePlaced = true;\n\t\tconst notice = formatContextLimitTruncationNotice(originalChars);\n\t\tconst nextBlock = Object.assign({}, block, { text: notice });\n\t\tif (typeof block.content === \"string\") nextBlock.content = notice;\n\t\tnextContent.push(nextBlock);\n\t}\n\treturn {\n\t\t...message,\n\t\tcontent: nextContent\n\t};\n}\n/**\n* Projects tool results for one model request (in-memory).\n* Returns the input array when nothing changes; never modifies the session file.\n*/\nfunction truncateOversizedToolResultsInMessages(messages, contextWindowTokens, maxCharsOverride, aggregateMaxCharsOverride, projectionState) {\n\tconst maxChars = Math.max(1, maxCharsOverride ?? calculateMaxToolResultChars(contextWindowTokens));\n\tconst aggregateBudgetChars = calculateRecoveryAggregateToolResultChars(contextWindowTokens, maxChars, aggregateMaxCharsOverride);\n\tconst lowWatermarkChars = Math.floor(aggregateBudgetChars * LIVE_TOOL_RESULT_LOW_WATERMARK);\n\tconst projected = messages.slice();\n\tconst changed = /* @__PURE__ */ new Set();\n\tconst sizes = /* @__PURE__ */ new Map();\n\tfor (const [index, message] of messages.entries()) {\n\t\tif (!message || message.role !== \"toolResult\") continue;\n\t\tif (getToolResultTextLength(message) > maxChars) {\n\t\t\tprojected[index] = truncateToolResultMessage(message, maxChars, { minKeepChars: RECOVERY_MIN_KEEP_CHARS });\n\t\t\tchanged.add(index);\n\t\t}\n\t\tsizes.set(index, getToolResultTextLength(projected[index]));\n\t}\n\tconst reducible = [];\n\tlet nextReducible = 0;\n\tlet totalChars = 0;\n\tlet batchFirst = 0;\n\tfor (const [index, message] of projected.entries()) {\n\t\tif (!message || message.role !== \"toolResult\") continue;\n\t\tif (projected[index - 1]?.role !== \"toolResult\") batchFirst = index;\n\t\tconst chars = sizes.get(index);\n\t\ttotalChars += chars;\n\t\tif (chars > LIVE_TOOL_RESULT_KEEP_WHOLE_CHARS) reducible.push(index);\n\t\tif (projected[index + 1]?.role === \"toolResult\" || totalChars <= aggregateBudgetChars) continue;\n\t\t// The newest batch is being sent for the first time; reduce only older results.\n\t\twhile (totalChars > lowWatermarkChars && nextReducible < reducible.length && reducible[nextReducible] < batchFirst) {\n\t\t\tconst target = reducible[nextReducible++];\n\t\t\tconst reduced = reduceLiveToolResultToNotice(projected[target], getToolResultTextLength(messages[target]));\n\t\t\ttotalChars += getToolResultTextLength(reduced) - sizes.get(target);\n\t\t\tprojected[target] = reduced;\n\t\t\tchanged.add(target);\n\t\t}\n\t}\n\treturn {\n\t\tmessages: changed.size > 0 ? projected : messages,\n\t\ttruncatedCount: changed.size\n\t};\n}"
]
],
"previousReplacements": {}
}