OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: 基于0.4.5版本,webstudio的会话(bot/chat接口)无法正常使用ov-server的tools

Open muuuuutou opened this issue 5 months ago • 5 comments

Bug Description

①bot调用tools时无法访问到Image ②基于问题①将配置为本地服务后,无法通过bot检索到添加到viking://resources下的资源

Steps to Reproduce

以下操作全程在web-studio进行验证: 使用rootkey开通account,admin账号后,添加资源

①将ov.conf,的server端服务地址配置为0.0.0.0,会导致bot调用tools时无法连接到server端。 ②临时规避问题①配置为本地服务127.0.0.1后可以访问了,但是resources无法检索到(使用原文内容也检索不到)

Expected Behavior

预期使用chat接口时可以正常访问到resources,

Actual Behavior

以下操作全程在web-studio进行验证: 使用rootkey开通account,admin账号后,添加资源

①将ov.conf,的server端服务地址配置为0.0.0.0,会导致bot调用tools时无法连接到server端。 ②临时规避问题①配置为本地服务127.0.0.1后可以访问了,但是resources无法检索到(使用原文内容也检索不到)

Minimal Reproducible Example


Error Logs


OpenViking Version

0.4.5

Python Version

3.11

Operating System

Other

Model Backend

None

Additional Context

No response

muuuuutou avatar Jun 26 '26 08:06 muuuuutou

现象①(ov.conf 中 host 配置为 0.0.0.0 时,bot 调用 tools 无法连接 ov-server)已在 PR #2868 修复,修复后无需再退回 127.0.0.1。

