Commit Graph
8415 Commits
Author SHA1 Message Date
NewtonCookie 650fab97d2 fix: sample Claude usage on chat completions 2026-11-27 11:40:40 +08:00
Wesley Liddick dedeb65c1d Merge pull request #9107
feat(openai): 同步 Codex v0.172.0 内置基础提示词并补齐 5.6/6.0 模板
2026-11-27 10:32:46 +08:00
Wesley Liddick 212f5e5dcf Merge pull request #9105
fix(antigravity): honor group mcp_xml_inject in Claude transform options
2026-11-27 10:32:38 +08:00
Wesley Liddick 187d8e5bbf Merge pull request #9049
fix(gateway): report Anthropic thinking_tokens as reasoning_tokens
2026-11-27 10:32:30 +08:00
Wesley Liddick 8feae1b49c Merge pull request #9042
feat(usage): add toggleable username column to admin usage table and export
2026-11-27 10:32:22 +08:00
Wesley Liddick 3273ae9913 Merge pull request #9027
fix(frontend): theme the MCP consent dropdowns with the common Select
2026-11-27 10:32:14 +08:00
Wesley Liddick 07c52fe25b Merge pull request #9005
test(gateway): measure signed-history allocations in a child process
2026-11-27 10:32:06 +08:00
Wesley Liddick ca236afc8c Merge pull request #9001
fix(antigravity): skip SSE comment keepalives for js-genai < 1.32 (Gemini CLI)
2026-11-27 10:31:58 +08:00
Wesley Liddick 8ac5f4de71 Merge pull request #8987
fix(antigravity): honor final retry reset when cooling models
2026-11-27 10:31:50 +08:00
forgottener 6637b280aa fix(gateway): report Anthropic thinking_tokens as reasoning_tokens
Anthropic reports thinking tokens in usage.output_tokens_details.thinking_tokens,
a subset of output_tokens. AnthropicUsage had no such field, so Anthropic
accounts served through /v1/chat/completions and /v1/responses never exposed
reasoning_tokens.

Decode the field, carry it through the stream state and the buffered
ClaudeUsage merge (a reported value, even 0, replaces the previous one), and
emit it as Responses output_tokens_details.reasoning_tokens, which the existing
Responses-to-Chat mapping turns into completion_tokens_details.reasoning_tokens.
Billing is unchanged.

