Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/agent/dsh-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,15 @@ export function apply(ctx: PluginContext): void {
// RETRY_INTERVAL_MS until a proxy lands.
maybeRetry(ctx);

// #1158 L2: a refusal sends model traffic DIRECT. First refusal per
// endpoint logs once; same-state refusals accumulate silently and re-print
// #1158 L2: a refusal leaves the request uncompressed, but does NOT decide
// its egress — that is settled downstream in the intercept: direct-to-
// upstream for plain traffic on a raw URL, or stamped into the proxy's
// unattributed passthrough lane (every overlay-routed URL; a marker-
// sniffed compaction POST is diverted there too, where the #2709 guard
// runs the decisive check). The log must not claim "sent DIRECT" (#3499:
// the claim misread as upstream-direct cost a full diagnostic pass — the
// bytes can die inside the proxy instead). First refusal per endpoint
// logs once; same-state refusals accumulate silently and re-print
// only on an attribution STATE change (none↔threw), always carrying the
// cumulative count — bounded noise (#1117 silence preserved) while a
// "dozens refused, one passed" distribution becomes visible. The durable
Expand Down Expand Up @@ -1368,7 +1375,7 @@ export function apply(ctx: PluginContext): void {
? "initiator present but missing session id"
: "no active initiator attribution (agentless/background lane, third-party in-process caller, or stale attribution after host resume?)";
const suffix = prev !== undefined ? ` (state ${prev.state}→${attr.state})` : "";
const line = `bili-native-dsh: model request sent DIRECT (uncompressed) — takeover gate refused ${key}: ${reason} — refusals so far: ${count}${suffix}`;
const line = `bili-native-dsh: model request NOT taken over by bili (uncompressed) — takeover gate refused ${key}: ${reason} — egress: direct upstream or proxy passthrough lane (decided after the gate) — refusals so far: ${count}${suffix}`;
persistClientEvent(line);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/dsh-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ test("#1158 L2 gate three-state: thrown attribution is a distinct state; counts
assert.equal(refusedLines().length, 3);
// the durable copy carries the same lines into bili.log, [dsh-client]-marked
const content = fs.readFileSync(logFile, "utf8");
assert.match(content, /\[warn\] \[v=[^\]]+\] \[dsh-client\] bili-native-dsh: model request sent DIRECT \(uncompressed\) — takeover gate refused https:\/\/api\.gate-l2\.test\/v1\/chat\/completions: currentInitiator\(\) threw \(agent initiator scope is disposed\) — agent scope disposed\/closing mid-request\? — refusals so far: 5 \(state none→threw\)$/m);
assert.match(content, /\[warn\] \[v=[^\]]+\] \[dsh-client\] bili-native-dsh: model request NOT taken over by bili \(uncompressed\) — takeover gate refused https:\/\/api\.gate-l2\.test\/v1\/chat\/completions: currentInitiator\(\) threw \(agent initiator scope is disposed\) — agent scope disposed\/closing mid-request\? — egress: direct upstream or proxy passthrough lane \(decided after the gate\) — refusals so far: 5 \(state none→threw\)$/m);
assert.equal(errs.filter((e) => e.includes("takeover gate refused")).length, 0, "#2831: must not reach the terminal surface");
} finally {
console.error = origErr;
Expand Down
Loading