现象②(添加到 viking://resources/ 的资源在 bot/chat 中检索不到)是一个独立的问题,与①无关,因为资源入库/检索链路并不经过 server URL。根据代码排查,最可能的两个原因:

未配置 embedding(最可能):openviking_search 走的是语义检索(向量相似度),不是字面匹配。默认 ov.conf 中 embedding.dense.api_key 为空;如果没有配置可用的 embedding key,资源入库时不会生成向量,语义检索就检索不到任何结果,这正好对应"用原文内容也检索不到"的现象。 跨账号隔离:检索时会按 account_id 过滤(_tenant_filter,多租户隔离边界)。如果资源是在某个账号下添加、而 bot/chat 会话在另一个账号下检索,资源会被过滤掉。 为帮助定位,麻烦确认几点:

ov.conf 里的 embedding.dense.api_key 是否填写了有效的 key? 添加资源所用的账号,与 chat 会话所用的账号是否一致? 用关键字 / grep 能搜到内容、但语义检索搜不到吗?(若是,基本可确认是 embedding 未配置)

Symptom ① (bot can't connect to ov-server when host is 0.0.0.0) is fixed in PR #2868; the 127.0.0.1 workaround is no longer needed.

Symptom ② (resources added under viking://resources/ not retrievable from bot/chat) is a separate issue, unrelated to ①, since the ingestion/search path doesn't go through the server URL. From a code investigation, the two most likely causes:

Embedder not configured (most likely): openviking_search performs semantic retrieval (vector similarity), not literal text matching. The default ov.conf ships an empty embedding.dense.api_key; without a working key, resources are stored without vectors, so semantic search returns nothing, which matches "even the original text can't be retrieved." Cross-account isolation: search filters by account_id (_tenant_filter, the multi-tenant boundary). If resources were added under one account but the bot/chat session searches under a different account, they get filtered out. To help pin it down:

Is embedding.dense.api_key in your ov.conf set to a valid key? Is the account used to add resources the same one the chat session runs under? Can a keyword / grep find the content while semantic search can't? (If yes, it's almost certainly the missing embedder.)

khou avatar Jun 26 '26 17:06 khou

症状②单独对资源检索,再webstudio 不经过bot/chat时可以检索到;因此该现象会造成困扰,暂时未对源码debug排查具体检索路径(不过可以排除模型问题,与3.2.0版本配置信息保持一致,320版本时可以正常再studio下进行检索交互),cli方式无法通过日志直观查看到我的用户作用域是哪个account; 同时有个建议:考虑多租户情况下及将bot能力服务化部,可以通过请求chat时的header中account,user,API-KEY作为其用户的鉴权身份;避免每个用户需要为bot建立单个实例作为身份凭证

muuuuutou avatar Jun 27 '26 03:06 muuuuutou

感谢补充,这些信息帮助很大。

现象②我在本地复现并确认了根因:bot/chat 检索运行在与添加资源时不同的账号(account)下。viking://resources/ 是按账号隔离的(同一账号内不同用户共享,跨账号不可见),所以同账号检索一定能取到,不同账号会被租户隔离过滤掉。

几个已经(同样通过复现)排除的方向:不是 embedding 未配置(资源能正常入库并检索到),不是空检索范围漏掉了 resources(实际包含),也不是静默回退到 default 账号(api_key 模式下缺少转发的 key 会直接报错,而不是返回空)。

你这边最快的确认方式:分别用「添加资源的身份」和「chat 实际运行的身份」调用 GET /api/v1/system/status,对比返回的 account,不同就是它。

为帮助定位,几个问题: • 你的 auth_mode 是哪种(dev / api_key / trusted)?可从 GET /health 看到。 • 上面两个身份各自解析到的 account 是什么? • chat 检索是返回空,还是报错?(空=账号不一致;401/缺 key=身份没转发到 bot。) • 在 web-studio 里,添加资源和发起 chat 时是否是同一个账号?中途切换身份就会复现这个现象。

一个需要注意的点:api_key 模式下 root key 解析到的是 account default 且受路径限制,所以资源应通过常规账号添加,chat 也要运行在同一个账号下。

如果你想让 viking://resources/ 跨账号全局可见,那看起来更像是一个全局资源的功能需求。

Thanks for the extra detail, that helped a lot.

I reproduced symptom ② locally and confirmed the cause: bot/chat search is running under a different account than the one that added the resource. viking://resources/ is account-scoped (shared across users within an account, isolated across accounts), so a same-account search always retrieves it, and a different-account search gets filtered out by tenant isolation.

A few things I ruled out, also by reproduction: not a missing embedder (resources index and retrieve fine), not the empty search scope skipping resources (it includes them), and not a silent fallback to the default account (in api_key mode a missing forwarded key errors out instead of returning empty).

Fastest way to confirm on your side: call GET /api/v1/system/status once with the identity you add resources with, and once with the identity chat runs under, then compare the account field. Different means that's it.

To narrow it down, a few questions: • What's your auth_mode (dev / api_key / trusted)? Visible from GET /health. • What account does each of those two identities resolve to? • Does chat search come back empty, or with an error? (empty = account mismatch; 401 / missing key = identity not forwarded to the bot.) • In web-studio, was the same account active when you added the resource and when you chatted? Switching identity between the two reproduces this.

One thing to watch: in api_key mode the root key resolves to account default and is path-restricted, so resources should be added through a regular account, and chat needs to run under that same account.

If you want viking://resources/ to be visible across all accounts, that seems like a feature request for global resources.

khou avatar Jun 30 '26 18:06 khou

感谢解答;①authmode是api_key方式 ②大概率是身份问题,当前我已基于0.4.6修改优化,所以身份验证方式所以无法进行确认 ③只是搜索为空没有出现报错 ④是的使用同一账户,我怀疑问题是:webstudio进行agent交互时是使用的ovcli.conf中配置的bot身份信息,添加资源时使用是web-studio登录的身份信息导致资源不一致 您可以进行一下验证 目前我这边的优化方案: 统一使用header将身份信息添加,bot--server对身份信息进行透传,调用tools仍保留身份信息,保持一致性

muuuuutou avatar Jul 01 '26 03:07 muuuuutou

感谢提交这个 issue。我们按当前代码重新核对了一遍,这个场景现在已经覆盖。

原问题是:ov-server 绑定在 0.0.0.0 时,Web Studio 的 bot/chat 工具侧拿到的 server URL 不可直接访问,导致 tools 调用失败。

当前实现里,openviking/server/config.py 的 map_bind_host_to_loopback() 会把 0.0.0.0、空 host、* 映射到 127.0.0.1,IPv6 wildcard 映射到 [::1];get_server_url_from_server_data() 会使用这个映射。相关测试也覆盖了 wildcard host 到 loopback 的转换。

因此按当前代码看,这个问题已经修复。先关闭这个 issue;如果你在最新代码上仍能复现,请带上 server 配置和 Web Studio 请求日志,我们可以重新打开。

qin-ctx avatar Jul 01 '26 09:07 qin-ctx