Skip to content

fix: resolve search_context conversation_id "current" to current session - #1127

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-22_search-context-current-alias
Sep 22, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-22_search-context-current-alias

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What changed

executeSearchContextTarget (src/decompress-shared.ts) only treated an empty id or an id exactly equal to the current session id as "the current session"; any other value went straight to the cross-session foreign lookup (resolveForeignSessionState). So when a model followed the parameter description verbatim and sent conversation_id: "current" — the description at src/compress-tool.ts:84 promises "Defaults to the current conversation" — the call failed with [search_context FAILED: unknown session "current"].

The fix makes the literal "current" (any case) resolve to the current session, honoring the documented default:

if (!requested || requested === sessionId || requested.toLowerCase() === "current")
    return executeSearchContext(args, core, state);

Why it's safe

Real session ids are generated (pfa-* store keys / mNNNNN-style refs), so shadowing a hypothetical session literally named current is negligible. Cross-session search (#841) for real ids is unchanged — the new branch only fires for the exact word "current".

Tests

Added a self-contained regression case in tests/search-context-cross-session.test.ts:

  • conversation_id: "current" / "Current" / "cUrReNt" all equal direct current-session execution (before the fix each returned unknown session "current");
  • no foreign-scope framing and no FAILED on the alias.

Pre-flight (rebased onto current master)

  • npm run typecheck — green
  • npm test — 2199 pass / 0 fail (2 skipped = ACP_TEST_E2E-gated e2e)
  • npm run build — success

Standalone minimal PR split out of #1121 per the owner's split directive there.

Fixes #1125

The search_context conversation_id param description promises "Defaults to the
current conversation", but executeSearchContextTarget only special-cased an
empty id or one exactly equal to the session id — sending the literal "current"
fell through to the foreign lookup and failed as unknown session "current".
Resolve "current" (any case) to the current session so the documented default
actually works. Real session ids are generated (pfa-* / mNNNNN-style), so
shadowing a hypothetical session literally named "current" is negligible;
cross-session search for real ids is unchanged.

Fixes #1125
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-22_search-context-current-alias (09317e5)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1127

Each push to this PR publishes a new version under the pr-1127 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1127.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR review — verified mergeable.

Diff hygiene: 2 files, +19/−1; every line relates to the fix. No unrelated changes, no whitespace churn, no lockfile/generated-file churn. Rebased onto current master (merge-base == master tip aeeed25), single linear commit.

Triage (reproduce → layering → approach):

  • Reproduced: checked out pre-fix src/decompress-shared.ts from master and ran the new regression test → fails with exactly [search_context FAILED: unknown session "current"], matching search_context rejects conversation_id "current" although the param description promises it #1125. With the fix: passes (8/8 in tests/search-context-cross-session.test.ts).
  • Layering: the producer is the routing decision in executeSearchContextTarget (src/decompress-shared.ts:184), which treated any non-empty id ≠ session id as a foreign session. The fix sits at that decision point — not a payload filter/mask — and honors the documented default ("Defaults to the current conversation", src/compress-tool.ts:84).
  • Coverage: executeSearchContextTarget is the single resolution point — all three wire paths (src/stream.ts:36, src/loop/core.ts:173, src/compress-loop-responses.ts:99) and the MCP/plugin transport (src/mcp.ts forwards to the same proxy-side executor) funnel through it, so both compression modes are covered. No other tool carries conversation_id.
  • Shadowing risk confirmed negligible: canonical ids are pfa-<16-hex> sha256-derived (src/session.ts:347); only a client literally sending x-acp-session: current could collide, and the blast radius is a search targeting the caller's own session instead of erroring.

Pre-flight (re-ran locally on head 09317e5, matches GitHub CI):

  • npm run typecheck — green
  • npm test — 2199 pass / 0 fail / 2 skipped (ACP_TEST_E2E-gated)
  • npm run build — success
  • CI check-runs on head: test matrix (ubuntu/windows × Node 22/24), version-guard, build-artifact, codex-vs-fake-upstream e2e preflight — all success. (mergeable_state: blocked is the human review gate, not CI.)
  • Full token-cost e2e could not be run from the review environment (local e2e upstream not available); given this is pure tool-argument resolution with no wire/message-shape change, the targeted regression + full suite + CI are adequate. Manual-dispatch ci-e2e remains available if you want the extra assurance.

No small fixes found to add — nothing to patch. Ready for human merge.

中文摘要:修复了 search_context 把字面量 conversation_id "current"(参数描述承诺的默认值)误当外部会话查询而报 unknown session 的问题——在唯一的路由决策点(decompress-shared.ts:184)让 "current"(任意大小写)回落到当前会话;已验证回归测试修复前必现、修复后通过,diff 干净、本地与 CI 全绿,可以合并。

@ranxianglei
ranxianglei merged commit 269fc54 into master Sep 22, 2026
8 checks passed
@ranxianglei ranxianglei mentioned this pull request Sep 22, 2026
@ranxianglei
ranxianglei deleted the 2026-09-22_search-context-current-alias branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search_context rejects conversation_id "current" although the param description promises it

1 participant