How the Async Extraction Pipeline Processes L0 Conversation Data in TencentDB Agent Memory

The asynchronous extraction pipeline processes L0 (Long-Output) conversation data through a fire-and-forget HTTP request to the /v3/extract endpoint, immediately returning control to the client while the server extracts structured knowledge in the background.

The TencentDB Agent Memory SDK provides a specialized asynchronous pipeline for handling large conversation logs without blocking application threads. This pattern, implemented in skill_client.py, enables high-throughput ingestion of L0 conversation data while the system runs LLM-based extraction to populate the knowledge base.

Architecture of the AsyncSkillClient

The pipeline centers on the AsyncSkillClient class, which operates as an asynchronous context manager available through the MemoryClient or instantiated directly from the metadata_client.py module.

Context Management and Defaults

When initialized, the client maintains default identifiers in self._defaults for team_id, agent_id, user_id, and task_id. Before submitting any request, the extract method merges these defaults with user-provided parameters and sanitizes the payload using the internal _strip_none helper to remove null values.

Input Validation Pipeline

Prior to transmission, the _validate_extract(messages, body) function (lines 1040-1041 of skill_client.py) enforces schema compliance. This validation ensures:

  • The messages parameter is a non-empty list
  • Each message contains valid role and content fields
  • Required metadata fields are present

The Fire-and-Forget Extraction Flow

The L0 extraction pipeline follows a strict fire-and-forget pattern designed for minimal latency impact on client applications.

HTTP Submission to the Extract Endpoint

The validated payload is posted to /v3/extract via the asynchronous HTTP stub (self._stub.post) defined in _v3_http.py. The implementation intentionally provides no separate polling endpoint; the server immediately acknowledges receipt and begins background processing of the conversation turns.

Server-Side Knowledge Extraction

On the server, the LO extraction service parses the supplied conversation turns, executes the configured LLM pipeline, and persists structured knowledge—including topics, intents, and entities—linked to the provided session_id and space_id. Once processing completes, results become available through standard knowledge-management APIs such as client.get_knowledge and client.list_knowledge.

Companion Operations for Conversation Management

The SDK provides supporting methods that interact with the extraction pipeline lifecycle, defined in skill_client.py.

Appending Raw Conversation Turns

The conversation_add method (lines 1043-1064) appends additional messages to an existing conversation record without triggering extraction. This allows batching of conversation segments before invoking the pipeline.

await client.skill.conversation_add(
    session_id="sess-1234",
    user_id="u-5678",
    team_id="t-9012",
    agent_id="agent-1",
    messages=[{"role": "user", "content": "What is the quota?"}]
)

Forcing Immediate Archival

When automatic archiving conditions are insufficient, conversation_force_archive (lines 1066-1088) manually triggers the extraction process for a specific conversation, useful for guaranteeing extraction after critical dialogue segments.

await client.skill.conversation_force_archive(
    session_id="sess-1234",
    user_id="u-5678",
    team_id="t-9012",
    agent_id="agent-1",
    space_id="default",
    reason="Manual trigger after quota query"
)

Complete Implementation Example

The following example demonstrates the complete flow from client initialization through extraction submission using the MemoryClient facade.

import asyncio
from tencentdb_agent_memory.v3 import MemoryClient

async def run_extraction():
    async with MemoryClient(api_key="YOUR_KEY") as client:
        # Prepare conversation turns (user ↔ assistant)

        messages = [
            {"role": "user", "content": "How do I reset my password?"},
            {"role": "assistant", "content": "You can reset it via the account settings page."},
        ]

        # Fire-and-forget extraction request

        resp = await client.skill.extract(
            messages=messages,
            session_id="sess-1234",
            user_id="u-5678",
            team_id="t-9012",
            agent_id="agent-1",
            reason="Password reset workflow",
        )
        print("Extraction submitted, server reply:", resp)

asyncio.run(run_extraction())

Summary

  • The async extraction pipeline utilizes AsyncSkillClient.extract to submit L0 conversation data without blocking the calling thread.
  • Input validation occurs client-side via _validate_extract before transmission to the /v3/extract endpoint.
  • The pattern is fire-and-forget; there is no polling mechanism, and results propagate to knowledge-management APIs asynchronously.
  • Default identifiers merge automatically from self._defaults, sanitized by _strip_none.
  • Companion methods conversation_add and conversation_force_archive provide fine-grained control over conversation archival and extraction timing.

Frequently Asked Questions

What does L0 conversation data refer to in TencentDB Agent Memory?

L0 (Long-Output) conversation data refers to raw, unstructured dialogue turns between users and agents that require LLM-based processing to extract structured knowledge such as entities, intents, and topics. The pipeline specifically handles these large conversation logs through the async extraction service.

How can I verify that the extraction completed successfully?

Since the pipeline operates as fire-and-forget, the initial response only confirms receipt. Query the extracted knowledge using client.get_knowledge or client.list_knowledge with the associated session_id to verify results populated in the background.

Is there a way to poll the extraction status?

No. According to the source implementation in skill_client.py, there is no separate polling endpoint for the extraction job. The design intentionally decouples submission from retrieval, requiring clients to query the knowledge base directly after a reasonable processing interval.

What validation does the client perform before sending the request?

The client executes _validate_extract(messages, body) to ensure the message list is non-empty, contains valid role-content dictionaries, and includes required metadata fields. This prevents invalid payloads from consuming server resources.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →