Repository navigation
fix(dsh): /acp and /acp-cache target the invoking session via the host-passed invocation (#1677) - #1684
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1631-pr.1684.b174321This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1684.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…t-passed invocation In plugin/native mode the DSH command executor hands the invoking agent to the handler through the invocation object but does NOT establish the AsyncLocalStorage boundary that currentInitiator() reads, so sessionIdOf() was always empty on the command path and both commands fell back to fetchStatusLatest - silently showing the most-recently-active session's panel instead of the current one. The handlers now read invocation.agent.session.id first (zero DSH-side change), keeping the ALS attribution and latest as fallbacks. When they fall back to latest because the requested session is unknown/unidentifiable, they prepend an explicit banner naming the shown session instead of presenting foreign data silently. Fixes #1677
7ad554a to
40278db
Compare
[bot] 🏷 Review 结论:可以合并(按 §7.4 留给人工合并——触碰 ① 原 issue(#1677,方向关)✅issue 排查扎实:四次跨会话调用 MD5 逐字节一致证明「静默显示别的会话」;根因追到 DSH 源码层(命令执行器不建立 ② 回归审查(既有行为清点)
③ 代码审查 ✅
④ 测试有效性 ✅三个新测试是真回归测试——我把 master 的 ⑤ diff 整洁度 ✅2 文件 +197/−13,单 commit,base 即当前 master tip(v0.1.172,c0e9e65f,0 behind),每一行都与本修复相关。 验证记录
中文摘要:修复了 dsh 插件模式下 |
Summary
In plugin/native mode (dsh profile bundle),
/acpand/acp-cacheshowed the proxy's most-recently-active session instead of the current one — silently. Root cause is plugin-side only: DSH's command executor hands the invoking agent to the handler through theinvocationobject but does not establish the AsyncLocalStorage boundary thatcurrentInitiator()reads, sosessionIdOf()was always empty on the command path and both commands fell back tofetchStatusLatest.What changed
src/agent/dsh-native.ts:CommandInvocationtype mirroring the DSH command-execution contract ({ commandId, agent, rawInput, attachments, signal }, all optional so older dsh degrades gracefully).commands.registerhandler signature now accepts(invocation?: CommandInvocation).statusOutcome/cacheOutcomeresolve the session asinvocationSidOf(invocation) ?? sessionIdOf(ctx)— invocation first, keeping ALS attribution and latest as fallbacks (backward-compatible with an older dsh that passes nothing).fetchStatusLatestbecause the requested session is unknown to the proxy, or no session could be identified at all, the output now prepends an explicit banner naming the shown session (latestSessionNote) instead of presenting foreign data silently.tests/dsh-native.test.ts: 3 regression tests (below).Behavior change (old → new)
/acp//acp-cacheinvocation.agent.session.id); falls back to ALS attribution, then latest⚠️ bili: session <id> is not known to the proxy — showing <shown> instead.(orcould not identify the current session — showing <shown> instead.when no session at all)Why: the first row is the bug fix (a different session's panel was being rendered); the second row implements the issue's "the fallback must not be silent" requirement. Neither affects the proxy wire or the
acp_status/acp_cachetools, which already readexec.agent?.session?.id.Scope & safety
GET /__bili/plugin/status?conversationId=Xreturns distinct panels; unknown id → 404;fallback=latest→ most-recently-active). Only the two plugin-side command handlers changed.panel=null,runtimeInfopresent) → hits the existing runtimeInfo branch with no banner (that is the intended armed/idle state).Tests
New regression coverage in
tests/dsh-native.test.ts:/acpresolves the invoking session from the invocation (asserts the specific panel; asserts nofallback=latestquery)./acp-cachebindsacp_cacheto the invoking session id (asserts the forwardedconversationId).Pre-flight on the rebased head (v0.1.172 base): typecheck clean · build OK · 3231 pass / 0 fail (12 skipped = E2E-gated).
Auto-merge
Not eligible per §7.4 — touches
src/agent/*(hot file) and changes/acpoutput shape (banner added in the fallback path). Stays human merge.Fixes #1677