All Products
Search
Document Center

Cloud Monitor:Diagnose Python applications with the Live-Debug Agent Skill

Last Updated:Aug 07, 2026

Live-Debug Agent Skill enables you to perform runtime diagnostics on Python applications connected to Application Real-Time Monitoring Service (ARMS) without modifying business code, releasing a new version, or restarting the process. You describe your diagnostics intent in natural language, and the AI Agent automatically orchestrates agent creation, result query through Simple Log Service (SLS), and agent cleanup through the Cloud Monitor (CMS) ServiceTask API.

When the target method is called, you can collect dynamic logs, method snapshots, temporary metrics, and trace information.

Important

AI Agents are powered by large language models and may have risks such as target module or method identification bias or incorrect expressions. Before you create an agent, carefully verify the configuration and target resource that the Agent displays. Verify the impact of the agent on performance and stability in a test environment before you use it in a production environment. After you finish the diagnostics, delete the agent promptly to avoid residuals.

Scenarios

Diagnostics requirement

Recommended capability

Typical statement

Confirm whether a function is called and whether input parameters meet expectations

Dynamic log (LOG)

"Add a dynamic log at the exit of function X"

View parameters, return values, local variables, and call stack

Method snapshot (SNAPSHOT)

"Take a snapshot of function X, capture ..."

Automatically capture the scene when an exception is thrown

Method snapshot (exception)

"Capture a snapshot when function X throws an exception"

Temporarily observe business volume or latency distribution

Dynamic metric (METRIC)

"Add a ... metric to function X"

Temporarily add a span or tag an existing span with business attributes

SPAN/SPAN_TAG

"Add a span / Tag the current span with ..."

Supported diagnostics capabilities

Capability

Agent type

taskType

Description

Dynamic log

LOG

live_debug_log_probe

Outputs diagnostics logs based on a template. Does not capture object graphs or call stacks.

Method snapshot

SNAPSHOT

live_debug_snapshot_probe

Captures ARGS, RETURN, LOCALS, STACK, and other data.

Dynamic metric

METRIC

live_debug_metric_probe

Supports COUNTER, GAUGE, HISTOGRAM, and SUMMARY metric types.

Dynamic span

SPAN

live_debug_span_probe

Creates a function-level OTel span.

Span tagging

SPAN_TAG

live_debug_span_tag_probe

Appends attributes to the current active span.

Workflow

The following describes how the Skill orchestrates a diagnostics session:

  1. You describe the diagnostics requirement (which function to observe, what to capture, and optional filter conditions and duration).

  2. The Agent checks the command-line interface (CLI) environment and reads .arms-info (asks if the file is missing).

  3. The Agent generates an agent configuration, creates the task, and returns a taskId.

  4. You trigger the relevant service traffic.

  5. The Agent queries the installation status and collection results and interprets them.

  6. After you confirm that the diagnostics is complete, the Agent deletes the agent (or clears all agents).

Prerequisites

Condition

Description

Alibaba Cloud account

Has Live-Debug (CMS ServiceTask) and Simple Log Service query permissions on the target workspace and application.

Target application

A Python application has been connected to ARMS and Live-Debug is enabled.

Alibaba Cloud CLI

Installed and authenticated through aliyun configure. Must be able to call cms2 (CMS CLI plugin aliyuncms2) and sls. For installation instructions, see Step 1 below.

AI Agent

QoderWork, Cursor, Claude Code, or another tool that supports Agent Skills is installed. For Skill installation instructions, see Step 2 below.

Application connection information

workspace, serviceId, regionId, and slsProject are prepared (see Step 3).

Step 1: Install and configure Alibaba Cloud CLI

Live-Debug Skill calls CMS (aliyun cms2 apm service-task to create, list, and delete tasks) and Simple Log Service (to query collection results) through the aliyun CLI. Complete CLI installation and credential configuration first.

Install the CLI

If the CLI is not installed, see Install Alibaba Cloud CLI and select the installation method for your operating system (Linux, macOS, or Windows).

After installation, verify that the CLI is available:

aliyun version

Configure access credentials

aliyun configure

Enter the AccessKey ID, AccessKey secret, and default region as prompted. Use a RAM user and grant CMS ServiceTask and read/write/query permissions on the target Simple Log Service project. For more information, see Configure and manage identity credentials.

Note

When Live-Debug queries results, it explicitly specifies regionId (from .arms-info). Do not rely on the default region in aliyun configure as the only source. If the default region does not match the Simple Log Service project, a ProjectNotExist error may occur.

Install CMS CLI (aliyuncms2) and verify availability

CMS ServiceTask capabilities are provided by the aliyuncms2 plugin binary. Obtain aliyuncms2 and place it in the ~/.aliyun/ directory (or PATH). You can then call it through aliyun cms2, and credentials are reused from the aliyun configure configuration.

# Verify CMS ServiceTask capabilities
aliyun cms2 apm service-task --help

# Verify SLS query availability
aliyun sls --help

If cms2 is not available, confirm that the aliyuncms2 binary is in ~/.aliyun/ (or PATH) and has execute permissions:

ls -l ~/.aliyun/aliyuncms2
chmod +x ~/.aliyun/aliyuncms2
aliyun cms2 apm service-task --help

If the issue persists, upgrade Alibaba Cloud CLI and try again:

aliyun upgrade -y

Step 2: Install Live-Debug agent skill

  1. Obtain the Live-Debug Agent Skill and install it into your AI Agent with one click through alibabacloud-livedebug.

  2. Follow the instructions of your AI tool to install the Skill in QoderWork, Cursor, Claude Code, or another environment.

  3. After installation, restart the AI assistant or confirm through a conversation that the Skill is loaded (for example, ask "Have you loaded the Live-Debug Skill?").

In the following sections, ${LIVE_DEBUG_SKILL_ROOT} represents the Skill installation root directory. Companion scripts are located at ${LIVE_DEBUG_SKILL_ROOT}/scripts/.

Step 3: Prepare application connection information

Create .arms-info (key=value format) in the root directory of the project to be diagnosed for the Agent to read automatically. You can also provide the same information directly in the conversation.

workspace=default-cms-xxxxxxxxxxxxxxxxxx-cn-hangzhou
serviceId=ggxw4lnjuz@f2fd3a6265a254a052afb
regionId=cn-hangzhou
targetIp=*
slsProject=proj-xtrace-xxxxxxxxxxxxxxxxxxxxxx-cn-hangzhou

Parameter

Required

Description

workspace

Yes

ARMS workspace ID.

serviceId

Yes

Application or service ID.

regionId

Yes

Access region, such as cn-hangzhou.

slsProject

Yes

Simple Log Service project that stores Live-Debug results.

targetIp

No

Target instance IP address. Default value: * (all instances).

Step 4: Use natural language to initiate diagnostics

We recommend that you open your project code with an AI Coding tool such as Qoder, switch to the branch corresponding to your online application, and then use natural language in the AI Coding tool to initiate diagnostics. When you describe the diagnostics requirement, include the following information (the Agent will ask if any is missing):

Information

Required

Example

Target location

Yes

OrderService.create_order in app.service.order, or line N of a specific file.

Observation timing

Recommended

Entry, exit, on exception, or a specific line (default is typically exit).

Content to observe

Yes

Input parameters, return value, latency, local variables, or call stack.

Filter condition

No

Only when amount > 10000.

Duration or count

No

30 minutes, or stop after 50 captures.

After the task is created, the Agent returns a taskId. Compare the reference configurations in Reference configurations to verify that the target module, method, location, template, or capture fields are correct, and then trigger service traffic.

Step 5: Trigger traffic, verify results, and clean up

  1. Verify the configuration: Confirm that the taskConfig sent by the Agent matches the reference configurations in terms of target location and collection content.

  2. Trigger service traffic: Send one or more requests to an interface that reaches the target code path.

  3. Query results: Tell the Agent:

    Query the collection results for the taskId from just now, and help me interpret whether the agent is installed and what was captured.
    • Task Status: Whether the agent was installed successfully, funnel metrics, and other status information.

    • Capture Results: The actual collected content such as logs and snapshots.

  4. Clean up (always perform this step):

    Delete the agent from just now.
    Clear all Live-Debug agents for the current service.
    Show me what Live-Debug agents are still attached to the current service.

Reference configurations

Use the following reference configurations to verify the taskConfig that the Agent generates. Each subsection corresponds to an agent type in the Supported diagnostics capabilities table.

Dynamic log (LOG)

Example statement:

Use the /alibabacloud-livedebug Skill to add a dynamic log at the exit of OrderService.create_order in app.service.order, print order_id, amount, return value, and latency. Keep it for 30 minutes.