Fixes #9048
2026-11-27 01:26:37 +08:00
Kripto c5622ce6cf feat(openai): 同步 Codex v0.172.0 内置基础提示词并补齐 5.6/6.0 模板
- 新增 gpt-5.6、gpt-6-sol、gpt-6-luna 内置基础提示词并接入 CodexBaseInstructionsForModel。
- 将 gpt-5.1、gpt-5.2、gpt-5.5、gpt-6-astra 及 gpt-6.1/gpt-6.2 描述文件中的提示词模板同步至 openai/codex rust-v0.172.0,保留既有模型 catalog 元数据不变。
- 补齐 CodexBaseInstructionsForModel 单元测试覆盖。
2026-11-26 03:52:33 -04:00
SipengXie2024 b5e9549c54 fix(antigravity): honor group mcp_xml_inject in Claude transform options 2026-11-26 04:35:01 +00:00
Wesley Liddick 81ce8356d9 Merge pull request #9094 from pood1e/feat/declare-image-input-models
feat(codex): let accounts declare image-input models
2026-11-26 12:06:32 +08:00
shaw 06e7a2ed4b Merge branch 'main' into feat/declare-image-input-models
# Conflicts:
#	backend/internal/service/openai_codex_models_service.go
2026-11-26 11:50:34 +08:00
Wesley Liddick eef63ee7cd Merge pull request #9099 from PMExtra/feat/channel-expose-response-model
feat(channel): 渠道支持向用户显示实际响应模型
2026-11-26 11:49:58 +08:00
Wesley Liddick 76d8d976d5 Merge pull request #9095 from pood1e/fix/anthropic-bridge-deepseek-default-effort
fix(openai): default DeepSeek effort to high in the Anthropic bridge
2026-11-26 11:49:45 +08:00
Wesley Liddick 3db5753641 Merge pull request #9093 from pood1e/feat/openai-chat-reasoning-content
feat(openai): let API-key accounts opt into reasoning_content on raw Chat Completions
2026-11-26 11:49:32 +08:00
Wesley Liddick 164d7056ed Merge pull request #9088 from PMExtra/feat/proxy-ip-checked-at
feat(proxy): 代理列表显示出口 IP 与最后检测时间
2026-11-26 11:49:18 +08:00
Wesley Liddick 7b2a5f5d48 Merge pull request #9087 from wucm667/fix/issue-9086-tooltip-scroll
fix(frontend): keep help tooltips aligned after scrolling
2026-11-26 11:49:05 +08:00
Wesley Liddick 821701e45b Merge pull request #9085 from adamcjm/fix/opencode-user-agent-version
fix(opencode): 上游 User-Agent 版本更新至 1.19.6 并支持环境变量覆盖
2026-11-26 11:48:52 +08:00
Wesley Liddick ab00fef989 Merge pull request #9084 from r266-tech/codex/command-code-image-modalities
fix(codex): include Command Code image capabilities in model catalogs
2026-11-26 11:48:38 +08:00
Wesley Liddick bb7fb85cd5 Merge pull request #9081 from bin-bash-dev/fix/sse-keepalive-retry-accounting
fix(openai): account SSE keepalive bytes across failover attempts
2026-11-26 11:48:25 +08:00
Wesley Liddick e55f9db056 Merge pull request #9080 from bin-bash-dev/fix/content-moderation-lazy-queue
fix(moderation): allocate async moderation queue on demand
2026-11-26 11:48:11 +08:00
Wesley Liddick 3dd9a24957 Merge pull request #9079 from wucm667/fix/issue-9077-versionless-identity
fix(antigravity): handle versionless system identity openers
2026-11-26 11:47:57 +08:00
Wesley Liddick 2c5325ace8 Merge pull request #9076 from r266-tech/codex/optional-antigravity-stream-summaries
feat(antigravity): let upstream choose Gemini stream summaries
2026-11-26 11:47:43 +08:00
Wesley Liddick be8dfee8b2 Merge pull request #9069 from wucm667/feat/issue-9066-proxy-account-count
fix(accounts): show proxy account counts in account dialogs
2026-11-26 11:47:30 +08:00
Wesley Liddick f3ea22ec91 Merge pull request #9064 from PMExtra/feat/account-upstream-error-stats
feat(accounts): 在账号今日统计和用量趋势中展示上游错误次数
2026-11-26 11:47:17 +08:00
Wesley Liddick 8ace90b8d0 Merge pull request #9060 from LagrangeQ/fix/gemini-empty-stream-usage
fix(gemini): preserve stream usage after empty metadata
2026-11-26 11:47:04 +08:00
Wesley Liddick 62b3fa1aac Merge pull request #9046 from alfadb/fix/zhipu-overload-429-short-cooldown
fix(ratelimit): 智谱平台过载 429 改用秒级冷却
2026-11-26 11:46:51 +08:00
Wesley Liddick a55adce0aa Merge pull request #9034 from r266-tech/codex/shorten-proxy-network-cooldown
fix(openai): recover sooner after transport reachability failures
2026-11-26 11:46:38 +08:00
Wesley Liddick d081e563f7 Merge pull request #9012 from Anankke/fix/toolname-stream-restore
fix(gateway): restore tool names split across stream deltas
2026-11-26 11:46:23 +08:00
Wesley Liddick 6f34149c15 Merge pull request #9004 from Anankke/fix/sticky-session-rebind-cas
fix(gateway): do not overwrite a sticky rebind after a long forward
2026-11-26 11:46:10 +08:00
Wesley Liddick ddc855a51d Merge pull request #8995 from r266-tech/codex/show-requester-in-ops-error-detail
fix(ops): show requester in request error details
2026-11-26 11:45:58 +08:00
Wesley Liddick e3eb96c0b5 Merge pull request #8994 from wucm667/fix/issue-8991-terminal-context
fix(openai): normalize standalone terminal context
2026-11-26 11:45:44 +08:00
Wesley Liddick 4ecec232d8 Merge pull request #8860 from Anankke/fix/account-usage-auto-refresh
fix(accounts): refetch Gemini usage when the account's quota tier changes
2026-11-26 11:45:30 +08:00
张屹峰 fc2471c2d5 feat(usage): add toggleable username column to admin usage table and export 2026-11-26 11:32:56 +08:00
PMExtraandClaude Opus 5.5 8c4336eb58 fix(usage): chain Localized on user usage DTO mapping line
TestUserFacingGroupDTOsAreLocalized statically requires every user-facing
dto.*FromService call to chain .Localized( on the same line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 01:01:21 +08:00
PMExtraandClaude Opus 5.5 a1c7be6e90 feat(channel): optionally show actual response model to users
Add a channel-level toggle (features_config.expose_response_model, off by
default). When enabled, regular users see the final response model next to
the requested model in their usage records; the intermediate mapping chain
stays admin-only.

- Channel.IsResponseModelExposed + ChannelService.ResponseModelExposedChannels
  read from the in-memory channel cache, so no extra DB queries
- User usage list/detail fill the new optional response_model field
  (upstream_response_model -> upstream_model -> model, omitted when equal
  to the requested model)
- Channel form toggle, UsageTable rendering and i18n

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:45:37 +08:00
pood1eandClaude Opus 5.5 2945ecf89b fix(openai): default DeepSeek effort to high in the Anthropic bridge
Without a client effort, the Anthropic bridge sends `medium`. DeepSeek's
reasoning scale is low/high/max, as the Codex manifest already declares,
and DeepSeek-V4.1 rejects `medium`. Every Anthropic-format request without
an explicit effort therefore failed on DeepSeek models. The bridge now
sends DeepSeek's default level instead. Explicit efforts, disabled thinking
and other models are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:40:19 -08:00
pood1eandClaude Opus 5.5 5c95c63e15 feat(codex): let accounts declare image-input models
The Codex manifest advertises image input from synced upstream metadata
or a few known model names. Multimodal models served by vLLM or SGLang
match neither, so Codex blocks image attachments for them. The new account
extra key `image_input_models` lists upstream model IDs that accept image
input, and the manifest honors it ahead of synced metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 05:52:27 -08:00
pood1eandClaude Opus 5.5 21a95dbaa8 feat(openai): let API-key accounts opt into reasoning_content on raw Chat Completions
vLLM and SGLang stream reasoning in `reasoning`, while DeepSeek-style
clients read `reasoning_content`. The raw Chat Completions path already
mirrors these fields for Ollama Cloud accounts. The new account extra key
`openai_chat_reasoning_content` enables the same normalization for other
OpenAI API-key accounts. Ollama Cloud keeps it unconditionally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 05:51:41 -08:00
wucm667 afd87f38be fix(frontend): keep help tooltips aligned after scrolling 2026-11-25 14:55:16 +08:00
PMExtraandClaude Opus 5.5 1ba1ae8ef0 feat(proxy): show exit IP and last check time in proxy list
- Expose latency_checked_at (from cached UpdatedAt) on admin proxy list
- Show exit IP under location and last check time under created_at
- Include region/city in quality check result
- Quality check now updates row latency/IP/location on failure too,
  matching the backend snapshot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:27:06 +08:00
adam b3fdd01f0b fix(opencode): 上游 User-Agent 版本更新至 1.19.6 并支持环境变量覆盖
出站到 opencode.ai 的规范 User-Agent 一直硬编码为 opencode/1.0.0,已明显落后于
真实客户端(opencode-ai npm 包当前为 1.19.6)。上游按 opencode/<version> 格式
校验客户端身份,陈旧的版本号本身会成为可识别的特征。

- 默认版本号更新为 1.19.6,注释说明跟随 opencode-ai 最新发布
- 新增 OPENCODE_USER_AGENT_VERSION 环境变量覆盖,后续升级无需改代码
- 版本号按三段 semver 校验,非法或空值回退内置默认
- 补充 Normalize/Resolve 与 UA 格式的单元测试
2026-11-25 12:59:28 +08:00
r266-tech f90198a5ee fix(codex): include Command Code image capabilities in model catalogs 2026-11-25 12:50:23 +08:00
bin-bash-dev 1f5ca63440 fix(openai): account SSE keepalive bytes across failover attempts
Problem: on /v1/responses passthrough accounts with
gateway.stream_keepalive_interval enabled, a failover-eligible upstream
error (e.g. an overloaded `event: error` before any visible output) is
only failed over once. If the first attempt has already written a
keepalive comment, the next attempt that fails the same way is treated
as if semantic output had reached the client: the error is delivered as
response.failed and the remaining schedulable accounts are never tried.

Root cause: handleStreamingResponsePassthrough starts a new SSE
keepalive for every attempt, and startOpenAISSEKeepalive replaces the
instance stored on the gin.Context. Keepalive bytes were tracked per
instance, so OpenAICompactKeepaliveAdjustedWrittenSize subtracted only
the current instance's bytes from c.Writer.Size(); comments written by
an earlier attempt stayed in Size() and were counted as real output.
openAIStreamClientOutputStarted therefore reported output as started
and the passthrough stream stopped proposing failover.
StopOpenAICompactSSEKeepaliveCommitted had the same per-instance blind
spot and reported "not committed" when only an earlier instance had
committed the 200 response.

Fix: keep the keepalive byte count in a request-scoped atomic counter
stored on the gin.Context and shared by every keepalive instance of the
request (retries and nested starts). AdjustedWrittenSize subtracts the
cumulative count, and the committed check also reports true once any
keepalive of the request has written a comment. Single-keepalive
behaviour is unchanged.

Tests: a handler-level regression test drives the real Responses
handler with three passthrough accounts (the first attempt emits a real
keepalive and then fails over, the second fails immediately, the third
succeeds); on the previous code only accounts [1 2] are called and the
client receives response.failed. Service-level tests cover cumulative
accounting across restarts, the committed check after a previous
attempt, restarts without beats, and nested keepalives; they drive beats
manually instead of relying on timer scheduling.
2026-11-25 04:01:48 +08:00
bin-bash-dev fe72ddf1ae fix(moderation): allocate async moderation queue on demand
问题:NewContentModerationService 在构造时就执行
make(chan contentModerationTask, maxContentModerationQueueSize)。
maxContentModerationQueueSize=100000,单个任务 288 字节,因此每个实例一
构造就常驻约 28.8MB,与是否启用异步审核、是否有流量都无关。service 包测
试会创建数百个短生命周期实例,测试进程的提交内存随之涨到 GiB 级;生产上
任何额外构造的实例也要白白付出同样的代价。

根因:队列深度按允许的最大值预分配,而真正的丢弃判据
len(queue) >= cfg.QueueSize 只依赖运行期配置,并不需要预先占满容量。

修法:
- 构造函数不再创建队列,只标记 asyncQueueLazy;首次入队时按
  min(64, QueueSize) 创建,满且仍低于 QueueSize 时按 2 倍扩容(上限
  QueueSize),迁移已排队任务;运行期调大 QueueSize 也能继续扩容。
- 丢弃判据仍是 len >= QueueSize,丢弃计数与告警日志保持不变。
- 未经构造函数创建的零值服务入队仍是 no-op(不计数、不告警)。
- 队列创建/扩容时关闭并替换 asyncWake 广播唤醒 worker,阻塞在旧
  channel 上的 worker 会重新读取新队列,不空转、不漏取任务。
- GetStatus 与日志读取队列长度改为加锁读取,不会触发分配。

测试:
- content_moderation_queue_contract_test.go 只使用既有接口:构造后不预
  留队列;在独立子进程中测量 64 个空闲实例的堆增量(旧实现约
  28,803,490 字节/实例,修复后约 451 字节/实例,阈值 64KiB);
  QueueSize=8 时收 8 丢 12、记录路径同样受限、4096 全收且调大到 8192
  后继续接收;零值服务 no-op;真实 worker 并发消费 400 条记录不丢不重。
  结构与内存用例在修复前失败,其余语义用例修复前后均通过。
- content_moderation_queue_lazy_test.go 用 synctest 覆盖初始容量与扩容
  上限、多生产者/消费者恰好一次投递、扩容期间消费者持续读取、首次创建
  与替换队列时的唤醒、取消与空闲超时。
2026-11-25 03:56:32 +08:00
wucm667 2b836b7b7c fix(antigravity): handle versionless system identity openers 2026-11-25 02:44:44 +08:00
r266-tech 876f137d8f feat(antigravity): let upstream choose Gemini stream summaries 2026-11-25 01:15:18 +08:00
PMExtraandClaude Opus 5.5 8decae9779 feat(accounts): show upstream error counts in today stats and usage trend
Count provider-owned, non-business-limited rows in ops_error_logs per
account (same definition as the ops dashboard) and expose them as
`upstream_errors` on today stats and per-day account usage history.

- Today stats column shows today's upstream errors (highlighted when > 0).
- Usage statistics modal adds an upstream error trend line plus today and
  30-day totals; days with only errors are merged into the history.
- Counts are omitted when ops monitoring is disabled so the UI hides them
  instead of showing a misleading 0. Failover intermediate attempts are
  attributed only to the last failing account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:46:46 +08:00