All Products
Search
Document Center

AgentLoop:Integrate AgentScope (Java) applications

Last Updated:Aug 28, 2026

AgentLoop collects observability data for Java applications built on the AgentScope framework through the Java probe. Based on the OpenTelemetry standard, the Java probe automatically captures the call traces of your application and reports agent execution, model invocation, and tool invocation data to AgentLoop. This topic describes how to integrate an AgentScope Java application into AgentLoop so that you can monitor the runtime status of your AI application in real time.

Framework introduction

AgentScope is an open-source multi-agent application development framework from Alibaba. It provides multiple agent types such as ReActAgent, includes built-in model adapters such as DashScope, and supports tool calling, memory management, and multi-agent collaboration. AgentScope Java is the Java implementation of the framework and is suitable for building LLM applications in the JVM ecosystem.

After integration, the following data is monitored automatically:

  • Agent execution traces.

  • LLM invocations: token usage and the input and output content of model invocations.

  • Tool calling traces: the call details of each tool in the Toolkit.

  • ReAct steps: the action and observation of each loop iteration.

    AgentLoop reports this data as Trace and Metric data.

Integration methods

To integrate an AgentScope Java application into AgentLoop, first get the integration parameters in the AgentLoop console, and then install the Java probe based on your deployment environment.

Prerequisites and limits

  • JDK version — Run the AgentScope Java application on JDK 17 or later.

  • JVM memory — When you install the Java probe, make sure that the maximum heap memory of the target JVM is greater than 300 MB.

  • AgentLoop service — AgentLoop is enabled and an AgentSpace is created.

Get integration parameters

  1. Log on to the AgentLoop console. In the left-side navigation pane, click Integration Center.

  2. Click the AgentScope card.

  3. On the AgentScope integration page, select the Java language.

  4. Enter the application name. The page generates the parameters and installation instructions required to integrate the Java probe.

Install the Java probe

Choose one of the following installation methods based on your deployment environment:

  • Integrate with Container Service for Kubernetes (ACK) and Container Compute Service (ACS) — For applications deployed in ACK or ACS clusters. The ack-onepilot component automatically installs and maintains the Java probe in container environments.

  • Manual integration — For applications that run outside ACK or ACS clusters, such as applications started with the java -jar command, Tomcat, or Jetty. You download the Java probe and add it to the application startup process yourself.

    After you complete the integration and restart your application, you can verify that data is reported in the View monitoring details section.

Integrate with ACK and ACS

The application monitoring probe integration assistant (ack-onepilot) is a key component for integrating probes of various languages. It automatically prepares application monitoring probe packages in container environments and sets up the reporting environment for the probes. For more information about how ack-onepilot works, see Overview of the ack-onepilot component.

After the probe is integrated, a new probe version is automatically applied when your application restarts, so that ack-onepilot upgrades the probe to the latest version and keeps your experience consistent. If you do not want the mounted probe to be updated automatically as new probe versions are released, you can control the probe version yourself. For more information, see Manually control the probe version.

This method consists of three steps: install ack-onepilot, grant the access permissions that ARMS requires, and then enable application monitoring for your application.

Step 1: Install the probe integration assistant (ack-onepilot)

  1. Log on to the Container Service for Kubernetes console. On the Clusters page, click the name of the target cluster.

  2. In the left-side navigation pane, click Add-ons, and then search for ack-onepilot.

    Important

    The ack-onepilot version must be 5.1.0 or later.

  3. On the ack-onepilot card, click Install.

    Note
    • The ack-onepilot component supports up to 1,000 pods by default. For every additional 1,000 pods in the cluster, increase the CPU of the ack-onepilot resource by 0.5 cores and the memory by 512 MB.

    • To install ack-onepilot in an ACS cluster, configure accessKey and accessKeySecret (the AccessKey ID and AccessKey secret of your Alibaba Cloud account) at the bottom of the installation card. For more information, see Create an AccessKey pair. Make sure that the corresponding Alibaba Cloud account has the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions.

  4. On the page that appears, configure the parameters. Use the default values, and then click OK.

    Note

    After the installation is complete, you can upgrade, configure, or uninstall the ack-onepilot component on the Add-ons page.

Step 2: Grant access permissions to ARMS resources

