Skip to content

fix: set AionRS chat completions path for non-v1 OpenAI-compatible providers#2514

Closed
taekchef wants to merge 3 commits into
iOfficeAI:mainfrom
taekchef:codex/fix-aionrs-non-v1-api-path
Closed

fix: set AionRS chat completions path for non-v1 OpenAI-compatible providers#2514
taekchef wants to merge 3 commits into
iOfficeAI:mainfrom
taekchef:codex/fix-aionrs-non-v1-api-path

Conversation

@taekchef

@taekchef taekchef commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Description

问题背景:
用户在 AionUI 中把 Zhipu 配置为 OpenAI-compatible provider,baseUrlhttps://open.bigmodel.cn/api/paas/v4。通过 AionRS 路线调用时,请求实际变成:

https://open.bigmodel.cn/api/paas/v4/v1/chat/completions

正确路径应该是:

https://open.bigmodel.cn/api/paas/v4/chat/completions

同类问题也会影响 AionUI 预置的其他非 /v1 OpenAI-compatible API root:

  • Zhipu:https://open.bigmodel.cn/api/paas/v4
  • Ark:https://ark.cn-beijing.volces.com/api/v3
  • Qianfan:https://qianfan.baidubce.com/v2

根因分析与修复:

  1. AionRS 默认路径追加:AionRS 的 OpenAI provider 默认会追加 /v1/chat/completions。这个行为对普通 /v1 provider 是正确的,但对已经在 baseUrl 中包含版本化 API root 的 provider 会拼出错误路径,例如 /api/paas/v4/v1/chat/completions
  2. AionUI 适配层缺少 compat override:已验证问题不在 Zhipu,也不在 OpenAI JS SDK。OpenAI JS SDK 使用同样的 Zhipu baseUrl 时会请求正确路径;问题出在 AionUI 启动 AionRS 时没有为这类非 /v1 API root 写入 api_path = "/chat/completions"
  3. 修复方案(本 PR):在 AionRS adapter 的 project config 生成逻辑中,识别 /api/paas/v4/api/v3/v2 这类非 /v1 API root,并写入:
[providers.openai.compat]
api_path = "/chat/completions"
  1. 兼容性保护:保留官方 OpenAI /v1 base URL 的现有默认行为,不全局取消 AionRS 的 /v1 默认追加;同时保留 Gemini 现有的 compat override 行为。
  2. 测试与 CI 补充:补充 unit tests 覆盖 Zhipu / Ark / Qianfan、trailing slash、非法 URL、普通 custom URL、Gemini 与 OpenAI 官方 /v1 场景。由于 Windows unit tests 原先多次在 10 分钟超时点被取消,本 PR 同时将 unit test job timeout 调整为 20 分钟,避免 Windows runner 偶发偏慢导致误报。

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • Tested on macOS
  • Tested on Windows
  • Tested on Linux
  • 本地 unit test 通过:./node_modules/.bin/vitest run tests/unit/process/agent/aionrs/envBuilder.test.ts
  • 本地 typecheck 通过:./node_modules/.bin/tsc --noEmit
  • 本地格式检查通过:./node_modules/.bin/oxfmt --check src/process/agent/aionrs/envBuilder.ts tests/unit/process/agent/aionrs/envBuilder.test.ts
  • git diff --check 通过
  • 最新 PR Checks 通过(head commit: 847f997b38120c1cf9c0ff2243d70c8383b62867
  • codecov/patch 显示所有本次修改且可覆盖的代码行都已被测试覆盖

Screenshots

Additional Context & Known Limitations

已知范围:

  • 本 PR 只修复 AionUI 启动 AionRS 时的 OpenAI-compatible path 适配问题。
  • 不修改 Zhipu / Ark / Qianfan 的 base URL。
  • 不全局改变 AionRS 对 OpenAI provider 的默认 /v1/chat/completions 行为。
  • 不处理鉴权、模型名、额度、限流等与路径拼接无关的问题。

后续如果新增更多非 /v1 OpenAI-compatible provider:

  • 可以继续在 adapter 中补充对应 API root。
  • 如果这类 provider 数量继续增加,可以考虑把非 /v1 API root 规则沉到 provider preset metadata 中,而不是继续扩展硬编码列表。

感谢维护团队!🎉

@taekchef
taekchef marked this pull request as ready for review April 17, 2026 09:30
@sentry

sentry Bot commented Apr 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@piorpua

piorpua commented May 25, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution.

This PR was opened before the project was split into separate frontend and backend repositories. The project structure has changed significantly since then:

Because the code structure, module boundaries, and backend implementation have changed substantially, this PR is no longer easy to review or merge based on the original diff.

If the issue addressed by this PR is still relevant in the new architecture, please open a new issue in the appropriate repository so we can re-evaluate it against the current codebase:

  • Frontend-related issues: AionUi
  • Backend-related issues: AionCore

If this PR is no longer applicable, feel free to close it.

Thanks again for your contribution and understanding.

@taekchef

Copy link
Copy Markdown
Contributor Author

I re-checked this after the AionUi / AionCore split.

The original issue is still relevant, but this old diff now targets stale AionUi-side AionRS adapter code. In the current architecture, the runtime URL and compat resolution for AionRS lives in AionCore. AionUi keeps the provider presets and bundles a released AionCore version.

I moved the current tracking and replacement fix to AionCore:

Closing this PR so the stale AionUi diff does not stay in review. After the AionCore fix is released, the AionUi follow-up should just be a bundled aioncoreVersion bump.

@taekchef taekchef closed this May 26, 2026
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.

2 participants