Prompts management

Updated at:

Managing Prompts across teams and environments requires version tracking, change comparison, and reliable deployment. Agent Assets provides centralized Prompt management with built-in version control and Label-based publishing, so you can iterate on Prompts and load them at runtime through the SDK without restarting your application.

Create a Prompt

Prerequisites

  • You have access to the AgentLoop console at arms.aliyun.com/agentloop.

  • You have access to an Agent Space within AgentLoop.

Procedure

  1. On the Agent Assets page, click the Prompts tab.

  2. In the upper-right corner, click New Prompt.

  3. Configure the basic information.

    ParameterRequiredDescription

    Name

    Yes

    A unique identifier for the Prompt. The name must be unique within the Agent Space. Names support letters, digits, underscores (_), and hyphens (-), up to 64 characters. If a duplicate name is detected, saving the Prompt fails with an error.

    Description

    No

    A brief summary of the Prompt purpose.

  4. Write the Prompt content in the editor.

    The editor provides the following features:

    • Variable insertion: Use the {{variableName}} syntax to define template variables. Click Add Variable to insert a variable at the cursor position.

    • Split-view editing: Switch between three view modes: edit-only, side-by-side edit and preview, and preview-only.

    • Variable highlighting: The preview pane highlights variables in the Prompt content so you can verify them at a glance.

  5. Enter a version number and a change description.

  6. After completing the Prompt, choose one of the following actions:

    • Save as Draft: Saves the current content as a draft. You can continue editing before publishing.

    • Publish Version: Opens a confirmation dialog. Confirm the version number and change description, then click Confirm. Published versions cannot be modified.

    Note

    Only published versions are loadable through the SDK. Drafts are not available for SDK access.

Version management

Each time you edit and save a Prompt, a new version is created. You can compare any two versions, track changes over time, and use Labels to organize versions by environment or purpose.

Compare versions

On the Prompt details page, click the Version Comparison tab. Select two versions to view a side-by-side diff.

Labels

Labels tag a specific version for a particular purpose, such as production or staging. You can manage Labels in the following ways:

  • In the version list, click the edit icon next to a version to add or remove Labels.

  • Assign Labels when you publish a version or save a draft.

  • Create a Label by typing a name and pressing Enter.

Note

Each Label can be applied to only one version at a time. Assigning a Label that is already in use on another version automatically transfers the Label to the current version.

Load a Prompt through the SDK

You can load published Prompts at runtime through the SDK. This enables hot reload without restarting your application. When you publish a new version or reassign a Label, the SDK automatically picks up the latest Prompt content.

Java SDK

Currently, AgentLoop provides a Java SDK. Support for additional languages may be added in future releases.

Prerequisites

Before you begin, make sure that the following requirement is met:

  • nacos-client version 3.2.1 or later

Usage

Step 1: Add the following Maven dependency to your pom.xml file:

<dependency>
    <groupId>com.alibaba.nacos</groupId>
    <artifactId>nacos-client</artifactId>
    <version>3.2.1</version>
</dependency>

Step 2: Initialize the SDK:

Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, "<agentloop-server-address>");
properties.put(PropertyKeyConst.NAMESPACE, "<your-namespace-id>");
ConfigService configService = NacosFactory.createConfigService(properties);

Step 3: Load a Prompt by Label. The group parameter corresponds to the Label name, and dataId is the Prompt Name:

// group corresponds to the Label name; dataId is the Prompt Name
String promptContent = configService.getConfig("<prompt-name>", "<label-name>", 5000);

Step 4 (Optional): Enable hot-reload via a listener. When you publish a new version or reassign a Label, the listener automatically receives the updated Prompt content:

configService.addListener("<prompt-name>", "<label-name>", new Listener() {
    @Override
    public Executor getExecutor() { return null; }
    @Override
    public void receiveConfigInfo(String configInfo) {
        // Update your application's Prompt reference
        updatePrompt(configInfo);
    }
});

Troubleshooting

getConfig() returns null

Verify that SERVER_ADDR points to the correct AgentLoop endpoint.

Connection timeout

Verify that NAMESPACE matches the Agent Space namespace ID shown in the AgentLoop console.

Authentication error

Confirm that your accessKey and secretKey have permission to access the AgentLoop namespace.