The authorization procedure depends on the type of your cluster:

  • ACK managed clusters — Verify whether the cluster contains the ARMS Addon Token. If the token exists, no additional authorization is required. If the token does not exist, manually add access policies.

  • Dedicated clusters and registered clusters — Provide ack-onepilot with the AccessKey pair of an Alibaba Cloud account that has ARMS permissions.

  • ASK/ECI clusters — Complete authorization on the Cloud Resource Access Authorization page.

ACK managed clusters

If the ARMS Addon Token does not exist in your ACK managed cluster, perform the following operations to manually grant access permissions to ARMS resources. If the ARMS Addon Token already exists, skip to Step 3.

Check whether the ARMS Addon Token exists in the cluster.

  1. Log on to the Container Service for Kubernetes console. On the Clusters page, click the name of the target cluster to go to the cluster details page.

  2. In the left-side navigation pane, choose Configurations > Secrets. At the top of the page, select kube-system for Namespace and check whether addon.arms.token exists.

Note

If the ARMS Addon Token exists in the cluster, ARMS performs passwordless authorization. Kubernetes managed clusters have the ARMS Addon Token by default, but some clusters created in earlier versions may not have it. Therefore, for a Kubernetes managed cluster, first check whether the ARMS Addon Token exists. If it does not exist, perform manual authorization.

Manually add access policies.

  1. Log on to the Container Service for Kubernetes console. On the Clusters page, click the name of the target cluster.

  2. On the Basic Information tab of the Cluster Information page, in the Cluster Resources section, click the link next to Worker RAM Role.

  3. On the Permissions tab, click Grant Permission.

  4. In the Grant Permission panel, add the following two access policies and click Confirm Grant Permission.

    • AliyunTracingAnalysisFullAccess: full permissions for Managed Service for OpenTelemetry.

    • AliyunARMSFullAccess: full permissions for ARMS.

Dedicated clusters and registered clusters

To monitor applications in ACK dedicated clusters and ACK One registered clusters, make sure that the corresponding Alibaba Cloud account has the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions. For more information about how to grant permissions, see Grant permissions to a RAM user.

After you install the ack-onepilot component, you must also enter the AccessKey pair of an Alibaba Cloud account that has ARMS permissions in ack-onepilot. Use one of the following methods.

Method 1: Fill in the AccessKey pair in Helm

  1. Log on to the Container Service for Kubernetes console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Applications > Helm, and then click Update next to the ack-onepilot component.

  3. Replace accessKey and accessKeySecret with the AccessKey pair of the current account, and then click OK.

    Note

    For more information about how to get an AccessKey pair, see Create an AccessKey pair.

    In the controller section of the YAML editor, find accessKey: __ACCESSKEY__ and accessKeySecret: __ACCESSKEY_SECRET__, and replace the placeholders with the actual AccessKey pair.

  4. Restart the application Deployment.

Method 2: Reference a Kubernetes Secret

  1. Log on to the Container Service for Kubernetes console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Configurations > Secrets.

  3. Select the ack-onepilot namespace, create a Secret, and then add the AccessKey pair.

    Note

    For more information about how to get an AccessKey pair, see Create an AccessKey pair.

    Set the Secret name to ack-onepilot-aksk and select Opaque for the type. In the data section, add two entries: set the names to ak and sk, and set the values to the corresponding AccessKey ID and AccessKey secret. Then click OK.

  4. In the left-side navigation pane, choose Workloads > Deployments, and then click the ack-onepilot component. The component is typically in the ack-onepilot namespace and is named ack-onepilot-ack-onepilot.

  5. In the upper-right corner of the ack-onepilot-ack-onepilot page, click Edit. In the Environment Variables section, add ONE_PILOT_ACCESSKEY and ONE_PILOT_ACCESSKEY_SECRET and reference the values stored in the Secret, and then click OK.

    For the Secret, select ack-onepilot-aksk. For ONE_PILOT_ACCESSKEY, select ak as the key. For ONE_PILOT_ACCESSKEY_SECRET, select sk as the key.

ASK/ECI clusters

To monitor applications in ACK Serverless clusters or clusters connected to ECI, complete authorization on the Cloud Resource Access Authorization page, and then restart all pods under the ack-onepilot component.

Step 3: Enable application monitoring for a Java application

