1. 15 Jan, 2026 5 commits
  2. 14 Jan, 2026 23 commits
    • IanShaw027's avatar
      2daf13c4
    • IanShaw027's avatar
      feat(ops): 添加用户信息显示和搜索功能 · 2a6fb1e4
      IanShaw027 authored
      - 在错误日志列表和详情中显示用户邮箱
      - 在 GetErrorLogByID 中关联 users 表获取用户邮箱
      - 在 OpsErrorLogFilter 中添加 UserQuery 字段
      - 在 buildOpsErrorLogsWhere 中添加用户邮箱搜索条件
      - 在 GetErrorLogs handler 中支持 user_query 参数
      2a6fb1e4
    • IanShaw027's avatar
      feat(ops): 添加上游响应体字段到错误事件 · 9e6cd36a
      IanShaw027 authored
      - 在 OpsUpstreamErrorEvent 中添加 UpstreamResponseBody 字段
      - 用于存储上游服务返回的响应内容
      - 区分客户端响应和上游响应
      9e6cd36a
    • IanShaw027's avatar
      fix(lint): 修复 golangci-lint 检查问题 · 841d7ef2
      IanShaw027 authored
      - 格式化代码(gofmt)
      - 修复空指针检查(staticcheck)
      - 删除未使用的函数(unused)
      841d7ef2
    • IanShaw027's avatar
      refactor(ops): 使用TTFT替代Duration作为健康分数指标 · a7a49be8
      IanShaw027 authored
      - 业务健康分数:错误率 50% + TTFT 50%
      - TTFT 阈值:1s → 100分,3s → 0分
      - TTFT 对 AI 服务的用户体验更有意义
      - 更新所有相关测试用例期望值
      a7a49be8
    • IanShaw027's avatar
      refactor(ops): 优化健康分数计算逻辑和阈值 · d5eab7da
      IanShaw027 authored
      - 移除 SLA 组件(与错误率重复)
      - 恢复延迟组件,阈值调整为 1s-2s
      - 错误率阈值调整为 1%-10%(更宽松)
      - 业务健康分数:错误率 50% + 延迟 50%
      - 更新所有相关测试用例期望值
      d5eab7da
    • IanShaw027's avatar
      test(ops): 修复健康分数测试用例期望值 · 9b102415
      IanShaw027 authored
      - 更新 TestComputeBusinessHealth 中 SLA 95% 边界测试的期望值
      - 更新 TestComputeDashboardHealthScore 中中等健康度测试的期望值
      - 适配移除延迟组件后的新健康分数计算逻辑
      9b102415
    • IanShaw027's avatar
      fix(ops): 优化错误日志查询和详情展示 · 9584af5c
      IanShaw027 authored
      - 新增 GetErrorLogByID 接口用于获取单个错误日志详情
      - 优化 GetErrorLogs 过滤逻辑,简化参数处理
      - 简化前端错误详情模态框代码,提升可维护性
      - 更新相关 API 接口和 i18n 翻译
      9584af5c
    • longgexx's avatar
      fix(admin): 修复使用记录页面趋势图筛选联动和日期选择问题 · 806f402b
      longgexx authored
         修复两个问题:
         1. Token使用趋势图和模型分布图未响应筛选条件
         2. 上午时段选择今天刷新后日期回退到前一天
      
         前端修改:
         - 更新 dashboard API 类型定义,添加 model、account_id、group_id、stream 参数支持
         - 修改 UsageView 趋势图加载逻辑,传递所有筛选参数到后端
         - 修复日期格式化函数,使用本地时区避免 UTC 转换导致的日期偏移
      
         后端修改:
         - Handler 层:接收并解析所有筛选参数(model、account_id、group_id、stream)
         - Service 层:传递完整的筛选参数到 Repository 层
         - Repository 层:SQL 查询动态添加所有过滤条件
         - 更新接口定义和所有调用点以保持一致性
      
         影响范围:
         - /admin/dashboard/trend 端点现支持完整筛选
         - /admin/dashboard/models 端点现支持完整筛选
         - 用户在后台使用记录页面选择任意筛选条件时,趋势图和模型分布图会实时响应
         - 日期选择器在任何时区下都能正确保持今天的选择
      806f402b
    • LLLLLLiulei's avatar
      feat: enhance proxy management · 9bdb45be
      LLLLLLiulei authored
      9bdb45be
    • IanShaw027's avatar
      fix(ops): 优化错误日志过滤和查询逻辑 · 55e469c7
      IanShaw027 authored
      后端改动:
      - 添加 resolved 参数默认值处理(向后兼容,默认显示未解决错误)
      - 新增 status_codes_other 查询参数支持
      - 移除 service 层的高级设置过滤逻辑,简化错误日志查询流程
      
      前端改动:
      - 完善错误日志相关组件的国际化支持
      - 优化 Ops 监控面板和设置对话框的用户体验
      55e469c7
    • 墨颜's avatar
      feat(计费): 支持账号计费倍率快照与统计展示 · fb99ceac
      墨颜 authored
      - 新增 accounts.rate_multiplier(默认 1.0,允许 0)
      - 使用 usage_logs.account_rate_multiplier 记录倍率快照,避免历史回算
      - 统计/导出/管理端展示账号口径费用(total_cost * account_rate_multiplier)
      fb99ceac
    • yangjianbo's avatar
      fix(认证): 修复 OAuth token 缓存失效与 401 处理 · daf10907
      yangjianbo authored
      新增 token 缓存失效接口并在刷新后清理
      401 限流支持自定义规则与可配置冷却时间
      补齐缓存失效与 401 处理测试
      测试: make test
      daf10907
    • ianshaw's avatar
      fix(网关): 修复账号选择中的调度器快照延迟问题 · 25b00abc
      ianshaw authored
      ## 问题描述
      调度器快照更新存在0.5-1秒的延迟(Outbox轮询间隔),导致在账号被限流或过载后的短时间窗口内,
      可能仍会被选中,造成请求失败。
      
      ## 根本原因
      账号选择逻辑依赖调度器快照(listSchedulableAccounts),但快照更新有延迟:
      - Outbox轮询: 每1秒检查一次变更事件
      - 全量重建: 每300秒重建一次
      - 时间窗口: 账号状态变更后0.5-1秒内,快照可能未更新
      
      ## 解决方案
      在账号选择循环中添加IsSchedulable()实时检查,作为第二道防线:
      1. 第一道防线: 调度器快照过滤(可能有延迟)
      2. 第二道防线: IsSchedulable()实时检查(本次修复)
      
      IsSchedulable()会检查:
      - RateLimitResetAt: 限流重置时间
      - OverloadUntil: 过载持续时间
      - TempUnschedulableUntil: 临时不可调度时间
      - Status: 账号状态
      - Schedulable: 可调度标志
      
      ## 修改范围
      ### OpenAI Gateway Service
      - SelectAccountForModelWithExclusions: 添加IsSchedulable()检查
      - SelectAccountWithLoadAwareness: 添加IsSchedulable()检查
      
      ### Gateway Service (Claude/Gemini/Antigravity)
      - 负载感知选择候选账号筛选: 添加IsSchedulable()检查
      - selectAccountForModelWithPlatform: 添加IsSchedulable()检查
      - selectAccountWithMixedScheduling: 添加IsSchedulable()检查
      
      ### 测试用例
      - OpenAI: 添加2个测试用例验证限流账号过滤
      - Gateway: 添加2个测试用例验证限流和过载账号过滤
      
      ### 其他修复
      - ops_repo_preagg.go: 修复platform为NULL时的聚合问题
      
      ## 测试结果
      所有单元测试通过 
      25b00abc
    • IanShaw027's avatar
      refactor(ops): 完善gateway服务ops集成 · 63711067
      IanShaw027 authored
      63711067
    • IanShaw027's avatar
      7f317b90
    • IanShaw027's avatar
      060699c3
    • IanShaw027's avatar
      refactor(ops): 重构ops核心服务层代码 · 967e2587
      IanShaw027 authored
      967e2587
    • IanShaw027's avatar
      refactor(ops): 移除duration相关告警指标,简化监控配置 · 18268381
      IanShaw027 authored
      主要改动:
      - 移除 p95_latency_ms 和 p99_latency_ms 告警指标类型
      - 移除配置中的 latency_p99_ms_max 阈值设置
      - 简化健康分数计算(移除latency权重,重新归一化SLA和错误率)
      - 移除duration相关的诊断规则和阈值检查
      - 统一术语:延迟 → 请求时长
      - 保留duration数据展示,但不再用于告警判断
      - 聚焦TTFT作为主要的响应速度告警指标
      
      影响范围:
      - Backend: handler, service, models, tests
      - Frontend: API types, i18n, components
      18268381
    • yangjianbo's avatar
    • IanShaw027's avatar
      fix(ops): 修复告警状态验证和错误处理逻辑 · 33f58d58
      IanShaw027 authored
      - 增强告警事件状态验证,添加合法状态值检查
      - 移除重试逻辑中的遗留字段赋值
      - 修正仓库不可用时的错误类型
      - 格式化测试文件代码
      33f58d58
    • yangjianbo's avatar
      fix(网关): OAuth 请求强制 store=false · 3663951d
      yangjianbo authored
      避免上游 Store 必须为 false 的错误
      
      仅在缺失或 true 时写回 store
      
      测试: go test ./internal/service -run TestApplyCodexOAuthTransform
      
      测试: make test-backend(golangci-lint 已单独执行)
      3663951d
    • IanShaw027's avatar
      feat(service): 增强ops业务逻辑和告警功能 · d6017680
      IanShaw027 authored
      - 实现告警静默功能的业务逻辑
      - 优化错误分类和重试机制
      - 扩展告警评估和通知功能
      - 完善错误解决和重试结果处理
      d6017680
  3. 13 Jan, 2026 4 commits
    • yangjianbo's avatar
      为类型断言补充 ok 校验并添加中文说明,避免 errcheck 报错(backend/internal/service/ · 7bbf49fd
      yangjianbo authored
          openai_codex_transform_test.go:36、backend/internal/service/
          openai_codex_transform_test.go:89、backend/internal/service/
          openai_codex_transform_test.go:104)。
      7bbf49fd
    • yangjianbo's avatar
      fix(网关): 修复工具续链校验与存储策略 · 70eaa450
      yangjianbo authored
      完善 function_call_output 续链校验与引用匹配
      续链场景强制 store=true,过滤 input 时避免副作用
      补充续链判断与过滤相关单元测试
      
      测试: go test ./...
      70eaa450
    • ianshaw's avatar
      fix(openai): 增强 OpenCode 兼容性和模型规范化 · 3d6e01a5
      ianshaw authored
      ## 主要改动
      
      1. **模型规范化扩展到所有账号**
         - 将 Codex 模型规范化(如 gpt-5-nano → gpt-5.1)应用到所有 OpenAI 账号类型
         - 不再仅限于 OAuth 非 CLI 请求
         - 解决 Codex CLI 使用 ChatGPT 账号时的模型兼容性问题
      
      2. **reasoning.effort 参数规范化**
         - 自动将 `minimal` 转换为 `none`
         - 解决 gpt-5.1 模型不支持 `minimal` 值的问题
      
      3. **Session/Conversation ID fallback 机制**
         - 从请求体多个字段提取 session_id/conversation_id
         - 优先级:prompt_cache_key → session_id → conversation_id → previous_response_id
         - 支持 Codex CLI 的会话保持
      
      4. **Tool Call ID fallback**
         - 当 call_id 为空时使用 id 字段作为 fallback
         - 确保 tool call 输出能正确匹配
         - 保留 item_reference 类型的 items
      
      5. **Header 优化**
         - 添加 conversation_id 到允许的 headers
         - 移除删除 session headers 的逻辑
      
      ## 相关 Issue
      - 参考 OpenCode issue #3118 关于 item_reference 的讨论
      3d6e01a5
    • IanShaw027's avatar
      fix(codex): 添加codex CLI instructions fallback机制 · f9713e87
      IanShaw027 authored
      ## 问题
      - 使用OpenAI API key时,opencode客户端可能因instructions不兼容而报错
      - 依赖外部GitHub获取instructions,网络故障时会失败
      
      ## 解决方案
      1. 将codex CLI标准instructions嵌入到项目中
      2. 实现自动fallback机制:
         - 优先使用opencode GitHub的instructions
         - 失败时自动fallback到本地codex CLI instructions
      3. 添加辅助函数用于错误检测和手动替换
      
      ## 改动
      - 新增: internal/service/prompts/codex_cli_instructions.md
        - 从codex项目复制的标准instructions
        - 使用go:embed嵌入到二进制文件
      
      - 修改: internal/service/openai_codex_transform.go
        - 添加embed支持
        - 增强getOpenCodeCodexHeader()的fallback逻辑
        - 新增GetCodexCLIInstructions()公开函数
        - 新增ReplaceWithCodexInstructions()用于手动替换
        - 新增IsInstructionError()用于错误检测
      
      ## 优势
      - 零停机:GitHub不可用时仍能正常工作
      - 离线可用:不依赖外部网络
      - 兼容性:使用标准codex CLI instructions
      - 部署简单:instructions嵌入到二进制文件
      f9713e87
  4. 12 Jan, 2026 8 commits
    • ianshaw's avatar
      d85288a6
    • ianshaw's avatar
      feat(gateway): 对所有请求(包括 Codex CLI)应用模型映射 · 3402acb6
      ianshaw authored
      - 移除 Codex CLI 的模型映射跳过逻辑
      - 添加详细的模型映射日志,包含账号名称和请求类型
      - 确保所有 OpenAI 请求都能正确应用账号配置的模型映射
      3402acb6
    • ianshaw's avatar
      fix(gateway): 修复 base_url 包含 /chat/completions 时路径拼接错误 · 7fdc25df
      ianshaw authored
      问题:
      - 当账号的 base_url 配置为 https://example.com/v1/chat/completions 时
      - 代码直接追加 /responses,导致路径变成 /v1/chat/completions/responses
      - 上游返回 404 错误
      
      修复:
      - 在追加 /responses 前,先移除 base_url 中的 /chat/completions 后缀
      - 确保最终路径为 https://example.com/v1/responses
      
      影响范围:
      - OpenAI API Key 账号的测试接口
      - OpenAI API Key 账号的实际网关请求
      
      Related-to: #231
      7fdc25df
    • ianshaw's avatar
      fix(gateway): 完善 max_output_tokens 参数处理逻辑 · fe6a3f42
      ianshaw authored
      根据不同平台和账号类型处理 max_output_tokens 参数:
      - OpenAI OAuth (Responses API): 保留 max_output_tokens(支持)
      - OpenAI API Key: 删除 max_output_tokens(不支持)
      - Anthropic (Claude): 转换 max_output_tokens 为 max_tokens
      - Gemini: 删除 max_output_tokens(由 Gemini 专用转换处理)
      - 其他平台: 删除(安全起见)
      
      同时处理 max_completion_tokens 参数,仅在 OpenAI OAuth 时保留。
      
      修复客户端(如 OpenCode)发送不支持参数导致上游返回 400 错误的问题。
      
      Related-to: #231
      fe6a3f42
    • xiluo's avatar
      feat(gateway): 优化 Antigravity/Gemini 思考块处理 · 524d80ae
      xiluo authored
      此提交解决了思考块 (thinking blocks) 在转发过程中的兼容性问题。
      
      主要变更:
      
      1. **思考块优化 (Thinking Blocks)**:
         - 在 AntigravityGatewayService 中增加了 sanitizeThinkingBlocks 处理,强制移除思考块中不支持的 cache_control 字段(避免 Anthropic/Vertex AI 报错)
         - 实现历史思考块展平 (Flattening):将非最后一条消息中的思考块转换为普通文本块,以绕过上游对历史思考块签名的严格校验
         - 增加 cleanCacheControlFromGeminiJSON 作为最后一道防线,确保转换后的 Gemini 请求中不残留非法的 cache_control
      
      2. **GatewayService 缓存控制优化**:
         - 更新缓存控制逻辑,跳过 thinking 块(thinking 块不支持 cache_control 字段)
         - 增加 removeCacheControlFromThinkingBlocks 函数强制清理
      
      关联 Issue: #225
      524d80ae
    • IanShaw027's avatar
      2d45e61a
    • IanShaw027's avatar
      feat(ops): 添加 count_tokens 错误过滤功能 · 345a965f
      IanShaw027 authored
      功能特性:
      - 自动识别并标记 count_tokens 请求的错误
      - 支持配置是否在统计中忽略 count_tokens 错误
      - 错误数据完整保留,仅在统计时动态过滤
      
      技术实现:
      - ops_error_logger.go: 自动标记 count_tokens 请求
      - ops_repo.go: INSERT 语句添加 is_count_tokens 字段
      - ops_repo_dashboard.go: buildErrorWhere 核心过滤函数
      - ops_repo_preagg.go: 预聚合统计中添加过滤
      - ops_repo_trends.go: 趋势统计查询添加过滤(2 处)
      - ops_settings_models.go: 添加 ignore_count_tokens_errors 配置
      - ops_settings.go: 配置验证和默认值设置
      - ops_port.go: 错误日志模型添加 IsCountTokens 字段
      
      业务价值:
      - count_tokens 是探测性请求,其错误不影响真实业务 SLA
      - 用户可根据需求灵活控制是否计入统计
      - 提升错误率、告警等运维指标的准确性
      
      影响范围:
      - Dashboard 概览统计
      - 错误趋势图表
      - 告警规则评估
      - 预聚合指标(hourly/daily)
      - 健康分数计算
      345a965f
    • IanShaw027's avatar
      fix(ops): 修复Go代码格式问题 · e0cccf6e
      IanShaw027 authored
      e0cccf6e