mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 07:12:12 +03:00
fix(compression): bound mcpAccessibility maxTextChars on the live read path (#4206)
* fix(compression): bound mcpAccessibility maxTextChars on the live read path
smartFilterText reserves 300 chars for the truncation tail, so a maxTextChars at/below that
makes headSize <= 0 and the whole tool result is replaced by the notice (total data loss). Two
gaps let a bad value reach the engine: the DB normalizer floored maxTextChars only at > 0, and
the live MCP-server read path (readMcpAccessibilityConfig) did a raw {...DEFAULT, ...parsed}
spread with no bounding at all.
Centralize the floors in a shared clampMcpAccessibilityConfig (engine layer) used by both the DB
normalizer and the server read path; values in (0, 600) fall back to the default. Export the
tail-reserve constant (300) and use it in smartFilterText so the engine and the bounds stay in
sync. The F5.3 headSize >= 0 clamp stays as a second layer.
Defense-in-depth today (the config isn't writable via the settings API yet — making it
configurable is a tracked follow-up in the compression-completeness work); this closes the
data-loss path for when it lands.
Part of the compression "100% functional" program (audit follow-up).
* chore(quality): bump server.ts file-size baseline 1457->1458 (#4206 +1 import)
This commit is contained in:
committed by
GitHub
parent
aed2a5024c
commit
4fecb34ac6
@@ -11,6 +11,7 @@ import {
|
||||
DEFAULT_MCP_ACCESSIBILITY_CONFIG,
|
||||
DEFAULT_RTK_CONFIG,
|
||||
DEFAULT_ULTRA_CONFIG,
|
||||
clampMcpAccessibilityConfig,
|
||||
type AggressiveConfig,
|
||||
type CavemanConfig,
|
||||
type CavemanOutputModeConfig,
|
||||
@@ -519,32 +520,10 @@ export function getDefaultRtkConfig(): RtkConfig {
|
||||
}
|
||||
|
||||
function normalizeMcpAccessibilityConfig(value: unknown): McpAccessibilityConfig {
|
||||
const record = toRecord(value);
|
||||
return {
|
||||
...DEFAULT_MCP_ACCESSIBILITY_CONFIG,
|
||||
...record,
|
||||
enabled: record.enabled !== false,
|
||||
maxTextChars:
|
||||
typeof record.maxTextChars === "number" && record.maxTextChars > 0
|
||||
? Math.floor(record.maxTextChars)
|
||||
: DEFAULT_MCP_ACCESSIBILITY_CONFIG.maxTextChars,
|
||||
collapseThreshold:
|
||||
typeof record.collapseThreshold === "number" && record.collapseThreshold > 0
|
||||
? Math.floor(record.collapseThreshold)
|
||||
: DEFAULT_MCP_ACCESSIBILITY_CONFIG.collapseThreshold,
|
||||
collapseKeepHead:
|
||||
typeof record.collapseKeepHead === "number" && record.collapseKeepHead >= 0
|
||||
? Math.floor(record.collapseKeepHead)
|
||||
: DEFAULT_MCP_ACCESSIBILITY_CONFIG.collapseKeepHead,
|
||||
collapseKeepTail:
|
||||
typeof record.collapseKeepTail === "number" && record.collapseKeepTail >= 0
|
||||
? Math.floor(record.collapseKeepTail)
|
||||
: DEFAULT_MCP_ACCESSIBILITY_CONFIG.collapseKeepTail,
|
||||
minLengthToProcess:
|
||||
typeof record.minLengthToProcess === "number" && record.minLengthToProcess > 0
|
||||
? Math.floor(record.minLengthToProcess)
|
||||
: DEFAULT_MCP_ACCESSIBILITY_CONFIG.minLengthToProcess,
|
||||
};
|
||||
// clampMcpAccessibilityConfig (engine layer) owns the numeric floors so the DB normalizer and
|
||||
// the live MCP-server read path agree — in particular it floors maxTextChars to a sane minimum
|
||||
// (a value below the tail reservation would make smartFilterText truncate the whole text away).
|
||||
return clampMcpAccessibilityConfig(value);
|
||||
}
|
||||
|
||||
export async function getMcpAccessibilityConfig(): Promise<McpAccessibilityConfig> {
|
||||
|
||||
Reference in New Issue
Block a user