Reference configuration:taskType = live_debug_log_probe

{
  "probeType": "LOG",
  "language": "python",
  "target": {
    "typeName": "app.service.order",
    "methodName": "OrderService.create_order",
    "location": "exit",
    "instanceIds": ["*"]
  },
  "action": {
    "type": "LOG",
    "template": "create_order id={order_id} amount={amount} ret={@return} cost={@duration}ms"
  },
  "ttl": "30m",
  "captureCount": 100
}

Line-level with condition:

Add a log at line 42 of app/service/order.py. Only output the order ID and amount when amount >= 1000.

Reference configuration:taskType = live_debug_log_probe

{
  "probeType": "LOG",
  "language": "python",
  "target": {
    "sourceFile": "app/service/order.py",
    "location": "line:42",
    "instanceIds": ["*"]
  },
  "trigger": {
    "condition": "amount >= 1000"
  },
  "action": {
    "type": "LOG",
    "template": "big order id={order_id} amount={amount}"
  },
  "ttl": "30m"
}

Method snapshot (SNAPSHOT)

Example statement:

Use the /alibabacloud-livedebug Skill to take a snapshot at the exit of OrderService.create_order. Capture input parameters, local variables, return value, and call stack. Capture up to 20 times.

Reference configuration:taskType = live_debug_snapshot_probe

{
  "probeType": "SNAPSHOT",
  "language": "python",
  "target": {
    "typeName": "app.service.order",
    "methodName": "OrderService.create_order",
    "location": "exit",
    "instanceIds": ["*"]
  },
  "action": {
    "type": "SNAPSHOT",
    "capture": ["ARGS", "LOCALS", "RETURN", "STACK"],
    "captureConfig": {
      "maxDepth": 3,
      "maxCollectionSize": 100,
      "maxStringLength": 1024
    }
  },
  "ttl": "30m",
  "captureCount": 20
}

Conditional filtering with custom fields:

Take a snapshot at the exit of create_order. Trigger only when the return value is empty or the amount is greater than 10000. Focus on order_id, amount * count, self.user_id, and the return value.

Reference configuration:taskType = live_debug_snapshot_probe

{
  "probeType": "SNAPSHOT",
  "language": "python",
  "target": {
    "typeName": "app.service.order",
    "methodName": "OrderService.create_order",
    "location": "exit",
    "instanceIds": ["*"]
  },
  "trigger": {
    "condition": "@return is None or amount > 10000"
  },
  "action": {
    "type": "SNAPSHOT",
    "capture": ["ARGS"],
    "captureExpressions": [
      "order_id",
      "amount * count",
      "self.user_id",
      "@return"
    ]
  },
  "ttl": "30m",
  "captureCount": 50
}

Exception capture:

Capture a snapshot when PaymentService.process_payment throws an exception. Include input parameters, exception information, and call stack. Keep it for 2 hours.

Reference configuration:taskType = live_debug_snapshot_probe

{
  "probeType": "SNAPSHOT",
  "language": "python",
  "target": {
    "typeName": "app.service.payment",
    "methodName": "PaymentService.process_payment",
    "location": "exception",
    "instanceIds": ["*"]
  },
  "action": {
    "type": "SNAPSHOT",
    "capture": ["ARGS", "EXCEPTION", "STACK", "LOCALS"]
  },
  "ttl": "2h",
  "captureCount": 100
}

Dynamic metric (METRIC)

Example statement:

Use the /alibabacloud-livedebug Skill to add an amount histogram metric to create_order. Include a tag indicating whether the user is a VIP. Keep it for 1 hour.

Reference configuration:taskType = live_debug_metric_probe

{
  "probeType": "METRIC",
  "language": "python",
  "target": {
    "typeName": "app.service.order",
    "methodName": "OrderService.create_order",
    "location": "exit",
    "instanceIds": ["*"]
  },
  "action": {
    "type": "METRIC",
    "metricName": "livedebug.order.amount",
    "metricType": "HISTOGRAM",
    "valueExpression": "amount",
    "tags": {
      "is_vip": "str(user_id == 'vip')"
    }
  },
  "ttl": "1h"
}

Dynamic span (SPAN)

Example statement:

Use the /alibabacloud-livedebug Skill to temporarily add a span on OrderService.create_order named dyn.create_order. Include the order ID and amount as span attributes.

Reference configuration:taskType = live_debug_span_probe

{
  "probeType": "SPAN",
  "language": "python",
  "target": {
    "typeName": "app.service.order",
    "methodName": "OrderService.create_order",
    "location": "enter",
    "instanceIds": ["*"]
  },
  "action": {
    "type": "SPAN",
    "spanName": "dyn.create_order",
    "spanTags": {
      "order.id": "str(order_id)",
      "order.amount": "str(amount)"
    }
  },
  "ttl": "1h"
}

Span tagging (SPAN_TAG)

Example statement:

At the exit of create_order, use the /alibabacloud-livedebug Skill to tag the current span with order.id and order.result (use the return value). Do not create a new span.

Reference configuration:taskType = live_debug_span_tag_probe

{
  "probeType": "SPAN_TAG",
  "language": "python",
  "target": {
    "typeName": "app.service.order",
    "methodName": "OrderService.create_order",
    "location": "exit",
    "instanceIds": ["*"]
  },
  "action": {
    "type": "SPAN_TAG",
    "tags": [
      {"key": "order.id", "value": "str(order_id)"},
      {"key": "order.result", "value": "str(@return)"}
    ]
  },
  "ttl": "1h"
}

Step 5: Trigger traffic, validate results, and clean up

  1. Verify the configuration: Confirm that the taskConfig sent by the agent matches the reference configuration for the target location and the content to be captured.

  2. Trigger traffic: Send one or more requests to the API that executes the target code path.

  3. Query results: Query the agent to retrieve the following results:

    Show me the capture results for the last task ID, and tell me if the probe was installed and what was captured.
    • Task Status: This status indicates whether the probe was successfully installed and provides funnel metrics and other details.

    • Capture Results: This includes the captured content, such as logs and snapshots.

  4. Clean up (Required):

    Delete the previous probe.
    Delete all Live-Debug probes in the current service.
    Show me which Live-Debug probes are still active in the current service.

Scenario quick reference

Diagnostic need

In other words

Corresponding taskType

Quickly confirm a function call

"Add a dynamic log at the exit of function X and print..."

live_debug_log_probe

Inspect parameters, return values, or the stack

"Take a snapshot of function X and collect..."

live_debug_snapshot_probe

Capture context only on exceptions

"When function X throws an exception, capture a snapshot"

live_debug_snapshot_probe

View variables near a specific line

"In file X, at line N, add a log or take a snapshot"

live_debug_log_probe / live_debug_snapshot_probe

Temporary metric

"Attach a ... metric to function X"

live_debug_metric_probe

Ad-hoc backfilling and tagging

"Add a Span to function X or add a ... tag to the current Span"

live_debug_span_probe / live_debug_span_tag_probe

View results

"Query and interpret the results for taskId=..."

— (Query SLS)

Clean up

"Delete this agent" or "Delete all agents"

— (Delete)

FAQs

The agent reports that cms2 or aliyun command is unavailable

Cause: Alibaba Cloud CLI is not installed, the version is too old, or the aliyuncms2 plugin binary is not ready.

Solution:

aliyun version
aliyun upgrade -y
ls -l ~/.aliyun/aliyuncms2   # Confirm the CMS CLI plugin binary exists and is executable
aliyun cms2 apm service-task --help
aliyun sls --help

Make sure that you have run aliyun configure to configure the AccessKey pair.

Task created successfully but no capture results appear

Troubleshoot in the following order:

  1. Ask the Agent to check the Task Status first and confirm whether the agent was installed successfully.

  2. Verify that typeName and methodName match the runtime module name and __qualname__. Check whether the main module should be __main__.

  3. Confirm that you have triggered a request that reaches the target function. Check whether the filter condition is too strict.

  4. Confirm that regionId in .arms-info matches the region of slsProject.

  5. Increase the query time window and try again.

You can also tell the Agent: "No data was captured. Help me check whether the status and target location are correct."

SLS reports ProjectNotExist

Cause: The region used for the query does not match the region of the Simple Log Service project.

Solution: Enter the correct regionId in .arms-info and make sure that the Agent has exported LIVE_DEBUG_REGION_ID. Do not rely solely on the CLI default region.

How to confirm that agents are cleaned up

Show me what Live-Debug agents are still attached to the current service. If there are any, delete all of them.

Can Python applications perform thread, memory, or decompilation diagnostics?

No. These are Command capabilities that are supported only for Java/JVM applications. For Python applications, use log, snapshot, metric, or span diagnostics instead.

References