翻篇收录说明
翻篇网页快照

Memory - Features - Crew - Docs - Kiro

https://kiro.dev/docs/crew/features/memory/

最近抓取:2026-12-01 11:51:48(北京时间)

最近内容变化:2026-12-01 11:51:48(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

How Crew automatically builds, retrieves, and manages memories across sessions. Six memory layers, decay mechanisms, and how lessons override defaults.

正文摘录

Copy pageView as MarkdownMemory Memory is what makes Crew feel like it knows you. New sessions inherit preferences, project context, and learned corrections from every session that came before — without replaying old conversations token by token. There are six independent memory layers, each with a specific purpose. The six memory layers Loading diagram... Preferences — how you like to work User habits, tool preferences, communication style. Replaced wholesale by the consolidator every 30 messages — not append-only. Source: ~/.kiro/crew/workspace/memory/preferences.md Injected every new session Cap: 4,250 chars Example: markdown- Prefers Slack for communication and monitoring - Uses standard Python build system (setuptools/pip) - Prefers deep code analysis with hidden information uncovered - Wants diagrams in documentation for complex flows Projects — active work context CRs, packages, branches, status. Same lifecycle as preferences. Source: ~/.kiro/crew/workspace/memory/projects.md Injected every new session Cap: 6,400 chars Recent history — daily summaries with tiered decay AgeDetail level0–13 daysFull entries with timestamps14–60 daysFirst entry per day + count61–180 daysDate + entry count only181–364 daysNot loaded (kept on disk)365+ daysDeleted from disk Source: ~/.kiro/crew/workspace/memory/history/ Updated on 3-hour idle per session Cap: 26,600 chars Pruned daily via the heartbeat service Semantic memory — structured key-value Structured facts stored in SQLite. Always on — embeddings activate automatically once the model downloads. Storage: SQLite semantic_memory table + optional FAISS index Key prefixes: pref.*, project.*, user.* (plus user-configurable extras) Cap: 12,000 chars Retrieval: hybrid 0.6 × vector_score + 0.4 × keyword_score (keyword-only fallback if the embedding model hasn't downloaded yet) Example entries: user.dev_desktop_host_current: dev-host.example.com project.kirocrew.zoom_fix_implemented: True pref.prefers_configregions_over_null_guards: True Confidence gating prevents hallucinated writes. LLM writes require confidence ≥ 0.8. User-explicit writes always win regardless of confidence. On conflict, higher confidence wins; same confidence → newer wins. Episodic memory — past events Short text snippets capturing specific past events — "fixed the zoom bug by adding CSS custom properties", "user prefers pytest-asyncio strict mode". Think of them as searchable bookmarks into past conversations. Storage: SQLite episodic_memories table + optional FAISS index Text length: 10–2,000 chars per entry Dedup: FAISS cosine > 0.88 rejects near-duplicates Cap: 3,000 chars, top-8 results per query Max entries: 10,000 (lowest-importance oldest pruned when exceeded) Search uses decay scoring with MMR diversity reranking (Jaccard-based, λ=0.6) to avoid redundant results. A two-stage filter first drops irrelevant matches on raw cosine, then decay-adjusted scoring ranks the survivors. Lessons — learned corrections User-taught rules that override default behavior. Created when you say "always do X" or when a correction pattern is detected in a conversation. Storage: lesson.<md5hash> semantic entries (confidence 1.0) Dedup: substring match + topic overlap (>50% keyword → replace) Cap: 37,250 chars, max 50 lessons Injected as a distinct [Learned corrections] block Example: - Dashboard auto-scroll should only trigger when the user is near bottom (within 80px). - Task Runner resets the agent session after each step — the agent can't carry context forward. How memories get built User Message │ ├──► learn_add MCP tool ──► write_lesson() ──► Immediate lesson save │ (user says "remember X" or agent is corrected) │ ├──► 30 messages ──► HistoryConsolidator (prefs path) │ ├── Updates preferences.md (wholesale replace) │ ├── Updates projects.md (wholesale replace) │ └── Extracts semantic entries (max 20) │ ├──► 3h idle ──► HistoryConsolidator (history path) │ ├── Appends to history/{date}.md │ ├── Extracts episodic entries (max 10) │ └── Extracts implicit lessons (corrections without "remember") Two independent consolidation paths PathTriggerUpdatesOffset trackingPreferences / projects30 messagespreferences.md, projects.md, semantic entriesIn-memory offset dictHistory + lessons3h idlehistory/{date}.md, episodic, implicit lessonsPersisted last_consolidated The prefs path does not advance the persisted last_consolidated marker — history consolidation always covers all messages, even if prefs consolidation fired earlier. Explicit vs. implicit lessons Explicit — user says "remember to always use pytest-asyncio strict mode" → saved immediately via learn_add Implicit — user corrects the agent without saying "remember" (e.g., "No, don't cache that — the value changes per request") → extracted during history consolidation Both go through write_lesson() which provides substring dedup and topic-overlap dedup. Fading — three decay mechanisms Three independent decay mechanisms prevent stale memories from consuming context. 1. History decay (time-based tiers) Older history progressively loses detail (see table above). "Something happened" markers eventually replace full entries, then get dropped from context but kept on disk as backup, then are deleted altogether at 365 days. 2. Episodic decay (exponential time-decay scoring) score = cosine_sim × (0.7 + 0.3 × importance) × exp(-0.03 × days_old) cosine_sim — semantic relevance to the current query 0.7 + 0.3 × importance — high-importance memories decay slower exp(-0.03 × days_old) — exponential decay: 50% at ~23 days, 10% at ~77 days 3. Episodic cap enforcement At 10,000 entries the lowest-importance, oldest ones are pruned first. Conflict resolution — priority order 1. Lessons (user-explicit, confidence 1.0) 2. Semantic memory (user-explicit writes) 3. Semantic memory (LLM writes, confidence ≥ 0.8) 4. Preferences / projects (consolidation-generated) 5. Episodic memory (relevance-scored fragments) 6. History (time-decayed summaries) Lessons win the tie because they're injected in a distinct [Learned corrections] block that reads "ALWAYS follow these. They override default behavior." Context assembly The context builder assembles all sources into the prompt. Different content is injected at different times. At session start ComponentCapCritical rules~500 charsCurrent date/time~50 charsAgent system promptVariableThread conversation history45,000 chars (LLM-compressed)Preferences4,250 charsProjects6,400 charsRecent history26,600 charsSkills (always-on + summaries)VariableLessons37,250 charsSemantic memory12,000 chars Per message (follow-up turns) ComponentSourceEpisodic memoryQueried by message text, top-8 fragments (up to 3,000 chars)Channel historyGroup-channel context (Slack observe mode)Triggered skillsOn-demand skills matching message keywordsHook contextConfig-driven context rules Channel-aware memory The same memory store is shared across every channel, but recording behavior varies: ChannelActivationHistory bufferMemory consolidationDMalwaysSession-based (ACP native)✅ YesGroup channelmention50 msg, 5-min TTL, in-memory✅ When @mentionedGroup channelobserve200 msg, 1-week TTL, disk-persisted✅ When @mentionedGroup channeloffNone❌ NoDashboard tabN/ASession-based (ACP native)✅ Yes Security in observe mode. Only messages from authorized users (owner + allowlist) are recorded. Non-authorized messages are silently dropped to prevent prompt injection. Control memory writes and context Four config.json switches separate what Crew records from what a new turn receives: SettingDefaultEffect when offmemory.persistence_enabledtrueStops automatic memory writes and consolidation, and adds no stored memory or lessons to new sessionsmemory.inject_memorytrueOmits stored memory from new-session contextmemory.inject_lessonstrueOmits the learned-corrections and user-profile blocksmemory.inject_activitytrueOmits recent projects, history, task facts, and past episodes. Has no effect when memory.inject_memory is off These process-wide controls do not replace a session's Persistent, Incognito, or Temporary mode. Use a session mode for one conversation. Use these settings when the Gateway should change memory behavior for every new session. Teaching Crew The CLI is the fastest path to add a lesson: bashkirocrew learn add "always use TypeScript over JavaScript" kirocrew learn add "prefer pytest over unittest" --category tool kirocrew learn list kirocrew learn remove "prefer pytest" The learn_add MCP tool is the same interface exposed to the LLM — when the agent recognizes a correction, it calls the tool itself. Embeddings through Ollama By default Kiro Crew embeds memory and knowledge text in process. In Kiro Crew 0.13.0 or later, set memory.embedding_provider to ollama_http to send that text to an Ollama server instead. KeyDefaultMeaningmemory.embedding_provider"llama_cpp"ollama_http sends text to Ollamamemory.ollama_url"http://127.0.0.1:11434"The Ollama server, on this machine by defaultmemory.ollama_model""The embedding model Ollama serves, as listed by its /api/tags. Required for ollama_httpmemory.ollama_allow_remotefalseAllows a remote https Ollama server Set memory.embedding_dim (default 1024) to match the model. A loopback address keeps text on this machine. Switching providers or models changes the vector space, so Kiro Crew regenerates stored embeddings in the background. These keys need a Gateway restart. Recall tuning and cleanup In Kiro Crew 0.13.0 or later: memory.session_affinity and memory.recency_boost (both 0, so off, by default) favor memories from the current session or from recent ones. memory.dream (default off) set to propose runs an offline pass that lists the copies, near-copies, and stale rules it would clean up, and applies nothing. Read the list with kirocrew memory dream list. memory.extraction_instructions tells consolidation, in your own words, what to keep and what never to store. Managing memory from the dashboard The dashboard exposes memory management surfaces: Memory Gr