SupportAgent Overview
SupportAgent is a hybrid AI assistant that combines knowledge base search (RAG) with tool calling. It operates in the Telegram, VKontakte, and Max support chats.
Architecture#
Components#
The system consists of three layers:
SupportMessageDispatcher - accepts incoming messages from all channels, deduplicates requests (one user - one active processing), resolves userId from socialId.
SupportRagService - the main request-processing service. Detects intent (question vs. command), searches the knowledge base, manages conversation history.
SupportToolDispatcher - the tool registry. Accepts a tool name and parameters, calls the required
ISupportTool.
Processing flow#
User sends a message
→ SupportMessageDispatcher
→ Resolve userId from socialId
→ SupportRagService.AskAsync()
→ LM Studio: detect intent (question or command?)
├─ Question → search the knowledge base → build an answer via LLM
└─ Command → SupportToolDispatcher.RunAsync()
→ LM Studio + tool_calling → select tool
→ ISupportTool.ExecuteAsync()
→ result → LLM builds the final answer
→ send the response to the user
Intent detection#
Before processing, the agent analyzes the message: is it a question or a request to perform an action?
- Question: "How do I create a giveaway?", "What are sparks?" - the agent looks for the answer in the knowledge base via semantic search.
- Command: "Show my activities", "Check my balance" - the agent calls the corresponding tool.
If the language model is unavailable or unsure about the intent, the agent falls back to knowledge base mode.
Knowledge base (RAG)#
SupportAgent uses Retrieval-Augmented Generation:
- The user's query is converted into a vector via LM Studio Embeddings
- The vector store (
km-storage) is searched for the most similar knowledge base document fragments - The retrieved fragments are passed to the language model as context
- The LLM builds an answer strictly based on the provided context
If no matching fragments are found, the agent responds with a fallback message and suggests contacting a live specialist.
Conversation history#
The agent maintains conversation context. The last N messages (question + answer) are passed to the LLM on every new request, which allows follow-up questions without repeating context.
History is stored in the database (the SupportChatHistory table) and is tied to the session.
Agent tools#
Tools are the real actions the agent can perform. Each tool implements the ISupportTool interface.
Full list of tools and their description:
- get_balance - balance of flasks, sparks, and energy
- list_my_activities - list of activities
- get_activity_status - activity status by code
- create_activity_draft - create a draft
- launch_activity - launch an activity
- stop_activity - stop an activity
- generate_image - generate an image