diff --git a/src/compress-tool.ts b/src/compress-tool.ts index bff555d253..ad890781de 100644 --- a/src/compress-tool.ts +++ b/src/compress-tool.ts @@ -140,17 +140,21 @@ export const BILI_SEARCH_CONTEXT_TOOL_GOOGLE = { // #1179 CCR v2: host-side range-restore extension of decompress. Optional // startId/endId (mNNNNN refs) restore only the block's messages inside that -// span instead of the whole block. Served unconditionally on every wire + the -// plugin manifest (one definition, no drift — same rule as conversation_id -// above); execution is gated on CCR being armed for the session -// (resolveDecompressRange fails explicitly when it is not). +// span instead of the whole block. Execution is gated on CCR being armed for +// the session (resolveDecompressRange fails explicitly when it is not), so +// the params are advertised ONLY where they can work (#1712): proxy-lane wire +// injection serves the *_NO_RANGE variant while the session is unarmed, and +// the plugin manifest serves them only when the base config enables CCR +// (plugin policy is the base block verbatim, #1345) — same conservative rule +// as acp_retrieve/absorb/rule in handlePluginManifest (#1192/#1271). Blank or +// whitespace values are treated as omitted at execution (whole-block restore). const DECOMPRESS_RANGE_PARAM_START = { type: "string", - description: "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled).", + description: "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted.", }; const DECOMPRESS_RANGE_PARAM_END = { type: "string", - description: "Optional mNNNNN message ref, inclusive upper bound. Used together with startId.", + description: "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block.", }; function withRangeParams(schema: JsonSchemaObject): JsonSchemaObject { @@ -166,6 +170,15 @@ export const BILI_ACP_TOOLS_ANTHROPIC = ACP_TOOLS_ANTHROPIC.map((t) => (t.name = export const BILI_ACP_TOOLS_OPENAI = ACP_TOOLS_OPENAI.map((t) => (t.function.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_OPENAI : t.function.name === DECOMPRESS_TOOL_NAME ? BILI_DECOMPRESS_TOOL_OPENAI : t)); export const BILI_ACP_TOOLS_RESPONSES = ACP_TOOLS_RESPONSES.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t.name === DECOMPRESS_TOOL_NAME ? BILI_DECOMPRESS_TOOL_RESPONSES : t)); export const BILI_ACP_TOOLS_GOOGLE = ACP_TOOLS_GOOGLE.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_GOOGLE : t.name === DECOMPRESS_TOOL_NAME ? BILI_DECOMPRESS_TOOL_GOOGLE : t)); + +// #1712: no-range variants — identical except decompress lacks startId/endId. +// Served where range restore cannot be armed so the advertised schema never +// offers what execution will refuse (see the #1179 note above). +export const BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE = ACP_TOOLS_ANTHROPIC.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL : t)); +export const BILI_ACP_TOOLS_OPENAI_NO_RANGE = ACP_TOOLS_OPENAI.map((t) => (t.function.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_OPENAI : t)); +export const BILI_ACP_TOOLS_RESPONSES_NO_RANGE = ACP_TOOLS_RESPONSES.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t)); +export const BILI_ACP_TOOLS_GOOGLE_NO_RANGE = ACP_TOOLS_GOOGLE.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_GOOGLE : t)); +export const BILI_ACP_READONLY_TOOLS_RESPONSES_NO_RANGE = ACP_READONLY_TOOLS_RESPONSES.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t)); export const BILI_ACP_READONLY_TOOLS_RESPONSES = ACP_READONLY_TOOLS_RESPONSES.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t.name === DECOMPRESS_TOOL_NAME ? BILI_DECOMPRESS_TOOL_RESPONSES : t)); // The kernel ships no Responses-format absorb const (the four ACP tools have diff --git a/src/decompress-shared.ts b/src/decompress-shared.ts index 5603aed2a5..0d34a950c3 100644 --- a/src/decompress-shared.ts +++ b/src/decompress-shared.ts @@ -108,6 +108,14 @@ function toFilePointer(args: Record, ctx: ProxyToolCtx, header: * - Otherwise fall back to collectBlockContent against the unfolded view * (ctx.compressMessages ?? ctx.messages); if that yields nothing, return * the block summary. */ +/** A decompress call asks for a range restore only when at least one range + * field carries a non-blank value (#1712). */ +function hasRangeArgs(args: Record): boolean { + const start = typeof args.startId === "string" ? args.startId.trim() : ""; + const end = typeof args.endId === "string" ? args.endId.trim() : ""; + return start !== "" || end !== ""; +} + export function resolveDecompress( args: Record, ctx: ProxyToolCtx, @@ -123,7 +131,10 @@ export function resolveDecompress( if (archived[blockId] !== undefined) { return `[decompress FAILED: block ${blockId} is a pre-compaction archive — its content was in the history BEFORE the client's native compaction and is no longer reachable (replaced by the client's compaction summary). decompress is unavailable for archived blocks.]`; } - if (typeof args.startId === "string" || typeof args.endId === "string") { + // #1712: blank/whitespace range fields mean "unspecified" — hosts and models + // emit "" for optional fields, and treating that as a range request produced + // an unsatisfiable retry loop (fill in a real range → refused in plugin mode). + if (hasRangeArgs(args)) { return resolveDecompressRange(args, ctx, block); } @@ -253,14 +264,16 @@ export function coveredRefSpan(state: CompressionState, block: CompressionBlock) function resolveDecompressRange(args: Record, ctx: ProxyToolCtx, block: CompressionBlock): string { const startRaw = typeof args.startId === "string" ? args.startId.trim() : ""; const endRaw = typeof args.endId === "string" ? args.endId.trim() : ""; - if (!startRaw || !endRaw) return "[decompress FAILED: startId and endId must be given together]"; + if (!startRaw || !endRaw) return "[decompress FAILED: startId and endId must be given together — pass both mNNNNN refs, or omit both to restore the whole block]"; if (!ccrEnabled(ctx.session)) { - // [#1207 review F3] Plugin mode structurally never arms CCR (the agent - // owns its folds; bili never executes them) — the generic "enable - // compress.ccr.enabled" advice is unsatisfiable there and would send - // the model chasing a config that cannot help. + // Range restore needs the CCR content store; a CCR-off session has none. + // In plugin mode the model cannot enable CCR itself (it lives in the + // proxy's base config — plugin policy is the base block verbatim, + // #1345), so pointing it at the setting sends it chasing a config it + // cannot change (#1207 review F3). Give it the working call instead: + // whole-block restore with just blockId (#1712). if (typeof ctx.session.metadata.pluginAgent === "string") { - return "[decompress FAILED: range restore (startId/endId) is proxy-mode only — plugin mode owns its folds natively]"; + return `[decompress FAILED: range restore (startId/endId) requires CCR, which this plugin-mode session does not have — omit startId/endId and restore the whole block: {"blockId":"${block.blockId}"}]`; } return "[decompress FAILED: range restore (startId/endId) requires CCR — enable compress.ccr.enabled]"; } @@ -444,7 +457,7 @@ function resolveDerivedDecompress( if (preCompactionArchiveOf(anc)[blockId] !== undefined) { return `[decompress FAILED: block ${blockId} is a pre-compaction archive in derived session ${anc.id} — its content was replaced by the client's compaction summary and is no longer reachable.]`; } - if (typeof args.startId === "string" || typeof args.endId === "string") { + if (hasRangeArgs(args)) { return `[decompress FAILED: range restore (startId/endId) of derived-parent blocks is not supported — decompress "${blockId}" without range args (#1333)]`; } const full = args.full === true; diff --git a/src/plugin.ts b/src/plugin.ts index 649fda6aee..0ceb98c40e 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -6,7 +6,7 @@ import fs from "node:fs"; import path from "node:path"; import { acquireInFlight, diagnoseSuccessWithoutUsage, effectiveConfig, findSessionByCanonicalId, listSessions, markCompactionBoundary, markDirty, peekSession, releaseInFlight, withSessionLock, type Session } from "./session.js"; import { clientConversationHeader } from "./session-id.js"; -import { ABSORB_TOOL_NAME, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_RESPONSES, PROXY_TOOL_NAMES, RETRIEVE_TOOL_NAME, RULE_TOOL, RULE_TOOL_NAME, RULE_TOOL_OPENAI, RULE_TOOL_RESPONSES, SEARCH_CONTEXT_CONVERSATION_ID_PARAM, SEARCH_CONTEXT_TOOL_NAME, absorbToolsFor, retrieveToolsFor } from "./compress-tool.js"; +import { ABSORB_TOOL_NAME, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_OPENAI_NO_RANGE, BILI_ACP_TOOLS_RESPONSES_NO_RANGE, PROXY_TOOL_NAMES, RETRIEVE_TOOL_NAME, RULE_TOOL, RULE_TOOL_NAME, RULE_TOOL_OPENAI, RULE_TOOL_RESPONSES, SEARCH_CONTEXT_CONVERSATION_ID_PARAM, SEARCH_CONTEXT_TOOL_NAME, absorbToolsFor, retrieveToolsFor } from "./compress-tool.js"; import { absorbEnabled, effectiveAbsorbConfig, isProxyToolFor } from "./absorb.js"; import { effectiveRulesEnabled, rulesEnabled } from "./rules-feature.js"; import { executeProxyTool } from "./loop/core.js"; @@ -627,6 +627,18 @@ export function handlePluginManifest(res: import("node:http").ServerResponse, co const ccrOn = config.ccr?.enabled === true; const ccrName = config.ccr?.toolName ?? RETRIEVE_TOOL_NAME; const ccrTools = ccrOn ? retrieveToolsFor(ccrName) : undefined; + // #1712: decompress's startId/endId (range restore) executes only on CCR-armed + // sessions, so the manifest advertises them only when the base config enables + // CCR (#1345 plugin policy = base block verbatim) — same conservative #1192 + // rule as acp_retrieve above. CCR-off manifests serve the no-range variants so + // a registered agent never sees range fields execution would refuse. + const acpAnthropic = ccrOn ? BILI_ACP_TOOLS_ANTHROPIC : BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE; + const acpOpenai = ccrOn ? BILI_ACP_TOOLS_OPENAI : BILI_ACP_TOOLS_OPENAI_NO_RANGE; + // Responses wire: plugin mode structurally disarms CCR there (#1271 — + // PLUGIN_CCR_WIRES excludes it), so range restore can never execute for a + // registered agent on that wire — always the no-range variant, mirroring + // how ccrTools above is never spread into the responses array. + const acpResponses = BILI_ACP_TOOLS_RESPONSES_NO_RANGE; res.writeHead(200, { "content-type": "application/json" }); res.end(JSON.stringify({ ok: true, @@ -635,9 +647,9 @@ export function handlePluginManifest(res: import("node:http").ServerResponse, co version: VERSION, toolNames: [...PROXY_TOOL_NAMES, ...(absorbTools ? [absorbName] : []), ...(rulesOn ? [RULE_TOOL_NAME] : []), ...(ccrOn ? [ccrName] : [])], tools: { - anthropic: withSearchContextConversationDescription([...BILI_ACP_TOOLS_ANTHROPIC, ...(absorbTools ? [absorbTools.anthropic] : []), ...(rulesOn ? [RULE_TOOL] : []), ...(ccrTools ? [ccrTools.anthropic] : [])].map(withConversationIdParam)), - openai: withSearchContextConversationDescription([...BILI_ACP_TOOLS_OPENAI, ...(absorbTools ? [absorbTools.openai] : []), ...(rulesOn ? [RULE_TOOL_OPENAI] : []), ...(ccrTools ? [ccrTools.openai] : [])].map(withConversationIdParam)), - responses: withSearchContextConversationDescription([...BILI_ACP_TOOLS_RESPONSES, ...(absorbTools ? [absorbTools.responses] : []), ...(rulesOn ? [RULE_TOOL_RESPONSES] : [])].map(withConversationIdParam)), + anthropic: withSearchContextConversationDescription([...acpAnthropic, ...(absorbTools ? [absorbTools.anthropic] : []), ...(rulesOn ? [RULE_TOOL] : []), ...(ccrTools ? [ccrTools.anthropic] : [])].map(withConversationIdParam)), + openai: withSearchContextConversationDescription([...acpOpenai, ...(absorbTools ? [absorbTools.openai] : []), ...(rulesOn ? [RULE_TOOL_OPENAI] : []), ...(ccrTools ? [ccrTools.openai] : [])].map(withConversationIdParam)), + responses: withSearchContextConversationDescription([...acpResponses, ...(absorbTools ? [absorbTools.responses] : []), ...(rulesOn ? [RULE_TOOL_RESPONSES] : [])].map(withConversationIdParam)), }, headers: { agent: PLUGIN_AGENT_HEADER, conversation: PLUGIN_CONVERSATION_HEADER, contextWindow: PLUGIN_CONTEXT_WINDOW_HEADER, maxOutput: PLUGIN_MAX_OUTPUT_HEADER, model: PLUGIN_MODEL_HEADER, instructionsMutable: PLUGIN_INSTRUCTIONS_MUTABLE_HEADER }, toolEndpoint: "/__bili/plugin/tool", diff --git a/src/server.ts b/src/server.ts index d8b39c28f3..1e83d0d52a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -64,7 +64,7 @@ import { type GoogleSystemInstruction, type GoogleTool, } from "acp-kernel/wire"; -import { ABSORB_TOOL_NAME, COMPRESS_TOOL, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_GOOGLE, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_RESPONSES, BILI_ACP_READONLY_TOOLS_RESPONSES, COMPRESS_TOOL_NAME, IMAGE_FULL_TOOL, IMAGE_FULL_TOOL_GOOGLE, IMAGE_FULL_TOOL_OPENAI, IMAGE_FULL_TOOL_RESPONSES, RULE_TOOL, RULE_TOOL_GOOGLE, RULE_TOOL_OPENAI, RULE_TOOL_RESPONSES, absorbToolsFor, retrieveToolsFor, buildAbsorbSystemPrompt, buildCompressSystemPrompt, buildCompressHybridSystemPrompt, withConversationIdNote, withMarkerIntegrityNote, withStagedCompressGuidance, withSummaryBudgetNote } from "./compress-tool.js"; +import { ABSORB_TOOL_NAME, COMPRESS_TOOL, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE, BILI_ACP_TOOLS_GOOGLE, BILI_ACP_TOOLS_GOOGLE_NO_RANGE, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_OPENAI_NO_RANGE, BILI_ACP_TOOLS_RESPONSES, BILI_ACP_TOOLS_RESPONSES_NO_RANGE, BILI_ACP_READONLY_TOOLS_RESPONSES, BILI_ACP_READONLY_TOOLS_RESPONSES_NO_RANGE, COMPRESS_TOOL_NAME, IMAGE_FULL_TOOL, IMAGE_FULL_TOOL_GOOGLE, IMAGE_FULL_TOOL_OPENAI, IMAGE_FULL_TOOL_RESPONSES, RULE_TOOL, RULE_TOOL_GOOGLE, RULE_TOOL_OPENAI, RULE_TOOL_RESPONSES, absorbToolsFor, retrieveToolsFor, buildAbsorbSystemPrompt, buildCompressSystemPrompt, buildCompressHybridSystemPrompt, withConversationIdNote, withMarkerIntegrityNote, withStagedCompressGuidance, withSummaryBudgetNote } from "./compress-tool.js"; import { applyAbsorbView, absorbEnabled, absorbToolName, storeEffectiveAbsorb } from "./absorb.js"; import { adoptContentStore, ccrEnabled, ccrLoopConfig, ccrPluginWireOk, commitRetrievals, commitRetrievalNotes, contentStoreOf, dropRetrievals, executeRetrieve, pruneExpiredRetrievals, reconcileReloadedRetrievals, renderRetrievalNotes, retrieveToolName, snapshotPendingRetrievals, snapshotRetrievalNotes, storeEffectiveCcr, type CcrSettings } from "./store.js"; import { applyImageCompressionPass, imageCompressionEnabled, imageFullTrailingNote, imageUsageSuffix, storeEffectiveImageCompression, type ImageCompressionSettings } from "./image-compress.js"; @@ -3365,7 +3365,7 @@ async function prepareAnthropic( // the compress prompt on round-2, the exact F2 seam the matrix pins). systemOut = stampAnthropicSystemCacheControl(systemOut, anthropicCacheMarks !== undefined); if (injectTools) { - toolsOut = injectTool(parsed.tools, [...(absorbActive ? [absorbTools.anthropic] : []), ...(rulesActive ? [RULE_TOOL] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).anthropic] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL] : [])], surface?.toolPrompts); + toolsOut = injectTool(parsed.tools, [...(absorbActive ? [absorbTools.anthropic] : []), ...(rulesActive ? [RULE_TOOL] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).anthropic] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL] : [])], surface?.toolPrompts, ccrEnabled(session)); } // Nudge as a separate trailing user message (cache-friendly): the // system block stays byte-stable so the prefix cache survives. @@ -3596,7 +3596,7 @@ async function prepareOpenai( // avoids double-counting it. openaiOutboundSystem = sysParts.join("\n\n"); if (injectTools) { - toolsOut = injectOpenaiTool(parsed.tools, [...(absorbActive ? [absorbTools.openai] : []), ...(rulesActive ? [RULE_TOOL_OPENAI] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).openai] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL_OPENAI] : [])], surface?.toolPrompts); + toolsOut = injectOpenaiTool(parsed.tools, [...(absorbActive ? [absorbTools.openai] : []), ...(rulesActive ? [RULE_TOOL_OPENAI] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).openai] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL_OPENAI] : [])], surface?.toolPrompts, ccrEnabled(session)); } // Nudge as a separate trailing user message (cache-friendly). Injected // in BOTH modes (#451): plugin agents supply the ACP tools but have no @@ -3822,7 +3822,7 @@ async function prepareGoogle( const extraSystemParts = sysParts.slice(googleClientSystem ? 1 : 0); systemInstruction = extraSystemParts.length > 0 ? { parts: sysParts.map((text) => ({ text })) } : parsed.systemInstruction; if (injectTools) { - toolsOut = injectGoogleTool(parsed.tools, [...(absorbActive ? [absorbTools.google] : []), ...(rulesActive ? [RULE_TOOL_GOOGLE] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).google] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL_GOOGLE] : [])], surface?.toolPrompts); + toolsOut = injectGoogleTool(parsed.tools, [...(absorbActive ? [absorbTools.google] : []), ...(rulesActive ? [RULE_TOOL_GOOGLE] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).google] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL_GOOGLE] : [])], surface?.toolPrompts, ccrEnabled(session)); } if (sysNotes.length > 0) { rebuiltContents = appendGoogleNudge(rebuiltContents, sysNotes.join("\n\n---\n\n")); @@ -4110,10 +4110,13 @@ async function prepareResponses( if (forgedSummaries.length > 0) log("debug", `[${sessionId}] [inject] ${forgedSummaries.length} captured summary block(s) re-injected into developer message`); rebuiltInput = injectResponsesDeveloperMessage(rebuiltInput, devContent); if (!process.env.ACP_NO_INJECT_TOOL && injectTools) { - const respExtra = [...(absorbActive ? [absorbTools.responses] : []), ...(rulesActive ? [RULE_TOOL_RESPONSES] : []), ...(ccrEnabled(session) ? [retrieveToolsFor(retrieveToolName(session)).responses] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL_RESPONSES] : [])]; + // #1712: decompress's startId/endId execute only on CCR-armed + // sessions (#1179) — serve the no-range schema otherwise. + const ccrOn = ccrEnabled(session); + const respExtra = [...(absorbActive ? [absorbTools.responses] : []), ...(rulesActive ? [RULE_TOOL_RESPONSES] : []), ...(ccrOn ? [retrieveToolsFor(retrieveToolName(session)).responses] : []), ...(imageCompressionEnabled(session) ? [IMAGE_FULL_TOOL_RESPONSES] : [])]; toolsOut = responsesTextProtocol - ? injectResponsesTool(parsed.tools, BILI_ACP_READONLY_TOOLS_RESPONSES, surface?.toolPrompts) - : injectResponsesTool(parsed.tools, respExtra.length > 0 ? [...BILI_ACP_TOOLS_RESPONSES, ...respExtra] : BILI_ACP_TOOLS_RESPONSES, surface?.toolPrompts); + ? injectResponsesTool(parsed.tools, ccrOn ? BILI_ACP_READONLY_TOOLS_RESPONSES : BILI_ACP_READONLY_TOOLS_RESPONSES_NO_RANGE, surface?.toolPrompts) + : injectResponsesTool(parsed.tools, respExtra.length > 0 ? [...(ccrOn ? BILI_ACP_TOOLS_RESPONSES : BILI_ACP_TOOLS_RESPONSES_NO_RANGE), ...respExtra] : (ccrOn ? BILI_ACP_TOOLS_RESPONSES : BILI_ACP_TOOLS_RESPONSES_NO_RANGE), surface?.toolPrompts); } } else if (projection.systemParts.length > 0 || forgedSummaries.length > 0) { const devContent = [...projection.systemParts, ...forgedSummaries].join("\n\n---\n\n"); @@ -4513,8 +4516,10 @@ function injectSystem( // cannot be filtered per request) are dropped here so the upstream sees // exactly one definition per name, and it is bili's (its arg schemas are what // the compress loop dispatches on). Plugin mode never calls these helpers. -function injectTool(tools: unknown[] | undefined, extras?: readonly { name: string }[], toolPrompts?: ToolPrompts): unknown[] { - const acp = applyAcpToolOverrides(BILI_ACP_TOOLS_ANTHROPIC, toolPrompts); +function injectTool(tools: unknown[] | undefined, extras?: readonly { name: string }[], toolPrompts?: ToolPrompts, ccrOn = false): unknown[] { + // #1712: decompress's startId/endId execute only on CCR-armed sessions + // (#1179), so serve the no-range schema when CCR is off. + const acp = applyAcpToolOverrides(ccrOn ? BILI_ACP_TOOLS_ANTHROPIC : BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE, toolPrompts); const list = extras ?? []; if (!Array.isArray(tools)) return [...acp, ...list]; const owned = new Set(acp.map((t) => t.name)); @@ -4526,8 +4531,8 @@ function injectTool(tools: unknown[] | undefined, extras?: readonly { name: stri return [...kept, ...acp, ...list]; } -function injectOpenaiTool(tools: OpenAITool[] | undefined, extras?: readonly OpenAITool[], toolPrompts?: ToolPrompts): OpenAITool[] { - const acp = applyAcpToolOverrides(BILI_ACP_TOOLS_OPENAI, toolPrompts) as OpenAITool[]; +function injectOpenaiTool(tools: OpenAITool[] | undefined, extras?: readonly OpenAITool[], toolPrompts?: ToolPrompts, ccrOn = false): OpenAITool[] { + const acp = applyAcpToolOverrides(ccrOn ? BILI_ACP_TOOLS_OPENAI : BILI_ACP_TOOLS_OPENAI_NO_RANGE, toolPrompts) as OpenAITool[]; const list = extras ?? []; if (!Array.isArray(tools)) return [...acp, ...list] as OpenAITool[]; const owned = new Set(acp.map((t) => t.function.name)); @@ -4543,8 +4548,8 @@ function injectOpenaiTool(tools: OpenAITool[] | undefined, extras?: readonly Ope * nests declarations one level deeper than the OpenAI shape * (`tools[].functionDeclarations[]`), so presence is collected across every * entry and the missing declarations are appended as one new entry. */ -function injectGoogleTool(tools: GoogleTool[] | undefined, extra?: { name: string }[], toolPrompts?: ToolPrompts): GoogleTool[] { - const acp = applyAcpToolOverrides(BILI_ACP_TOOLS_GOOGLE, toolPrompts) as GoogleFunctionDeclaration[]; +function injectGoogleTool(tools: GoogleTool[] | undefined, extra?: { name: string }[], toolPrompts?: ToolPrompts, ccrOn = false): GoogleTool[] { + const acp = applyAcpToolOverrides(ccrOn ? BILI_ACP_TOOLS_GOOGLE : BILI_ACP_TOOLS_GOOGLE_NO_RANGE, toolPrompts) as GoogleFunctionDeclaration[]; const wanted: { name: string }[] = extra ? [...acp, ...extra] : [...acp]; if (!Array.isArray(tools)) return [{ functionDeclarations: wanted as GoogleFunctionDeclaration[] }]; const present = new Set(); diff --git a/tests/decompress-empty-range.test.ts b/tests/decompress-empty-range.test.ts new file mode 100644 index 0000000000..5ea8e325f2 --- /dev/null +++ b/tests/decompress-empty-range.test.ts @@ -0,0 +1,186 @@ +// #1712: blank optional decompress range fields (startId/endId = "" or +// whitespace) must mean "unspecified" → whole-block restore, not a +// "given together" failure. One-sided non-blank still fails, now steering to +// omitting both. And the advertised decompress schema must not offer range +// args where execution refuses them: plugin manifest advertises them only on +// the wires whose CCR can arm (anthropic/openai, base-config enabled per +// #1345/#1271), proxy wire injection only while the session is CCR-armed. +import test from "node:test"; +import assert from "node:assert/strict"; + +process.env.BILI_PERSIST = "0"; + +import { createCore, defaultConfig, DECOMPRESS_TOOL_NAME, SEARCH_CONTEXT_TOOL_NAME, type Config, type CoreMessage } from "acp-kernel"; +import { applyCompressSettings } from "../src/compress-settings.ts"; +import { storeEffectiveCcr } from "../src/store.ts"; +import { getSession } from "../src/session.ts"; +import { parseCompressInput, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_OPENAI_NO_RANGE, BILI_ACP_TOOLS_RESPONSES, BILI_ACP_TOOLS_RESPONSES_NO_RANGE, BILI_ACP_TOOLS_GOOGLE, BILI_ACP_TOOLS_GOOGLE_NO_RANGE, BILI_ACP_READONLY_TOOLS_RESPONSES, BILI_ACP_READONLY_TOOLS_RESPONSES_NO_RANGE } from "../src/compress-tool.ts"; +import { applyRanges } from "../src/stream.ts"; +import { resolveDecompress } from "../src/decompress-shared.ts"; +import { handlePluginManifest } from "../src/plugin.ts"; + +const pad = (n: number): string => String(n).padStart(5, "0"); + +function makeMsgs(): CoreMessage[] { + const msgs: CoreMessage[] = []; + for (let i = 0; i < 20; i++) { + msgs.push({ + id: `h_${i}`, + role: i % 2 === 0 ? "user" : "assistant", + contentType: "text", + text: `\x3cacp tokens="2K" type="text"\x3em${pad(i + 1)}\x3c/acp\x3e\nHistorical detail ${i}. ${"x".repeat(2000)}`, + }); + } + return msgs; +} + +type FoldResult = { + core: ReturnType; + config: Config; + session: ReturnType; + msgs: CoreMessage[]; + blockId: string; +}; + +function fold(opts: { ccr: boolean; plugin?: string }): FoldResult { + const core = createCore(); + const config = applyCompressSettings( + defaultConfig(200_000), + 200_000, + { ccr: opts.ccr ? { enabled: true, minToolTokens: 50 } : { enabled: false, minToolTokens: 50 } }, + ) as Config; + const session = getSession(`d1712-${Math.random().toString(36).slice(2)}`); + if (opts.ccr) storeEffectiveCcr(session, { enabled: true, minToolTokens: 50 }); + if (opts.plugin) session.metadata.pluginAgent = opts.plugin; + const raw = makeMsgs(); + const turn = core.processTurn({ messages: raw, state: session.state, config, tokenCount: 9999, renderTags: "text-only" }); + session.state = turn.state; + const ctx = { core, config, messages: turn.messages, session, log: () => {} }; + applyRanges(parseCompressInput({ content: [{ startId: "m00001", endId: "m00007", summary: "Early history: messages 1-7 covered initial setup.", topic: "Early history" }] }), ctx); + const block = [...session.state.blocks].find((b) => b.active); + assert.ok(block, "a block was created"); + return { core, config, session, msgs: turn.messages, blockId: block.blockId }; +} + +function ctxOf(f: FoldResult) { + return { core: f.core, config: f.config, messages: f.msgs, session: f.session, log: () => {} }; +} + +test("#1712: both range fields blank → whole-block restore, no failure", () => { + const f = fold({ ccr: true }); + const out = resolveDecompress({ blockId: f.blockId, startId: "", endId: "" }, ctxOf(f)); + assert.doesNotMatch(out, /FAILED/, `blank range fields must not fail: ${out.slice(0, 120)}`); + assert.match(out, new RegExp(`^\\[Block ${f.blockId} content \\u2014`)); +}); + +test("#1712: whitespace-only range fields count as omitted too", () => { + const f = fold({ ccr: true }); + const out = resolveDecompress({ blockId: f.blockId, startId: " ", endId: "\t" }, ctxOf(f)); + assert.doesNotMatch(out, /FAILED/); + assert.match(out, new RegExp(`^\\[Block ${f.blockId} content \\u2014`)); +}); + +test("#1712: one field missing + other blank → whole-block restore", () => { + const f = fold({ ccr: true }); + const out = resolveDecompress({ blockId: f.blockId, startId: "" }, ctxOf(f)); + assert.doesNotMatch(out, /FAILED/); + assert.match(out, new RegExp(`^\\[Block ${f.blockId} content \\u2014`)); +}); + +test("#1712: one-sided non-blank still requires both, and steers to omitting them", () => { + const f = fold({ ccr: true }); + const outStart = resolveDecompress({ blockId: f.blockId, startId: "m00002", endId: "" }, ctxOf(f)); + assert.match(outStart, /startId and endId must be given together/); + assert.match(outStart, /omit both to restore the whole block/); + const outEnd = resolveDecompress({ blockId: f.blockId, endId: "m00004" }, ctxOf(f)); + assert.match(outEnd, /startId and endId must be given together/); +}); + +test("#1712: plugin mode without CCR points at the working call shape instead of dead-end param filling", () => { + const f = fold({ ccr: false, plugin: "omp" }); + const out = resolveDecompress({ blockId: f.blockId, startId: "m00002", endId: "m00004" }, ctxOf(f)); + assert.match(out, /plugin-mode session does not have/); + assert.ok(out.includes(`{"blockId":"${f.blockId}"}`), `copy-pasteable guidance: ${out}`); + assert.doesNotMatch(out, /is proxy-mode only/); +}); + +test("#1712: proxy mode without CCR keeps the enable-CCR error", () => { + const f = fold({ ccr: false }); + const out = resolveDecompress({ blockId: f.blockId, startId: "m00002", endId: "m00004" }, ctxOf(f)); + assert.match(out, /requires CCR \u2014 enable compress\.ccr\.enabled/); +}); + +type FlatTool = { name?: string; description?: string; input_schema?: Record; parameters?: Record; function?: { name?: string; parameters?: Record } }; + +function propsOf(arr: unknown[], name: string): Record | undefined { + const e = arr.find((t) => { + const o = t as FlatTool; + return o.name === name || o.function?.name === name; + }) as FlatTool | undefined; + if (!e) return undefined; + const schema = (e.input_schema ?? e.parameters ?? e.function?.parameters) as { properties?: Record } | undefined; + return schema?.properties; +} + +function namesOf(arr: unknown[]): string[] { + return arr.map((t) => { + const o = t as FlatTool; + return o.name ?? o.function?.name ?? ""; + }).sort(); +} + +const RANGE_PAIRS: [unknown[], unknown[]][] = [ + [BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE], + [BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_OPENAI_NO_RANGE], + [BILI_ACP_TOOLS_RESPONSES, BILI_ACP_TOOLS_RESPONSES_NO_RANGE], + [BILI_ACP_TOOLS_GOOGLE, BILI_ACP_TOOLS_GOOGLE_NO_RANGE], + [BILI_ACP_READONLY_TOOLS_RESPONSES, BILI_ACP_READONLY_TOOLS_RESPONSES_NO_RANGE], +]; + +test("#1712: with-range arrays expose optional startId/endId; NO_RANGE variants drop exactly those", () => { + for (const [withRange, noRange] of RANGE_PAIRS) { + const wr = propsOf(withRange, DECOMPRESS_TOOL_NAME); + assert.ok(wr, "decompress present in with-range array"); + assert.equal(wr.startId?.type, "string"); + assert.equal(wr.endId?.type, "string"); + const nr = propsOf(noRange, DECOMPRESS_TOOL_NAME); + assert.ok(nr, "decompress present in NO_RANGE array"); + assert.equal(nr.startId, undefined, "NO_RANGE drops startId"); + assert.equal(nr.endId, undefined, "NO_RANGE drops endId"); + assert.deepEqual(namesOf(noRange as unknown[]), namesOf(withRange as unknown[]), "tool set otherwise identical"); + const sc = propsOf(noRange as unknown[], SEARCH_CONTEXT_TOOL_NAME); + assert.equal(sc?.conversation_id?.type, "string", "search_context keeps conversation_id"); + } +}); + +type ManifestBody = { toolNames: string[]; tools: Record }; + +function readManifest(config: Config): ManifestBody { + let body = ""; + const res = { writeHead: () => {}, end: (b: string) => { body = b; } } as never; + handlePluginManifest(res, config); + return JSON.parse(body) as ManifestBody; +} + +test("#1712: manifest (CCR off by default) never advertises decompress range args on any wire", () => { + const m = readManifest(defaultConfig(200_000)); + for (const wire of ["anthropic", "openai", "responses"]) { + const props = propsOf(m.tools[wire] ?? [], DECOMPRESS_TOOL_NAME); + assert.ok(props, `${wire}: decompress present`); + assert.equal(props.startId, undefined, `${wire}: no startId when CCR off`); + assert.equal(props.endId, undefined, `${wire}: no endId when CCR off`); + assert.equal(props.blockId?.type, "string", `${wire}: blockId untouched`); + } +}); + +test("#1712: manifest with base CCR on advertises range args on anthropic/openai only — responses never arms CCR in plugin mode (#1271)", () => { + const m = readManifest({ ...defaultConfig(200_000), ccr: { enabled: true } }); + for (const wire of ["anthropic", "openai"]) { + const props = propsOf(m.tools[wire] ?? [], DECOMPRESS_TOOL_NAME); + assert.equal(props?.startId?.type, "string", `${wire}: startId advertised with base CCR on`); + assert.equal(props?.endId?.type, "string", `${wire}: endId advertised with base CCR on`); + } + const respProps = propsOf(m.tools.responses ?? [], DECOMPRESS_TOOL_NAME); + assert.equal(respProps?.startId, undefined, "responses wire must NOT advertise range args"); + assert.equal(respProps?.endId, undefined, "responses wire must NOT advertise range args"); +}); diff --git a/tests/golden/wire-contract/bili.json b/tests/golden/wire-contract/bili.json index 4e52b15acc..3d8954a9cf 100644 --- a/tests/golden/wire-contract/bili.json +++ b/tests/golden/wire-contract/bili.json @@ -139,11 +139,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -345,11 +345,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -558,11 +558,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -689,11 +689,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -756,11 +756,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -943,11 +943,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -977,11 +977,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -1011,11 +1011,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ @@ -1043,11 +1043,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." } }, "required": [ diff --git a/tests/golden/wire-contract/manifest-default.json b/tests/golden/wire-contract/manifest-default.json index ee10d57b58..3283f24585 100644 --- a/tests/golden/wire-contract/manifest-default.json +++ b/tests/golden/wire-contract/manifest-default.json @@ -152,14 +152,6 @@ "type": "boolean", "description": "Restore all the way to original messages" }, - "startId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." - }, - "endId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." - }, "conversation_id": { "type": "string", "description": "Your bili conversation id (the value from the 'your bili conversation id' line in the proxy notes). Pass it on every call when your host shares one MCP process across several concurrent conversations; omit it when the host bound the session itself." @@ -375,14 +367,6 @@ "type": "boolean", "description": "Restore all the way to original messages" }, - "startId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." - }, - "endId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." - }, "conversation_id": { "type": "string", "description": "Your bili conversation id (the value from the 'your bili conversation id' line in the proxy notes). Pass it on every call when your host shares one MCP process across several concurrent conversations; omit it when the host bound the session itself." @@ -605,14 +589,6 @@ "type": "boolean", "description": "Restore all the way to original messages" }, - "startId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." - }, - "endId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." - }, "conversation_id": { "type": "string", "description": "Your bili conversation id (the value from the 'your bili conversation id' line in the proxy notes). Pass it on every call when your host shares one MCP process across several concurrent conversations; omit it when the host bound the session itself." diff --git a/tests/golden/wire-contract/manifest-optin.json b/tests/golden/wire-contract/manifest-optin.json index be529f111d..425939c2cb 100644 --- a/tests/golden/wire-contract/manifest-optin.json +++ b/tests/golden/wire-contract/manifest-optin.json @@ -157,11 +157,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." }, "conversation_id": { "type": "string", @@ -450,11 +450,11 @@ }, "startId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." + "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled). Omit both to restore the whole block; empty values count as omitted." }, "endId": { "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." + "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId; omit both to restore the whole block." }, "conversation_id": { "type": "string", @@ -757,14 +757,6 @@ "type": "boolean", "description": "Restore all the way to original messages" }, - "startId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive lower bound of a sub-range of this block. With endId, restores only that span instead of the whole block (requires CCR: compress.ccr.enabled)." - }, - "endId": { - "type": "string", - "description": "Optional mNNNNN message ref, inclusive upper bound. Used together with startId." - }, "conversation_id": { "type": "string", "description": "Your bili conversation id (the value from the 'your bili conversation id' line in the proxy notes). Pass it on every call when your host shares one MCP process across several concurrent conversations; omit it when the host bound the session itself."