agentscope-ai / agentscope-ai/AgentTeams

fix: AI Provider proxyName 无法通过 Provider API 设置 || fix: AI Provider proxyName cannot be set via Provider API

Open
#193 1 comment 0 reactions 1 assignee Claimed by @qiacheng7 View on GitHub
area:model-higress
Dominant language
Go
Stars
5.6k
Forks
692
Avg merge
5d 4h
Merged PRs (30d)
23

Description

## 问题描述

通过 AI Provider API (`PUT /v1/ai/providers/{name}`) 设置 `proxyName` 字段时,该字段不会被持久化到对应的 ServiceSource 中,且查询时始终返回 `null`。

## 复现步骤

1. 创建一个 `dns` 类型的 service source `openai-compat`,指向 `openrouter.ai`
2. 创建/更新 AI Provider,类型为 `openai`,设置 `openaiCustomServiceName: "openai-compat.dns"` 和 `proxyName: "mihomo"`
3. 查询该 provider:`GET /v1/ai/providers/openai-compat`
4. 返回的 `proxyName` 始终为 `null`

## 根因分析

Bug 位于 higress-console 后端的 `OpenaiLlmProviderHandler.buildServiceSource()` 方法。当检测到自定义 upstream(`openaiCustomServiceName`)时返回 `null`,导致 `LlmProviderServiceImpl.addOrUpdate()` 跳过了 `proxyName` 的同步逻辑。

读取路径 `fillProxyInfo()` 同样有问题:`getServiceSourceName()` 生成的名称是 `llm-openai-compat.internal`,但实际 service source 名称是 `openai-compat`,名称不匹配导致查找失败。

## 临时解决方案

通过 Service Source API 直接设置 proxy:

```bash
curl -X PUT http://:18001/v1/service-sources/openai-compat \
-H 'Content-Type: application/json' \
-d '{"name":"openai-compat","type":"dns","domain":"openrouter.ai","port":443,"protocol":"https","proxyName":"mihomo"}'
```

## 修复 PR

已向 higress-console 提交修复:https://github.com/higress-group/higress-console/pull/670

---
## Problem description

When setting the `proxyName` field through the AI Provider API (`PUT /v1/ai/providers/{name}`), the field is not persisted to the corresponding ServiceSource and always returns `null` when queried.

## Reproduction steps

1. Create a service source `openai-compat` of type `dns`, pointing to `openrouter.ai`
2. Create/update AI Provider, type is `openai`, set `openaiCustomServiceName: "openai-compat.dns"` and `proxyName: "mihomo"`
3. Query the provider: `GET /v1/ai/providers/openai-compat`
4. The returned `proxyName` is always `null`

## Root cause analysis

The bug is located in the `OpenaiLlmProviderHandler.buildServiceSource()` method of the higress-console backend. Returns `null` when a custom upstream (`openaiCustomServiceName`) is detected, causing `LlmProviderServiceImpl.addOrUpdate()` to skip the synchronization logic of `proxyName`.

There is also a problem with reading the path `fillProxyInfo()`: the name generated by `getServiceSourceName()` is `llm-openai-compat.internal`, but the actual service source name is `openai-compat`, and the name mismatch causes the search to fail.

## Temporary solution

Set the proxy directly through the Service Source API:

```bash
curl -X PUT http://:18001/v1/service-sources/openai-compat \
-H 'Content-Type: application/json' \
-d '{"name":"openai-compat","type":"dns","domain":"openrouter.ai","port":443,"protocol":"https","proxyName":"mihomo"}'
```

## Fix PR

Fix submitted to higress-console: https://github.com/higress-group/higress-console/pull/670

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.