Skip to content

fix: report unrouted-endpoint direct sends for POST requests only (#1657) - #1661

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-29_quiet-unrouted-get
Sep 30, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-29_quiet-unrouted-get

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What & why

dsh web startup printed ~18 lines of request sent DIRECT (uncompressed) — …is not a recognized model endpoint… per boot, all from plugin-manager registry traffic (npm <pkg>/latest, .tgz, catalog.json on jsdelivr/raw.githubusercontent, registry.npmjs.org, api.github.com/releases/latest, git info/refs). None of these can be model endpoints; the noise buried the real failure lines (takeover gate refused …, proxy bootstrap failed …) and re-flooded on every restart because dedup is per-process.

The #1290 hook (onUnroutedModelUrl) fired for every non-model, non-control URL the fetch patch saw. Only POST can carry a prompt, so the gate now requires POST. This implements suggestion 1 from the issue (owner-ranked first: 改动最小、语义最准).

Behavior change (flagged)

  • Old: every non-model, non-bili-control URL fired onUnroutedModelUrl once per process per endpoint, regardless of HTTP method → dsh console.error + persistClientEvent + bili.log entry for npm/CDN/git GETs.
  • New: only POST requests fire it. GET/HEAD/OPTIONS/etc. to non-model endpoints are silent client-side.
  • Why: a GET cannot carry a prompt, so it cannot be model inference; dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290's own motivating case (commandcode's custom wire) was a POST.
  • Unchanged: routing decisions (non-model URLs still go direct for ALL methods), /__bili/stats unrecognizedPaths counting (server-side, all methods), acp_status UNRECOGNIZED PATHS section, takeoverGate refusal warnings, proxy-bootstrap warnings.

Changes

No config surface change, no wire/routing change, no version bump.

Pre-flight

  • npm run typecheck — clean
  • npm test — 3191 tests, 0 fail (16 skipped: e2e-gated suites)
  • npm run build — success
  • Branch is one commit on current master (e8a15c4d), no drift.

Fixes #1657

)

The #1290 onUnroutedModelUrl hook fired for every non-model, non-control
URL the fetch patch saw, so host tooling traffic (npm registries, catalog
JSONs, git refs) flooded dsh web startup with ~18 'request sent DIRECT
(uncompressed)' lines per boot and buried real failure lines. Only POST can
carry a prompt, so gate the hook on POST; routing decisions are unchanged
and the /__bili/stats unrecognizedPaths channel keeps counting everything.

Fixes #1657
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-29_quiet-unrouted-get (bc80640)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1607-pr.1661.8ea342b

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1661.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 complete — mergeable. Pulled branch 2026-09-29_quiet-unrouted-get (bc80640), cross-checked the code against current master, and verified CI. Findings by review layer:

① Original issue direction (#1657) — verified, not taken on faith. Independently confirmed the mechanism claim: src/agent/native-intercept.ts:609 (pre-fix) fired onUnroutedModelUrl for every non-model, non-control URL the fetch patch saw, method-blind; the sole consumer is src/agent/dsh-native.ts:605 (origin+pathname dedup, cap 256, console.error + persistClientEvent). All ~18 boot URLs in the repro are GET/HEAD (npm <pkg>/latest, .tgz, catalog JSONs, info/refs, releases/latest). Root cause is hook coverage being process-wide (the patch sees all outbound fetches), so fixing at the trigger point in native-intercept with zero dsh-side changes is the right layer — not a symptom patch. Suggestion 1 (owner-ranked first) is semantically sound: every known model-inference wire is POST (OpenAI chat/completions/responses, Anthropic messages, Gemini generateContent); GET variants are read-only retrieval and cannot carry a prompt. #1290's own motivating case is a POST — confirmed by the source comment at dsh-native.ts:599 ("such as commandcode's POST /alpha/generate").

② Regression inventory (existing behaviors on the touched path, item-by-item):

  1. Routing decisions (model URL→proxy rewrite; non-model→direct for ALL methods; self-guard; bili control plane direct) — unchanged. The diff adds a condition to the hook call only; return send(input, init) is byte-identical. Pinned by sink.length === 8 in the new test plus the pre-existing routing tests.
  2. Hook firing scope — old: any method, once per process per endpoint → new: POST only. Intended, fully disclosed (PR body + both docs + interface doc). Impact surface verified minimal: grep shows exactly one call site and exactly one consumer (dsh); the consumer is pure observability with nothing downstream depending on non-POST events; other native hosts never set the hook and stay silent as before.
  3. /__bili/stats unrecognizedPaths + acp_status UNRECOGNIZED PATHS — unaffected: independent server-side counters (src/server/observability.ts, surfaced at src/server.ts:6265 / src/acp-status.ts:164) counting requests that actually reach the proxy; not fed by this client hook.
  4. takeoverGate refusal warnings / proxy-bootstrap warnings — separate mechanisms, untouched by the diff.
  5. Config surface / wire shape / persistence / version — none touched, as claimed.

③ Code review — fetchMethodOf(input, init) is correct: init.method wins over Request-object method (matches fetch spec override semantics), then Request.method, then the GET default; uppercased so lowercase post counts; string inputs skip the object branch, URL inputs are excluded explicitly. No as any/@ts-ignore; interface doc now states the POST-only contract with #1657 provenance.

④ Test validity — harness is hermetic (withPatch swaps globalThis.fetch for an in-memory sink; zero network). The modified #1290 test now uses POST (matching its actual example) with intact teeth (unrouted.length === 2). The new regression test reproduces the issue's real boot URLs plus HEAD, lowercase-init post, and Request-object POST shapes, asserting exactly the two POSTs fire while all 8 still pass through direct — it catches both over-firing and under-firing, not a tautology.

⑤ Diff & merge state — 4 files, +67/−14, single commit, every line on-purpose, zh/en docs mirrored, no lockfile churn. Master advanced after the branch point (#1570/#1653/#1663 merged) with zero file overlap; git merge-tree against current master (a084876) is conflict-free. CI on head sha: 13/13 checks green, including full suites on ubuntu+windows × node 22+24, the codex e2e through the proxy, and the real dsh headless lane (the affected consumer). Fixes #1657 will close the original issue on merge.

No minor nits found worth committing. No behavior beyond the flagged hook-scope narrowing changed.

中文摘要:修复了 dsh web 启动时 npm 注册表/git/静态资源等 GET 请求刷屏 "request sent DIRECT" 告警的问题——把 #1290 的 onUnroutedModelUrl 钩子门控到仅 POST 触发(GET 不携带 prompt,不可能是模型流量),路由决策与服务端 unrecognizedPaths 统计均不受影响;已核对代码、回归面与全绿 CI(13/13,含真实 dsh 通道),diff 干净且对当前 master 无冲突,可以合并。

@ranxianglei
ranxianglei merged commit 309796c into master Sep 30, 2026
13 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-29_quiet-unrouted-get 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.

[dsh] 非模型端点(npm registry / git / 静态资源)也触发 "request sent DIRECT (uncompressed)" 告警 → 每次 dsh web 启动刷屏

1 participant