Install
openclaw skills install alibabacloud-starops-chatAlibaba Cloud STAROps Agent AIOps diagnostic skill. Use this skill to help users diagnose service errors, analyze root causes, query workspace/service topology, inspect APM metrics, and troubleshoot incidents through the STAROps Agent. Triggers: "排查根因", "根因分析", "服务报错", "服务异常", "APM 服务", "workspace 服务", "STAROps", "AIOps 诊断", "链路追踪", "告警分析".
openclaw skills install alibabacloud-starops-chatCall the Alibaba Cloud STAROps Agent through STAROps OpenAPI and receive a streaming diagnostic answer.
Use this skill when the user wants to:
The script reads the following environment variables. They are typically pre-configured by the execution platform — verify they are set before running; do not overwrite them with placeholder values.
| Variable | Required | Description | How to obtain |
|---|---|---|---|
STAROPS_AGENT_EMPLOYEE | Yes | Digital employee name in STAROps | STAROps console → Digital Employee list → name column |
STAROPS_AGENT_WORKSPACE | Yes | Workspace identifier | STAROps console → Workspace settings → workspace name |
STAROPS_AGENT_UID | Yes | Alibaba Cloud account UID that owns the workspace | Alibaba Cloud console → Account Management → Account ID |
STAROPS_AGENT_ENDPOINT | No | API endpoint (default: starops.<region>.aliyuncs.com) | Use default unless a private or custom endpoint is required |
STAROPS_AGENT_REGION | No | Region (default: cn-beijing) | STAROps is centrally deployed; use cn-beijing for all regions |
If the variables are not pre-configured by the platform, set them manually before running the script:
export STAROPS_AGENT_EMPLOYEE="<your-digital-employee-name>"
export STAROPS_AGENT_WORKSPACE="<your-workspace-name>"
export STAROPS_AGENT_UID="<your-alibaba-cloud-account-uid>"
Credentials — The script uses the Alibaba Cloud Credentials SDK default chain. Configure one of the following (in priority order):
~/.aliyun/config.json or environment.aliyun configure to create a profile in ~/.aliyun/config.json.ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET (least preferred; avoid in production).Do not define skill-specific AccessKey variables; the credential SDK handles resolution automatically.
Pre-flight check — run this before invoking the script to confirm the variables are set:
missing=""
[ -z "$STAROPS_AGENT_EMPLOYEE" ] && missing="$missing STAROPS_AGENT_EMPLOYEE"
[ -z "$STAROPS_AGENT_WORKSPACE" ] && missing="$missing STAROPS_AGENT_WORKSPACE"
[ -z "$STAROPS_AGENT_UID" ] && missing="$missing STAROPS_AGENT_UID"
if [ -n "$missing" ]; then echo "ERROR: Missing required environment variables:$missing" >&2; exit 1; fi
echo "OK: EMPLOYEE=$STAROPS_AGENT_EMPLOYEE WORKSPACE=$STAROPS_AGENT_WORKSPACE UID=$STAROPS_AGENT_UID"
If any required variable is empty, stop and ask the user to provide the value. Never substitute placeholder strings like example-employee.
The STAROps console link uses the same digital employee ID as assistantId.
IMPORTANT: The --pipe flag is MANDATORY for all invocations. It ensures structured output with THREAD ID, STAROPS_URL, and delimited answer blocks that downstream agents can reliably parse. Never omit --pipe.
Install dependencies and run from this skill's root directory:
pip3 install -r scripts/requirements.txt
# First call - creates a new thread automatically
python3 scripts/call_starops_agent.py --question "<complete user context>" --pipe
# Follow-up calls - MUST reuse the thread ID from previous response
python3 scripts/call_starops_agent.py --thread "<thread_id>" --question "<follow-up question>" --pipe
Thread Management:
STAROPS_URL when the user needs to inspect the same thread in the STAROps console--thread "<id>" for related follow-up questions to preserve contextExample workflow:
# Query 1: Creates new thread
$ python3 scripts/call_starops_agent.py --question "Query TOP 5 error applications" --pipe
THREAD: thread-abc123-xyz
STAROPS_URL: https://starops.console.aliyun.com/chat?threadId=thread-abc123-xyz&assistantId=apsara-ops
=== STAROPS ANSWER BEGIN ===
...
# Query 2: MUST reuse thread for context
$ python3 scripts/call_starops_agent.py --thread "thread-abc123-xyz" --question "Deep dive into notification app errors" --pipe
CreateChat stream may start multiple internal diagnostic steps and take minutes; the default timeout is 30 minutes.--thread for follow-ups in the same investigation. Starting a new thread discards all prior context and findings.--pipe. Tool-call status and streaming diagnosis-report chunks are written to stderr, while stdout keeps the reusable thread ID and final answer easy to parse. Omitting --pipe will produce unstructured output that cannot be reliably evaluated.--idle-timeout only when the investigation is expected to be quiet for long periods.=== STAROPS ANSWER BEGIN === and === STAROPS ANSWER END ===. Specifically:
(No assistant answer was returned.)), incomplete, or only contains generic text, retry once using the same --thread. If the retry still yields no actionable data, report honestly: "STAROps 未返回有效诊断数据,请确认 workspace 中是否存在相关服务和时间范围内的数据。"When the script exits with an error, check the following in order:
cms:CreateThread and cms:CreateChat permissions. See references/ram-policies.md.STAROPS_AGENT_EMPLOYEE) or workspace (STAROPS_AGENT_WORKSPACE) does not exist, or the UID (STAROPS_AGENT_UID) does not match the owning account. Double-check all three environment variables.STAROPS_AGENT_EMPLOYEE, STAROPS_AGENT_WORKSPACE, STAROPS_AGENT_UID is empty or unset.~/.aliyun/config.json, STS, RAM role, or instance metadata).--idle-timeout seconds (default 60). The STAROps Agent may be stalled. Retry with the same --thread if a THREAD line was printed, or increase --idle-timeout for investigations expected to be quiet.--thread to resume context.pip3 install -r scripts/requirements.txt before invoking the script.This skill directly calls STAROps OpenAPI:
CreateThread: POST /digitalEmployee/{name}/threadCreateChat: POST /chatSee references/api-reference.md and references/ram-policies.md.