Skip to content

fix(logs): report the resolved upstream model in egress audit rows - #859

Closed
homniloquy wants to merge 1 commit into
icebear0828:devfrom
homniloquy:fix/848-egress-model-suffix
Closed

homniloquy wants to merge 1 commit into
icebear0828:devfrom
homniloquy:fix/848-egress-model-suffix

Conversation

@homniloquy

Copy link
Copy Markdown
Contributor

Summary / 概述

The dashboard log window's "upstream model" column rendered ProxyRequest.model, which chat.ts fills with a display name: buildDisplayModelName() re-appends the -high / -fast suffixes parseModelName() had just stripped. A request for gpt-6-high was therefore logged as gpt-6-astra-high while the wire actually carried gpt-6-astra — the audit trail named a model that was never requested upstream.

日志窗口的「出口模型」列读取的是 ProxyRequest.model,而该字段是 chat.ts 用 buildDisplayModelName() 生成的展示名——它会把 parseModelName() 刚剥掉的 -high / -fast 后缀重新拼回。于是 gpt-6-high 被记成 gpt-6-astra-high,而实际请求上游的模型是 gpt-6-astra,日志因此显示了一个从未真正请求过的模型。

Changes / 改动

  • Add upstreamModelOf(), returning the resolved id the translation layer actually sent, and route every egress audit row through it — Codex account path, direct / fallback path, and the stream-close rows (client-abort, upstream-premature, client-write-failed). / 新增 upstreamModelOf(),返回翻译层实际写出的模型 ID,并让所有出口审计行改走它——账号路径、直连/fallback 路径,以及 stream-close 各行。
  • Split the two concerns streamResponse()'s model parameter conflated: model stays the client-facing echo, a new optional upstreamModel feeds the audit rows (defaults to model, so the Ollama bridge caller is unaffected). / 拆分 streamResponse() 的 model 参数原先兼管的两种语义:model 继续用于客户端回显,新增可选 upstreamModel 供审计行使用(缺省回落到 model,Ollama 桥调用方无需改动)。
  • No new suffix parsing is introduced — the resolver's output is reused, as the issue requested — so a model whose real id ends in an effort word is still reported verbatim. Ingress rows, the client-facing echo, and reasoning-effort / fast-tier / routing behavior are unchanged. / 未新增任何后缀解析(按 issue 要求复用既有解析逻辑),真实 id 以 effort 词结尾的模型仍原样上报;入口行、客户端回显、推理等级 / 快速模式 / 路由行为均未改动。
  • Regression coverage: new tests/unit/routes/shared/direct-egress-model.test.ts driving handleDirectRequest, plus resolver-driven cases in proxy-egress-log.test.ts; two pre-existing tests that asserted the old display-name behavior were corrected. / 回归覆盖:新增 direct-egress-model.test.ts,并在 proxy-egress-log.test.ts 补充驱动真实解析器的用例;两个固化旧行为的既有测试一并修正。
  • Recorded in CHANGELOG.md. / 已记入 CHANGELOG.md。

Test Plan / 验证

  • npx tsc --noEmit — passed / 通过
  • npm test — 325 files passed; 3423 tests passed, 1 skipped / 325 个文件通过、3423 项测试通过、1 项跳过
  • npm run build — passed / 通过
  • git diff --check — passed / 通过
  • Manual end-to-end against a local mock Responses-API upstream: gpt-6-high / gpt-6-fast / gpt-6-astra all log gpt-6-astra on the egress row (matching the wire) while the ingress row keeps the raw name. / 实机端到端:对本地 mock 上游发起请求,出口行均显示 gpt-6-astra(与线上一致),入口行保留原始名称。
  • Mutation check: reverting upstreamModelOf() to its old body turns the new cases red while the "no suffix" and "legitimate suffix" controls stay green. / 变异检查:改回旧实现后新增用例变红,两个对照用例仍为绿。
  • npm run test:real — not run; the change is confined to audit logging under src/routes/shared/ and does not touch the upstream protocol (translation/, proxy/, auth/). / 未运行:本次改动仅涉及审计日志,未触及上游协议层。

Linked Issues / 关联 issue

Closes #848


This PR targets dev for review and does not deploy or merge. / 本 PR 仅提交至 dev 供检查,未部署或合并。

The log window's upstream-model column read ProxyRequest.model, which
chat.ts fills with a *display* name: buildDisplayModelName() re-appends
the -high / -fast suffixes parseModelName() had just stripped. Requests
carrying a local suffix therefore advertised a model that was never
requested upstream - gpt-6-high showed as gpt-6-astra-high while the
wire saw gpt-6-astra.

Route every egress audit row through upstreamModelOf(), which returns
the resolved id the translation layer actually sent. No new suffix
handling is introduced, so a model whose real id ends in an effort word
is still reported verbatim. Ingress rows, the client-facing model echo,
and reasoning-effort / fast-tier / routing behavior are unchanged.

Refs icebear0828#848
@SsuJojo

SsuJojo commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Superseded by merged PR #864, which reapplied this change on the current dev baseline and passed CI.

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.

fix(logs): 出口模型日志应移除 -high / -fast 等本地处理后缀

2 participants