Alibabacloud Starops Chat
/install alibabacloud-starops-chat
Alibaba Cloud STAROps Agent
Call the Alibaba Cloud STAROps Agent through STAROps OpenAPI and receive a streaming diagnostic answer.
Scenario Description
Use this skill when the user wants to:
- Diagnose service errors or exceptions (root cause analysis)
- Query workspace topology, service lists, or service metrics
- Analyze APM traces, error rates, latency, or request volume
- Triage alerts or investigate incidents
- Ask questions about their STAROps workspace or services
Environment Variables
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.\x3Cregion>.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 |
Environment Setup
If the variables are not pre-configured by the platform, set them manually before running the script:
export STAROPS_AGENT_EMPLOYEE="\x3Cyour-digital-employee-name>"
export STAROPS_AGENT_WORKSPACE="\x3Cyour-workspace-name>"
export STAROPS_AGENT_UID="\x3Cyour-alibaba-cloud-account-uid>"
Credentials — The script uses the Alibaba Cloud Credentials SDK default chain. Configure one of the following (in priority order):
- STS token — Recommended for CI/sandbox. The platform injects STS credentials via
~/.aliyun/config.jsonor environment. - RAM role — For ECS/container workloads with instance metadata.
- CLI profile — Run
aliyun configureto create a profile in~/.aliyun/config.json. - Environment variables — Set
ALIBABA_CLOUD_ACCESS_KEY_IDandALIBABA_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.
Invocation
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 "\x3Ccomplete user context>" --pipe
# Follow-up calls - MUST reuse the thread ID from previous response
python3 scripts/call_starops_agent.py --thread "\x3Cthread_id>" --question "\x3Cfollow-up question>" --pipe
Thread Management:
- Extract thread ID from output
- Use the printed
STAROPS_URLwhen the user needs to inspect the same thread in the STAROps console - Always pass
--thread "\x3Cid>"for related follow-up questions to preserve context
Example 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
Behavioral Notes
- STAROps Agent calls are long-running by design. A single
CreateChatstream may start multiple internal diagnostic steps and take minutes; the default timeout is 30 minutes. - Provide complete context in one question: cloud account or workspace context, time range, service or application names, alert text, SLS project/logstore, UModel object, region, and what decision the user needs.
- CRITICAL: Always reuse
--threadfor follow-ups in the same investigation. Starting a new thread discards all prior context and findings. - Use this skill for Agent reasoning and diagnosis, not direct resource management. For direct ECS, OSS, RDS, SLS, or RAM mutations, use the corresponding official CLI, SDK, or specialized skill.
- MANDATORY: Always pass
--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--pipewill produce unstructured output that cannot be reliably evaluated. - If no SSE event arrives for a while, the script fails with a clear idle-timeout error instead of silently waiting for the full task timeout. Increase
--idle-timeoutonly when the investigation is expected to be quiet for long periods. - Output integrity rule: Your final report MUST be based on the actual content returned between
=== STAROPS ANSWER BEGIN ===and=== STAROPS ANSWER END ===. Specifically:- Quote or paraphrase concrete data points from the STAROps response (HTTP status codes, service names, error paths, metrics).
- Do NOT infer or fabricate diagnostic conclusions that are not supported by the STAROps output.
- If the STAROps answer is empty (
(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 中是否存在相关服务和时间范围内的数据。" - Never substitute your own prior knowledge for missing STAROps evidence. For example, do not claim "database connection pool exhaustion" if STAROps did not mention it.
Troubleshooting
When the script exits with an error, check the following in order:
- HTTP 401 Unauthorized — The credential chain did not resolve to a valid identity with STAROps permissions. Verify that the Alibaba Cloud Credentials default chain can resolve a valid credential (STS token, RAM role, CLI profile, or instance metadata) and that the identity has
cms:CreateThreadandcms:CreateChatpermissions. See references/ram-policies.md. - HTTP 404 Not Found — The digital employee name (
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. - ConfigError: Missing required STAROps environment variables — One or more of
STAROPS_AGENT_EMPLOYEE,STAROPS_AGENT_WORKSPACE,STAROPS_AGENT_UIDis empty or unset. - CredentialError — The Alibaba Cloud Credentials SDK could not find any valid credential source. Ensure at least one credential provider is configured (environment variables,
~/.aliyun/config.json, STS, RAM role, or instance metadata). - Idle timeout — No SSE event was received within
--idle-timeoutseconds (default 60). The STAROps Agent may be stalled. Retry with the same--threadif a THREAD line was printed, or increase--idle-timeoutfor investigations expected to be quiet. - Stream interruption / network error — The HTTPS connection was reset or timed out. Retry the same request with
--threadto resume context. - ModuleNotFoundError — Python dependency not installed. Run
pip3 install -r scripts/requirements.txtbefore invoking the script.
API Surface
This skill directly calls STAROps OpenAPI:
CreateThread:POST /digitalEmployee/{name}/threadCreateChat:POST /chat
See references/api-reference.md and references/ram-policies.md.
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install alibabacloud-starops-chat - After installation, invoke the skill by name or use
/alibabacloud-starops-chat - Provide required inputs per the skill's parameter spec and get structured output
What is Alibabacloud Starops Chat?
Alibaba Cloud STAROps Agent AIOps diagnostic skill. Use this skill to help users diagnose service errors, analyze root causes, query workspace/service topolo... It is an AI Agent Skill for Claude Code / OpenClaw, with 119 downloads so far.
How do I install Alibabacloud Starops Chat?
Run "/install alibabacloud-starops-chat" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Alibabacloud Starops Chat free?
Yes, Alibabacloud Starops Chat is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Alibabacloud Starops Chat support?
Alibabacloud Starops Chat is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Alibabacloud Starops Chat?
It is built and maintained by alibabacloud-skills-team (@sdk-team); the current version is v0.0.1.