Use Agentic Context
In this tutorial, you set up Agentic Context on an Alibaba Cloud Elasticsearch instance and connect it to an agent. You complete four stages in order: initialize the engine, create a workspace and members, create a knowledge base and import documents, and connect an agent that retrieves knowledge. By the end, the agent answers questions from your imported documents and returns citations to the source.
Initialize Agentic Context
Before you use Agentic Context, initialize it on the target Alibaba Cloud Elasticsearch instance.
Prerequisites
An Engine-enhanced Edition instance is created. The instance version is 8.17 or 9.4, and the instance status is Active.
- Note
Other versions, such as 9.99, do not support Agentic Context. If you open the feature page on such an instance, the message "The current instance version does not support Agentic Context scenarios" appears.
You have the
elasticadministrator account and password of the instance. You must enter these credentials during initialization so that Agentic Context can access the cluster.If you forget the password, reset the password of the
elasticaccount on the Security Settings page of the instance.
Procedure
Log on to the Alibaba Cloud Elasticsearch console. In the left-side navigation pane, click Elasticsearch Clusters, and then click the target instance to go to the product page.
In the left-side navigation pane, choose AI Service Center > Agentic Context.
On the initialization guide page, read the Agentic Search Service Initialization Agreement and select the check box.
The top of the page shows the three initialization stages: Initialize Service > Enable Service > Connect and Use.
The page also states that initialization enables two services at the same time. For details about the two services, see Agentic Search and AI Search Open Platform. Fees generated by later model calls, such as indexing and retrieval, are billed to Billing for Agentic Search.
Click Initialize Now.
In the Configure Elasticsearch Cluster Access Credentials dialog box, configure the following settings, and then click Confirm and Initialize.
Parameter
Description
Account
The administrator account of the Elasticsearch cluster. By default, this field is set to
elastic.Password
The password of the administrator account. The password is encrypted and stored by Alibaba Cloud Key Management Service (KMS) and is never passed to the agent. You can change it later in Settings of Agentic Context.
Agentic Context must access the current Elasticsearch instance with the administrator account to create indexes and vector fields that store knowledge base chunks, write the metadata of smart memories and skills, and run runtime operations such as knowledge base retrieval and reranking.
After initialization is complete, the page goes to the Agentic Context feature page. The status at the top shows Initialized, and the Workspace list is displayed.
Create a workspace and members
A workspace is the basic unit that isolates knowledge bases, members, and access credentials by business. Each member has an independent API key in the workspace, and that key is used for all API calls of the workspace.
Create a workspace
On the Agentic Context feature page, click Create Workspace.
In the dialog box, configure the following settings, and then click OK.
Parameter
Description
Name
Required. The name must start with a letter and can contain letters, digits, and underscores. It can be up to 30 characters in length. Example:
sales_prod.Description
Optional. The description can be up to 128 characters in length.
After the workspace is created, it appears in the list with the status Running, together with four counters for knowledge bases, skills, smart memories, and members.
Workspace details page
Click the workspace name to go to its details page. The workspace details page contains the following tabs:
Overview: shows the workspace details, the four counters, the knowledge base overview, and the entry for connecting an agent.
Knowledge Base: manages the knowledge bases in the workspace.
Smart Memory: manages the long-term memory of agents.
Skills: manages reusable prompts and tool specifications.
Members & API Key: manages members and their API keys.
Create a member and get the API key
Go to the workspace details page and click the Members & API Key tab.
Click Add Member.
In the dialog box, configure the following settings, and then click OK.
Parameter
Description
Member Name
Required. The name must start with a letter or a digit and can contain letters, digits, underscores, and hyphens. It can be up to 64 characters in length. Example:
lisi.Status
The default value is Active.
After the member is created, the system generates an API key for the member and displays it in a dialog box. Copy the key immediately and store it in a secure location.
- Warning
The API key is the only credential that a member uses to access the resources of the workspace. Do not share it with others.
If you did not copy the key from the dialog box, you can copy it later from the API Key column of the member list.
The member list shows information such as the member name, member ID, status, API key, and creation time. You can perform the following operations on a member:
Disable: After a member is disabled, the API key of the member immediately becomes invalid.
Delete: Deleting a member also deletes all memory data of the member. The deleted data cannot be recovered.
Create a knowledge base and import documents
A knowledge base collects documents and multi-modal content. The content is parsed, chunked, and vectorized to build a searchable knowledge foundation.
Create a knowledge base
Go to the workspace details page, click the Knowledge Base tab, and then click Create Knowledge Base.
Basic Information (step 1): Configure the following settings, and then click Next.
Parameter
Description
Knowledge Base Name
Required. The name must start with a lowercase letter and can contain lowercase letters, digits, and underscores. It can be up to 30 characters in length and cannot be modified after the knowledge base is created. Example:
product_manual.Description
Optional. The description can be up to 1,024 characters in length.
Document Processing Configuration (step 2): The four processing switches are turned on by default. Configure the following items as needed, and then click Next.
Configuration item
Description
File Parse Model
The service that is used to parse document content. The default value is
ops-document-analyze-002. Different services recognize content such as tables and images with different levels of accuracy.Document Chunking
When this switch is turned on, documents are chunked by sentence, which suits scenarios that require fine-grained retrieval. You can configure separators in Custom Chunking.
Image Content Parsing
When this switch is turned on, images in documents are recognized and understood, which improves the retrieval quality of documents that contain images.
Understanding Enhancement
Enables text enhancement, document summaries, and section summaries to improve retrieval relevance and overall comprehension.
Agentic Wiki
(Recommended) When this switch is turned on, the agent automatically generates Wiki pages based on the knowledge base content and continues to maintain them. When you turn it off, updates stop and existing pages are not affected.
Vectorization Model
The default value is
text-embedding-v4.Multimodal Vectorization Model
The default value is
qwen3-vl-embedding.Model Service Configuration (step 3): Confirm the API key, the connection domain, and other information, and then click Confirm Creation.
By default, this step uses the API key of the workspace member and the connection domain of AI Search Open Platform, which provides Model Studio Model-as-a-Service (MaaS) full-stack model services and AI search model services.
- Important
The page states that this configuration incurs fees related to AI Search Open Platform. Make sure that you understand the billing method and the billable items.
After the knowledge base is created, it appears in the list with the status Normal.
Import documents
In the knowledge base list, click Upload Document for the target knowledge base.
On the Upload Local Files tab, click the upload area to select files, or drag files into the upload area. You can upload multiple files at the same time.
Supported document formats:
pdf,doc,docx,html,htm,txt,md,jsonl,csv,ppt,pptx,xls, andxlsx.Supported image formats:
png,jpg,jpeg,jp2,gif,webp,bmp, andtiff.Supported audio and video formats:
mp3,mp4,avi,mkv, andmov.Size limits: A single document or image file cannot exceed 200 MB, and a PDF file cannot exceed 300 pages. A single audio or video file cannot exceed 1 GB.
For the authoritative list of supported formats and size limits, refer to the console.
You can also switch to the Upload from Data Source tab to import files in batches from a data source.
After you confirm the file list, click Start Upload.
- Note
Closing the window does not interrupt the upload. You can check the progress in the task tray in the lower-right corner of the page.
After the upload, documents enter the processing pipeline: parsing, chunking, vectorization, and indexing. After processing is complete, the document status shows Succeeded, and the documents have been added to the knowledge base and are available for retrieval. The Wiki pages that are automatically generated based on the knowledge base content are slightly delayed.
In addition, knowledge base content supports operations such as adding documents, deleting documents, and rebuilding indexes.
Knowledge base details page
The knowledge base details page contains the following tabs:
Overview: shows the basic information of the knowledge base and the number of documents.
Document Processing: shows the document list, which contains the document name, status, and ingestion time. You can also upload documents and view document details.
Wiki: shows the Wiki pages that are automatically generated from the knowledge base content.
Knowledge Graph: shows the graph of the knowledge base content.
Connect an agent and retrieve knowledge
Agentic Context connects a workspace to an agent through the Model Context Protocol (MCP). After the connection is established, the agent uses MCP to retrieve the knowledge bases, smart memories, and skills in the workspace, and to get context with citations.
Connect an agent
On the Overview tab of the workspace, click Connect Agent.
Select Member: Select the member to use for the connection from the drop-down list. When you copy the access command, the full API key of the selected member is automatically filled in. Do not share it with others.
Select Access Method: Select the target agent (Qoder, Codex, Claude Code, Hermes, and OpenClaw are supported) and one of the following access methods:
Natural Language Access (recommended): Send one sentence to the agent. The agent reads the access instructions and completes the MCP configuration automatically.
Command Line Access: Copy the command and run it in a terminal. This method suits server and CLI scenarios. The command uses the following format:
npx --yes @aliyun-es/agentic-context@latest install <qoder|codex|claude-code|hermes|openclaw> \ --endpoint <service address> \ --workspace <workspace name> \ --user_id <member ID> \ --api_key <member API key> \ --jsonWhen you configure Connect Agent in the console, the system automatically generates the command for you to view.
After the command runs, the credentials are written to the MCP configuration of the agent. Restart the agent before you test the connection so that the configuration takes effect.
Retrieve enterprise knowledge
After the connection is complete, the agent can call the retrieval capabilities of Agentic Context through MCP. For each retrieval, Agentic Context runs the request through the following stages: identity authentication, intent recognition, permission filtering, multi-channel recall, fusion ranking, and reranking. Recall covers the BM25, vector, and sparse channels. Agentic Context then returns context with citations. A citation contains the source document, version, and position, which makes tracing easy.
You can start a retrieval in natural language in the agent. To verify that the connection works, ask the agent a question about an enterprise knowledge base. The agent calls Agentic Context to retrieve the relevant content and answers with citations.
For each retrieval, Agentic Context processes the request in the context of the member identity that initiates the call. Each member in a workspace has independent smart memories and custom skills, and members are naturally isolated from each other. A member can access only the memories and custom skills of that member. This mechanism supports both resource sharing across departments and separate isolation of personal memories and skills.
Skills are divided into built-in skills and custom skills. Built-in skills cannot be deleted, but you can enable or disable them. A built-in skill takes effect for all members in the workspace. Custom skills are created and managed independently by each member and take effect only for the member who owns them.