To enable application monitoring, add monitoring labels to the Deployment of your application in the YAML editor.

  1. Log on to the Container Service for Kubernetes console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Workloads > Deployments.

  3. On the Deployments page, find the target application and choose Edit YAML.

    To create a new application, click Create Resources from YAML.

  4. In the YAML file, add the following labels under the spec.template.metadata level.

    labels:
      armsPilotAutoEnable: "on"
      armsPilotCreateAppName: "deployment-name" # Replace deployment-name with the name of your application.
      armsPilotAppWorkspace: "workspace" # Replace with the current Workspace name.
      aliyun.com/app-language: java

    The following snippet shows the position of the labels in a Deployment:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: arms-springboot-demo
    spec:
      template:
        metadata:
          labels:
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-demo"
            armsPilotAppWorkspace: "workspace"
  5. Click Update.

Manual integration

Use manual integration to install the Java probe in environments other than ACK or ACS clusters, such as applications started with the java -jar command, Tomcat, or Jetty.

  1. After you select the Java language on the AgentScope integration page, find the manual integration section and download the Java probe by following the on-screen instructions. The page has already generated the integration parameters for the current AgentSpace.

  2. Extract the probe.

    Go to the directory of the probe package and run the following command to extract the package to a working directory of your choice.

    unzip AliyunJavaAgent.zip -d /{user.workspace}/
    Note

    {user.workspace} is a sample directory. Replace it with your actual directory.

  3. Configure the AppName and LicenseKey parameters.

    Use the LicenseKey that you got from the Integration Center of AgentLoop earlier. AppName is the name displayed for the application in AgentLoop and can be customized. In a distributed architecture, one application can contain multiple peer instances.

    Important

    Different AgentSpaces use different LicenseKeys. After you switch AgentSpaces, get the LicenseKey again.

    Provide AppName and LicenseKey by using one of the following methods:

    • Method 1 (recommended): Use -D startup parameters. Replace the {LicenseKey} and {AppName} placeholders in the startup command of Step 4 with the LicenseKey that you got from the console and the AppName of the application.

    • Method 2: Modify the probe configuration file. Use this method if you want to reuse the startup script across different applications. Perform the following steps:

      1. Check the Java probe version in the version file extracted in the previous step.

      2. Modify the probe configuration file based on the probe version:

        • For probe 4.0.0 or later, create an arms-agent.properties file in the probe directory and add the following configuration. Then add -Dotel.javaagent.configuration-file=/path/to/arms-agent.properties to the startup command or set the environment variable OTEL_JAVAAGENT_CONFIGURATION_FILE=/path/to/arms-agent.properties to enable the configuration file.

          arms.licenseKey={LicenseKey}
          arms.appName={AppName}
        • For a probe earlier than 4.0.0, add the following configuration to the arms-agent.config file in the probe package.

          arms.licenseKey={LicenseKey}
          arms.appName={AppName}
    Note
    • For probe versions earlier than 4.4.0, this method connects to default workspace by default.

    • For more information about other configuration items in the probe configuration file, see Modify the Java probe configuration file and the default reporting region.

  4. Add the integration command to the startup command.

    Replace {user.workspace} with the actual extraction directory of the probe package, and replace demoApp.jar with the actual path of the JAR package.

    Note
    • If the probe version is earlier than 2.7.3.5, replace AliyunJavaAgent/aliyun-java-agent.jar in this topic with ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar. We recommend that you upgrade the probe to the latest version as soon as possible.

    • On Windows operating systems, replace / in the script with \, and replace .sh files with .bat files.

    • Probe version 2.7.1.4 and later supports enabling Application Security when you integrate application monitoring. To enable Application Security, add -Darms.appsec.enable=true to the script. For more information about the billing rules of Application Security, see Billing rules.

    Add the -javaagent parameter based on your runtime environment:

    Runtime environment

    Steps

    Spring Boot or other Java applications started with the java -jar command

    Append the -javaagent parameter to the startup command. Make sure that the -javaagent parameter is placed before the -jar parameter. java -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace} -jar demoApp.jar

    Tomcat

    Add the following configuration to the {TOMCAT_HOME}/bin/setenv.sh file. JAVA_OPTS="$JAVA_OPTS -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace} " If your Tomcat version does not have the setenv.sh configuration file, open the {TOMCAT_HOME}/bin/catalina.sh file and add the preceding configuration after JAVA_OPTS. For a specific example, see line 256 of catalina.sh.

    Jetty

    Add the following configuration to the {JETTY_HOME}/start.ini configuration file. aliyun-java-agent.jar --exec -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace}

    To deploy multiple instances of the same application on one server, use the -Darms.agentId parameter (a logical number) to distinguish the JVM processes to be integrated. For example:

    java -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace} -Darms.agentId=001 -jar demoApp.jar
  5. Restart the Java application.

