f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.2 KiB
5.2 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-s-component-state-store | S-component (State Store) | 10_Wiki/Topics | verified | self |
|
none | A | 0.85 | applied |
|
2026-05-10 | pending |
|
S-component (State Store)
매 한 줄
"매 LLM agent 의 working memory + 영속 store". 매 LATS / LangGraph / Anthropic Memory Tool 2025 의 backbone 컴포넌트. 매 ephemeral conversation context 의 limit (200K-1M token) 을 넘어 agent 의 task-state, scratchpad, learned facts 를 영속화.
매 핵심
매 Layer
- Working memory: current turn 의 scratchpad (tool result, observations).
- Episodic memory: 매 session log + summarization.
- Semantic memory: extracted facts + embeddings (vector DB).
- Procedural: skill / playbook (file system).
매 vs Context Window
- Context = read-only attention. State = read-write.
- Context = volatile. State = persistent across sessions.
- Context = expensive (caching). State = cheap (KV / vector).
매 응용
- Multi-session task agent (e.g., research assistant).
- CRM-style customer history.
- Coding agent 의 codebase index + recent edits.
- Game NPC memory.
💻 패턴
LangGraph state schema
from typing import TypedDict, Annotated
from langgraph.graph import StateGraph
import operator
class AgentState(TypedDict):
messages: Annotated[list, operator.add]
scratchpad: dict
tool_calls: Annotated[list, operator.add]
final_answer: str | None
graph = StateGraph(AgentState)
graph.add_node("plan", planner)
graph.add_node("act", actor)
graph.add_edge("plan", "act")
Anthropic Memory Tool 2025
import anthropic
client = anthropic.Anthropic()
resp = client.messages.create(
model="claude-opus-4-7",
max_tokens=4096,
tools=[{"type": "memory_20250604", "name": "memory"}],
messages=[{"role": "user", "content": "Remember: I prefer Python type hints."}],
extra_headers={"anthropic-beta": "context-management-2025-06-04"},
)
# Memory persisted across calls; agent reads/writes via tool
Redis-backed working state
import { createClient } from 'redis';
const redis = createClient({ url: process.env.REDIS_URL });
class AgentStateStore {
async get(sessionId: string): Promise<AgentState> {
const data = await redis.get(`agent:${sessionId}`);
return data ? JSON.parse(data) : { scratchpad: {}, messages: [] };
}
async set(sessionId: string, state: AgentState) {
await redis.set(`agent:${sessionId}`, JSON.stringify(state), { EX: 3600 });
}
async append(sessionId: string, msg: Message) {
await redis.rPush(`agent:${sessionId}:msgs`, JSON.stringify(msg));
}
}
Vector store for semantic
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const idx = pc.index('agent-memory');
async function remember(fact: string, embed: (s: string) => Promise<number[]>) {
const vec = await embed(fact);
await idx.upsert([{ id: crypto.randomUUID(), values: vec, metadata: { fact, ts: Date.now() }}]);
}
async function recall(query: string, embed: (s: string) => Promise<number[]>) {
const vec = await embed(query);
const r = await idx.query({ vector: vec, topK: 5, includeMetadata: true });
return r.matches.map(m => m.metadata?.fact);
}
Summarization compaction
async function compactState(s: AgentState): Promise<AgentState> {
if (s.messages.length < 50) return s;
const summary = await llm.summarize(s.messages.slice(0, 30));
return { ...s, messages: [{role: 'system', content: summary}, ...s.messages.slice(30)] };
}
S-component in 6-component pattern (S/T/L/I/M/E)
// S = State, T = Tools, L = LLM, I = Input, M = Memory, E = Effect
type Agent = {
S: StateStore;
T: ToolRegistry;
L: LLMClient;
I: InputParser;
M: MemoryRetriever;
E: SideEffectExecutor;
};
매 결정 기준
| 상황 | Approach |
|---|---|
| Single-turn, stateless | No S-component |
| Multi-turn, single session | In-memory map |
| Cross-session, single user | Redis / SQLite |
| Production multi-user | DB + vector store + memory tool |
| Coding agent | File system + git as state |
기본값: Redis + Postgres + Anthropic Memory Tool — 2026 의 production pattern.
🔗 Graph
- 부모: Agent Architecture
- 변형: Working Memory
- 응용: LangGraph
- Adjacent: T-component (Tool Registry)
🤖 LLM 활용
언제: state schema design, summarization prompt, recall query. 언제 X: high-throughput stateless API (overhead ↑).
❌ 안티패턴
- Unbounded growth: state 의 GC 부재 → cost explosion.
- Stale state: TTL 없는 cache 의 contradiction.
- Tight coupling: S 와 L 의 직접 dep → testing 어려움.
- No versioning: schema migration 깨짐.
🧪 검증 / 중복
- Verified (LangGraph docs, Anthropic Memory Tool 2025 release notes).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — S-component full coverage |