Skip to content

northseadl/norix-skills / llm-agent-dev

llm-agent-dev

Unverified

LLM Agent engineering: pattern selection (12-mode matrix), data simulation, convergence iteration. Covers intent routing, function calling, ReAct, MCP, prompt chaining, guardrails, evaluation.

FileKindSize
SKILL.mdskill md17.6 KB
agents/openai.yamlconfig198 B
evals/evals.jsonconfig4.7 KB
references/convergence/iteration-protocol.mdmarkdown8.0 KB
references/eval-loop.mdmarkdown9.4 KB
references/feedback-protocol.mdmarkdown6.0 KB
references/intent-patterns.mdmarkdown5.8 KB
references/paradigms/context-engineering.mdmarkdown6.0 KB
references/paradigms/decision-tree.mdmarkdown2.7 KB
references/paradigms/memory-architecture.mdmarkdown4.0 KB
references/paradigms/observability.mdmarkdown4.5 KB
references/paradigms/pattern-matrix.mdmarkdown3.3 KB
references/paradigms/performance-benchmarking.mdmarkdown15.2 KB
references/paradigms/prompt-patterns.mdmarkdown5.0 KB
references/paradigms/safety-guardrails.mdmarkdown5.5 KB
references/paradigms/tool-design.mdmarkdown2.5 KB
references/patterns/01-crex-rule-router.mdmarkdown6.8 KB
references/patterns/02-slot-filling.mdmarkdown7.1 KB
references/patterns/03-function-calling.mdmarkdown3.9 KB
references/patterns/04-workflow-agent.mdmarkdown5.0 KB
references/patterns/05-react-agent.mdmarkdown3.4 KB
references/patterns/06-router-expert.mdmarkdown3.2 KB
references/patterns/07-mcp-tool-protocol.mdmarkdown5.0 KB
references/patterns/08-handoff-delegation.mdmarkdown4.7 KB
references/patterns/09-prompt-chaining.mdmarkdown3.0 KB
references/patterns/10-parallelizing.mdmarkdown3.2 KB
references/patterns/11-orchestrator-worker.mdmarkdown4.8 KB
references/patterns/12-evaluator-optimizer.mdmarkdown5.5 KB
references/scenarios/coding-assistant.mdmarkdown2.0 KB
references/scenarios/content-generation.mdmarkdown2.7 KB
references/scenarios/customer-service.mdmarkdown2.6 KB
references/scenarios/ecommerce-shopping.mdmarkdown4.2 KB
references/scenarios/food-ordering.mdmarkdown3.1 KB
references/scenarios/knowledge-qa.mdmarkdown2.6 KB
references/simulation/data-generation.mdmarkdown8.1 KB
references/skill-templates.mdmarkdown8.0 KB

references/paradigms/memory-architecture.md

View on GitHub
# 记忆架构 (Memory Architecture)

> Agent 的短期记忆、长期记忆和知识检索架构设计

## 三层记忆模型

```
┌─────────────────────────────────────────────────────┐
│                Agent 记忆架构                         │
│                                                      │
│  ┌──────────────┐  ┌──────────────┐  ┌───────────┐ │
│  │ Working      │  │ Session      │  │ Long-term │ │
│  │ Memory       │  │ Memory       │  │ Memory    │ │
│  │              │  │              │  │           │ │
│  │ 当前对话轮次  │  │ 当前会话状态  │  │ 跨会话    │ │
│  │ Slot 状态    │  │ History      │  │ 用户画像  │ │
│  │ 中间推理     │  │ Context      │  │ 知识库    │ │
│  │              │  │              │  │           │ │
│  │ 存储: 内存   │  │ 存储: Redis  │  │ 存储: DB  │ │
│  │ TTL: 请求级  │  │ TTL: 小时级  │  │ TTL: 持久 │ │
│  └──────────────┘  └──────────────┘  └───────────┘ │
└─────────────────────────────────────────────────────┘
```

## Working Memory

当前请求内的状态,用于 Slot 填充、ReAct 推理链等。

```typescript
interface WorkingMemory {
  currentIntent: IntentResult;
  slots: Record<string, any>;
  reasoningChain: string[];      // ReAct 的 thought 序列
  toolCallResults: ToolResult[];  // 工具调用结果
  pendingActions: string[];       // 未完成的动作
}
```

## Session Memory

同一会话内的多轮对话上下文。

```typescript
interface SessionMemory {
  sessionId: string;
  userId: string;
  history: Message[];           // 原始对话历史
  summarizedHistory: string;    // 压缩后的历史摘要
  activeSlots: Record<string, any>; // 跨轮保持的 slot
  turnCount: number;
  createdAt: Date;
  lastActiveAt: Date;
}
```

### 管理策略

| 策略 | 实现 | 适用 |
|------|------|------|
| FIFO 滑窗 | 保留最近 N 轮 | 简单客服 |
| 摘要压缩 | 早期对话 → LLM 摘要 | 长对话 |
| 结构化提取 | 提取 key-value → 丢弃原文 | Slot 密集型 |
| 全量 + 截断 | 全部保留,超限时截断最早的 | 对完整性要求高的 |

## Long-term Memory

### 用户画像 (Persistent Profile)

```typescript
interface UserProfile {
  userId: string;
  name: string;
  level: string;          // VIP, SVIP, normal
  preferences: string[];  // 偏好品类
  recentIntents: { intent: string; count: number }[]; // 高频意图
  totalOrders: number;
  totalSpend: number;
  sentiment: 'positive' | 'neutral' | 'negative';
  notes: string[];        // 人工标注的备注
}
```

### Agentic RAG (检索增强 Agent)

当 Agent 需要外部知识时,将 RAG 作为一个工具:

```typescript
const ragTool: ToolDefinition = {
  name: 'search_knowledge',
  description: '在知识库中搜索相关信息。用于回答产品规格、政策、FAQ 等问题。',
  parameters: {
    query: { type: 'string', description: '搜索查询' },
    category: {
      type: 'string', 
      description: '知识库类别',
      enum: ['product', 'policy', 'faq', 'tutorial'],
    },
  },
};

// Agent 自主决定何时检索
// 而非每次都自动检索 — 避免不必要的延迟和 token 消耗
```

### 记忆更新策略

```
用户对话结束
     │
     ▼
[会话摘要] → 提取关键信息 → 更新 UserProfile
     │
     ├── 新偏好? → 更新 preferences
     ├── 高频意图? → 更新 recentIntents
     ├── 情感变化? → 更新 sentiment
     └── 重要信息? → 添加 notes
```
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall