How ninimu0326/arknightagent works
Arknights Agent is a web-based Arknights question-answering product. A user asks in the chat UI; the backend streams an Agent response while the LLM selects local knowledge, graph, structured-data, stage-wave, web-search, or optional PRTS MCP tools. Retrieved evidence returns to the Agent for a final streamed answer, with source and image display handled by the frontend. The README documents the major capabilities; sampled source confirms selected retrieval, GraphRAG, storage, and context-compression details, so unsampled internal wiring is omitted where uncertain.
Main entry points: main.py HTTP and SSE API · tool_implementations.py Local tool execution · core.py Agent loop · retrievers.py Hybrid retrieval
Components 27
Web client
- Chat view
frontend/src/views/ChatView.vue - API client
frontend/src/api.js - Graph explorer
frontend/src/views/GraphView.vue - Admin dashboard
frontend/src/views/AdminView.vue
Agent runtime
- HTTP and SSE API
backend/main.py - Agent loop
backend/agent/core.py - Context engine
backend/agent/context_engine.py - Tool registry
backend/agent/tools.py - Local tool execution
backend/agent/tool_implementations.py - LLM client factory
backend/api/llm_factory.py
Knowledge retrieval
- Hybrid retrieval
backend/rag/retrievers.py - FAISS indexes
backend/storage/faiss_client.py - BM25 search
backend/data/bm25_index.py - Cross-encoder reranker
backend/lc/reranker.py - Parent expansion
backend/rag/parent_document.py - GraphRAG query
backend/rag/graphrag/query.py
Data integrations
- Structured SQL
backend/agent/structured_query.py - Stage wave parsing
backend/agent/stage_waves.py - Web search
backend/api/web_search.py - PRTS MCP client
backend/agent/mcp_client.py
State and insight
- SQLite sessions
backend/db.py - Trace service
backend/observability/tracing.py - Quick questions
backend/quick_questions.py
Other components
- Questioner
- LLM provider
- Web sources
- PRTS MCP service
Connections 30
- Questioner → Chat view: asks
- Chat view → API client: submits
- API client → HTTP and SSE API: calls API
- HTTP and SSE API → Agent loop: dispatches
- Agent loop → Context engine: builds context
- Context engine → SQLite sessions: reads and writes
- Agent loop → LLM client factory: requests completion
- LLM client factory → LLM provider: calls
- Agent loop → Tool registry: dispatches tools
- Tool registry → Local tool execution: runs local tools
- Local tool execution → Hybrid retrieval: searches
- Hybrid retrieval → FAISS indexes: vector search
- Hybrid retrieval → BM25 search: keyword search
- Hybrid retrieval → Cross-encoder reranker: reranks
- Hybrid retrieval → Parent expansion: expands documents
- Local tool execution → GraphRAG query: queries graph
- Local tool execution → Structured SQL: queries values
- Local tool execution → Stage wave parsing: parses waves
- Local tool execution → Web search: searches web
- Web search → Web sources: queries
- HTTP and SSE API → PRTS MCP client: registers tools
- Tool registry → PRTS MCP client: dispatches optional tools
- PRTS MCP client → PRTS MCP service: calls tools
- Agent loop → HTTP and SSE API: streams events
- HTTP and SSE API → Chat view: streams response
- HTTP and SSE API → Trace service: records traces
- Admin dashboard → API client: requests admin data
- Graph explorer → API client: requests graph data
- Graph explorer → HTTP and SSE API: loads graph
- Chat view → Quick questions: requests suggestions