Skip to content

feat: Moss Integration for LiveKit Agents#4812

Open
CoderOMaster wants to merge 2 commits intolivekit:mainfrom
usemoss:feature/moss-plugin
Open

feat: Moss Integration for LiveKit Agents#4812
CoderOMaster wants to merge 2 commits intolivekit:mainfrom
usemoss:feature/moss-plugin

Conversation

@CoderOMaster
Copy link

@CoderOMaster CoderOMaster commented Feb 13, 2026

PR Description: Moss Integration for LiveKit Agents

Description

This PR introduces livekit-plugins-moss, integrating Moss with LiveKit Agents.

The problem: Voice agents have a ~800ms total latency budget to feel natural. Traditional RAG pipelines add 100–500ms of network round-trips per retrieval call, making real-time knowledge retrieval impractical during live conversations.

The solution: Moss is an edge-native semantic search runtime that runs in the same process as your LiveKit agent. Once assets are downloaded, search executes locally with sub-10ms latency and zero network hops - making it practical to retrieve knowledge mid-conversation without breaking conversational flow.

What's New

  • New Plugin (livekit-plugins-moss): A dedicated plugin for Moss integration.
  • MossClient: An asynchronous wrapper around the inferedge-moss SDK, designed for LiveKit's event-driven architecture.
  • Type Definitions: Comprehensive type hints for all operations (IndexInfo, DocumentInfo, SearchResult, etc.).

Key Capabilities

Real-Time Semantic Search

  • Sub-10ms retrieval latency — search runs locally alongside the agent, not over the network
  • Hybrid search with tunable alpha parameter: blend semantic similarity (α=1.0) with keyword matching (α=0.0) to balance precision and recall for your use case

Index Lifecycle Management

  • Create, delete, and list indexes
  • Get detailed index metadata
  • Explicitly load/unload indexes from memory for resource control

Document Management

  • Add, delete, and retrieve documents within indexes
  • Moss handles indexing, packaging, and distribution of your knowledge base

Async-First API

  • All I/O operations are non-blocking async/await, ensuring agent responsiveness during live sessions

Privacy & Offline Support

  • Data stays local once indexed — no queries leave the device
  • Works offline after initial asset download

Usage

Here is a simple example of how to use the MossClient in your agent:

import asyncio
import os
from livekit.plugins.moss import MossClient, DocumentInfo

async def main():
    # Ensure env vars are set: MOSS_PROJECT_ID, MOSS_PROJECT_KEY
    # Client will automatically use these environment variables if not passed explicitly
    client = MossClient()
    index_name = "agent-knowledge-base"

    # 1. Create an index with initial documents
    initial_docs = [
        DocumentInfo(id="2",text="LiveKit is an open source project for real-time communication."),
        DocumentInfo(id="3",text="Moss provides semantic search capabilities for AI agents."),
    ]
    print(f"Creating index '{index_name}'...")
    await client.create_index(index_name, initial_docs)

    # 2. Add more documents later
    new_docs = [
        DocumentInfo(id="1",text="Agents can use plugins to extend their functionality.")
    ]
    await client.add_documents(index_name, new_docs, options=None)

    # 3. Query the index (auto-loads if needed)
    query_text = "What is Moss offering?"
    print(f"Querying: '{query_text}'")
    results = await client.query(index_name, query_text, top_k=2)

    for doc in results.docs:
        print(f"{doc.id}: {doc.text} (score: {doc.score:.3f})")

    # 4. Cleanup
    await client.delete_index(index_name)
    print("Index deleted.")

if __name__ == "__main__":
    asyncio.run(main())

Environment Variables

The client relies on the following environment variables for authentication:

Variable           Description                                       
MOSS_PROJECT_ID Your Moss Project ID. Found in the Moss dashboard.
MOSS_PROJECT_KEY Your Moss Secret Key. Used for API authentication.

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2026

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

@@ -0,0 +1 @@

No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove this change

]
dependencies = [
"livekit-agents>=1.2.18",
"inferedge-moss>=1.0.0b12"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an updated Python version b14 - https://pypi.org/project/inferedge-moss/

description = "Moss plugin for LiveKit Agents"
readme = "README.md"
license = "Apache-2.0"
requires-python = ">=3.9.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.10 and above

"Topic :: Multimedia :: Video",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line.

@@ -0,0 +1,55 @@
# Moss plugin for LiveKit Agents

This package wires the [Moss](https://www.usemoss.dev/) semantic search
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```bash
# change into the examples/dev folder and run the demo
cd examples/dev
python MossLifecycle.py
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is removed, then please update this documentation.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments