📝 Overview
Calls Doubao's internet search capability through the Redfox API; after submitting a query, it automatically polls and waits for the result to return. Suitable for scenarios requiring real-time internet search and AI-assisted information retrieval.
✨ Features
| Function Module | Capability Description | Core Value |
|---|---|---|
| Asynchronous Submission | Submits search keywords to Doubao WebSearch and returns a taskId | No need to wait; immediately obtain the task identifier |
| Automatic Polling | Queries task status every 5 seconds, waiting up to 5 minutes | Automatically waits for the result, no manual querying required |
| Progress Feedback | Outputs the waiting status in real time via stderr during polling | Users can know the search progress |
| Result Output | Outputs the complete JSON after the status becomes completed | Structured data is convenient for Agent parsing and display |
| Exception Handling | Covers four scenarios: missing API Key, submission failure, timeout, and task failure | Each exception has a clear prompt and handling |
🔑 Authentication
Go to Redfoxhub to obtain an API Key, and configure it in the following way:
# 方式一:配置文件(如 OpenClaw 的 ~/.openclaw/openclaw.json)
{ "env": { "REDFOX_API_KEY": "ak_xxxx..." } }
# 方式二:终端环境变量
export REDFOX_API_KEY="ak_xxxx..."
🔄 Workflow
Step 1: Extract search keywords
Extract the search intent and keywords from the user's natural language description, and pass them in as inquiry_text .
Step 2: Call the search script
python3 ~/.agents/skills/doubao-websearch/scripts/doubao_search.py "<搜索关键词>"
The script automatically completes:
- Submit search:
POST /story/api/doubaoSearch/submit, passing in{"inquiry_text": "...", "source": "豆包websearch-GitHub"} - Poll for results: every 5 seconds,
POST /story/api/doubaoSearch/resultqueries once until the status iscompleted - Real-time feedback: during polling, outputs a waiting prompt via stderr
- Final output: after the status is
completed, outputs the complete JSON result to stdout
Step 3: Display results
After the script returns JSON, extract the Doubao answer text from data.content and the citation sources from data.result , then organize them structurally and present them to the user.
📦 Dependencies
pip3 install requests
⚠️ Error Handling
| Case | Handling Method |
|---|---|
Not configured REDFOX_API_KEY |
Prompt the user to go to Redfoxhub to obtain an API Key |
| Submission failed | Output an error message and recommend that the user retry |
| Polling timeout (5 minutes) | Prompt timeout and recommend retrying later |
| Task failed (status=failed) | Output failure details |