Skip to content

Architecture

Yunque Agent is a modular AI agent runtime with 40+ core modules, all wired in cmd/agent/main.go. It uses a "control plane + execution plane" dual-layer architecture, decoupling the cognitive engine from external integrations.

Request Flow

HTTP / WebSocket / IM Channel → Gateway (Auth · CORS · Rate-limit · RBAC)
  → Guardrails (Input: PII redaction · Injection detection · Shell Guard)
  → Session Manager (History load · Fork/Branch)
  → Smart Router (Model selection by complexity: fast / smart / expert)
  → Cost Tracker (Budget check · Real-time billing)
  → Context Manager (Token budget · Compression · Sliding window)
  → Planner (LLM planning loop + Memory + Knowledge RAG + Skill orchestration)
  → Guardrails (Output: PII redaction · Content filter)
  → Memory Pipeline (Async fact extraction → 5-layer memory)
  → Audit Trail (Merkle immutable log)
  → Reflection Loop (Experience accumulation → Strategy compilation)

Core Modules

Cognitive Layer (agentcore)

ModuleFunction
llmLLM client, streaming, provider registry, circuit breaker
plannerMulti-step planning loop, skill orchestration, emotion-aware, Reverie
memory5-layer memory (short/mid/long/editable/knowledge graph)
knowledgeHybrid RAG: BM25 + vector + RRF + Rerank
skillsSkill registry, execution, parameter validation
skillmarketSkill installation, ClawHub/ToriHub market, SkillFileLoader
emotionEmotion analysis, history, sticker mapping
personaPersona chain, feature switches, templates
taskTask lifecycle, thread management, working memory
workflowDAG workflow engine, conditional branching, parallel execution

Security & Governance

ModuleFunction
guardrailsContent safety, PII redaction, injection detection, Shell Guard
auditMerkle chain immutable audit log
trustTrust score system, progressive permissions
approvalHigh-risk operation approval, 4-tier risk classification
rbacRole-based access control, 4-level inheritance

Execution Layer

ModuleFunction
channel16+ IM channel adapters with resilience wrappers
sandboxCode sandbox (process/Docker/K8s/Wasm), E2B Desktop
schedulerTask scheduler, Q-Learning optimization

Directory Structure

internal/
├── agentcore/        # 40+ cognitive modules
├── controlplane/     # HTTP/WS API gateway
├── execution/        # Sandbox, scheduler, 16+ channel adapters
├── experimental/     # Reflection, distillation, causal chains
├── storage/          # SQLite storage layer
├── ledger/           # KV storage + persistence bridge
cmd/agent/            # Entry point
plugins/              # Go skill plugins
pkg/                  # Shared libraries (plugin loader, skills)
data/
├── plugins/          # Script plugins (Python/Node/Shell)
├── skills/           # File-based skills (SKILL.md)
└── knowledge/        # Knowledge base documents
heroui-web/           # HeroUI v3 + Next.js dashboard
docs/                 # VitePress documentation

© 2025 云鸢科技(青岛)有限公司 × Dream Lab