Sample code

The following sample uses AgentScope Java 2.0.1 to build a minimal runnable agent that contains one model invocation and one tool invocation. Before you run the sample, make sure that JDK 17 or later is installed and that DASHSCOPE_API_KEY is set as an environment variable.

Add the AgentScope Java 2.0.1 dependencies to the pom.xml of your Maven project:

  • Add agentscope-core to use basic features such as ReActAgent.

  • Add agentscope-extensions-model-dashscope to call models through DashScope.

  • Add agentscope-harness if Harness features are required.

<dependencies>
  <dependency>
    <groupId>io.agentscope</groupId>
    <artifactId>agentscope-core</artifactId>
    <version>2.0.1</version>
  </dependency>
  <dependency>
    <groupId>io.agentscope</groupId>
    <artifactId>agentscope-extensions-model-dashscope</artifactId>
    <version>2.0.1</version>
  </dependency>
  <!-- Add this dependency if Harness features are required -->
  <dependency>
    <groupId>io.agentscope</groupId>
    <artifactId>agentscope-harness</artifactId>
    <version>2.0.1</version>
  </dependency>
</dependencies>

Write a minimal agent with tool calling: the model adapter DashScopeChatModel is imported from io.agentscope.extensions.model.dashscope, messages are constructed with Msg, MsgRole, and TextBlock, and tools are registered with Toolkit.

import io.agentscope.core.agent.ReActAgent;
import io.agentscope.core.message.Msg;
import io.agentscope.core.message.MsgRole;
import io.agentscope.core.message.TextBlock;
import io.agentscope.core.tool.Tool;
import io.agentscope.core.tool.ToolParam;
import io.agentscope.core.tool.Toolkit;
import io.agentscope.extensions.model.dashscope.DashScopeChatModel;

public class QuickStart {
    public static void main(String[] args) {
        Toolkit toolkit = new Toolkit();
        toolkit.registerTool(new SimpleTools());

        DashScopeChatModel model = DashScopeChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("qwen-plus")
                .build();

        ReActAgent agent = ReActAgent.builder()
                .name("TravelAgent")
                .sysPrompt("You are a travel assistant. Use tools when needed.")
                .model(model)
                .toolkit(toolkit)
                .build();

        Msg msg = Msg.builder()
                .role(MsgRole.USER)
                .content(TextBlock.builder()
                        .text("What time is it in Hangzhou? Give me one travel tip.")
                        .build())
                .build();

        Msg response = agent.call(msg).block();
        System.out.println(response.getTextContent());
    }
}

class SimpleTools {
    @Tool(name = "get_time", description = "Get current local time")
    public String getTime(
            @ToolParam(name = "city", description = "City name") String city) {
        return city + ": " + java.time.LocalDateTime.now()
                .format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
}

To run this sample with monitoring enabled, package the sample as a JAR file and start it by using the integration command in Step 4 of the manual integration procedure. Replace demoApp.jar with the path of the sample JAR file. If you deploy the sample in an ACK or ACS cluster, add the monitoring labels described in Step 3 to the Deployment of the sample.

View monitoring details

  1. Log on to the AgentLoop console and select the target AgentSpace. In the left-side navigation pane, click AI Agent Observability.

  2. On the AI Application List page, find the integrated AgentScope Java application and click Application Name to go to the details page.

    On the application details page, you can view the call traces of the application:

  • Overview — Includes the Trace ID, start time, total duration, Total tokens, and so on.

  • Trace timeline — Shows the complete agent call chain by level and the duration of each span. The root span is of the AGENT type and corresponds to one agent execution. Its duration is the total duration of the call. The levels below are the STEP type (each iteration of the ReAct loop), the LLM type (model invocations, including the input and output token counts), and the TOOL type (tool calling, such as get_time in the sample).

  • Span type filtering — Filters spans by AGENT, STEP, LLM, or TOOL to quickly locate the target node.

  • Span details — Click a span and view the details in the details panel on the right. For example, an LLM span shows Input Messages (the system prompt and the user question) and Output Messages (the model response and tool call details).

References