bytedance / bytedance/agentkit-samples

[byted-web-search] 1.3.8 新用户首次调用即 NameError 崩溃:AGENT_PLAN_URL 未定义

Open Beginner friendly
#268 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
454
Forks
96
PR merge metrics
No merged PRs in 30d

Description

## 问题概述

`byted-web-search` **分发版本 1.3.8** 在「未找到凭证」与「Key 无效 (10403)」两条错误分支上会抛 `NameError`,
导致新用户首次调用看到的是 Python traceback,而非设计好的开通引导。

## 环境

- skill 版本:1.3.8
- 来源:`https://skills.volces.com/skills/bytedance/agentkit-samples/.well-known/skills/byted-web-search/`
- 安装:`npx skills add https://skills.volces.com/skills/bytedance/agentkit-samples -s byted-web-search`
- macOS / Python 3.13

## 复现(全新用户,未配置任何凭证)

```
$ python3 scripts/web_search.py "测试"
Traceback (most recent call last):
File ".../scripts/web_search.py", line 539, in
main()
File ".../scripts/web_search.py", line 485, in main
f"Agent Plan 用户:{AGENT_PLAN_URL}\n"
NameError: name 'AGENT_PLAN_URL' is not defined
```

## 根因

实际定义的常量是 `AGENT_PLAN_API_KEY_URL`(`scripts/web_search.py:63`),
但两处引用了不存在的 `AGENT_PLAN_URL`:

| 位置 | 上下文 |
|---|---|
| `scripts/web_search.py:281` | `_print_api_error_hint()` 的 10403 / `invalid_api_key` 分支 |
| `scripts/web_search.py:485` | `main()` 的「未找到凭证」分支 |

对 1.3.8 做 AST 扫描,未定义标识符为 `['AGENT_PLAN_URL']`。

## 影响

`SKILL.md` §3 的要求是「执行搜索前不要预检查环境变量,默认直接调用脚本;
仅当脚本返回『未找到凭证』时,再输出配置引导」。

该 NameError 恰好打断了这条唯一的引导链路——**每个新用户第一次调用都会命中**,
且上层 Agent 收到的是 traceback 而非可解析的错误信息。

## 建议修复

```diff
- f" · Agent Plan 用户 Key 来自 {AGENT_PLAN_URL}\n"
+ f" · Agent Plan 用户 Key 来自 {AGENT_PLAN_API_KEY_URL}\n"
```

```diff
- f"Agent Plan 用户:{AGENT_PLAN_URL}\n"
+ f"Agent Plan 用户:{AGENT_PLAN_API_KEY_URL}\n"
```

## 附:版本落差说明

`main` 当前为 **1.3.4**,**不含上述代码**(AST 扫描 `main` 无未定义标识符),
故无法以 PR 形式提交,只能以此 Issue 反馈。

`main` 上该 skill 最后一次提交为 2026-05-11,而分发件已是 1.3.8,
两者相差约 4 个月。若 `main` 并非发布源,建议关注发布流程的同步——
否则通过 PR 提交的修复可能无法进入用户实际安装到的分发件。

Generated with AI assistance

Contributor guide

Open the contributing guide

Research direction

Start with scripts/web_search.py around the constant at line 63 and the two references at lines 281 and 485, comparing the distributed 1.3.8 copy with the current main branch. Done means both credential-error paths use the defined URL constant and show the intended setup guidance instead of raising NameError; also verify which source feeds the published skill.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.