MoonshotAI / MoonshotAI/kimi-code
Cross-session personal memory (memory.md + auto memory)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What feature would you like to see?
Each session starts fresh — the agent has no memory of user preferences, project patterns, or lessons learned from previous sessions. Users repeatedly provide the same context ("I use uv not pip", "reply in Chinese", "push directly without asking"). This wastes tokens and degrades the experience over time.
Current state
Kimi Code has AGENTS.md for project/team instructions (loaded via profile/context.ts), but:
- No mechanism for personal, cross-session preferences (e.g. "I prefer
uvoverpip") - No mechanism for the agent to learn from past sessions (e.g. "this project uses
pnpm test, notnpm test") ContextMemoryand compaction are session-scoped — nothing survives session end
Comparison with other agents
| Agent | Manual memory | Auto memory |
|---|---|---|
| Claude Code | CLAUDE.md |
Auto Memory (~/.claude/memdir/, AI-extracted) |
| Codex CLI | AGENTS.md |
Memories (~/.codex/memories/, async background) |
| kimi-code | AGENTS.md |
None |
Proposed approach
A two-phase design that reuses existing infrastructure (AGENTS.md loading, injection system, compaction hooks).
Phase 1: Manual memory file (MVP)
Load memory.md files alongside AGENTS.md, injected into the system prompt as a separate section:
~/.kimi-code/memory.md ← User-global personal preferences
.kimi-code/memory.md ← Project-level personal memory (gitignored)
Example ~/.kimi-code/memory.md:
## Preferences
- Use `uv` for Python package management
- Push directly after commit, no need to confirm
- Reply in Chinese
## Workflow
- Run tests with `pnpm test` before committing
Why a separate file instead of extending AGENTS.md:
AGENTS.mdis team-shared (checked into VCS); personal preferences shouldn't be- Different precedence and lifecycle —
memory.mdis personal,AGENTS.mdis project/team - Keeps the conceptual boundary clean: AGENTS.md = instructions, memory = preferences/learnings
Implementation surface (small):
profile/context.ts: addloadMemory()mirroringloadAgentsMdForRoots()profile/types.ts: addmemory?: stringtoSystemPromptContextprofile/default/system.md: add{{ KIMI_MEMORY }}section- Tests in
test/profile/context.test.ts
Phase 2: Auto memory (follow-up)
Agent extracts durable facts from sessions and writes them to ~/.kimi-code/memories/<project>/memory.md:
- Triggered after compaction (reuse
PostCompacthook) or on session end - A new
remembertool lets the agent actively save a note - Loaded at session start, capped at a token budget (like Claude Code's 200-line / 25KB limit)
- User can audit/edit via
/memorycommand
Design principles
- File-based, no new dependencies — plain Markdown, same as AGENTS.md
- Reuse existing patterns — loading, merging, injection all mirror AGENTS.md
- User-controlled — files are readable/editable, auto-memory can be disabled
- Decoupled from compaction — compaction is session-scoped; memory is cross-session
Additional information
Phase 1 is a small, self-contained change (~4 files). Happy to implement it as a PR once there's alignment on the approach.
Key design decisions that could use maintainer input:
- Separate
memory.mdfile vs. extendingAGENTS.mdwith a personal section — I lean toward separate for the reasons above, but open to alternatives - Project-level
memory.mddefault.gitignorebehavior — should kimi-code auto-add it? - Token budget for memory content (Claude Code uses 25KB; kimi-code's AGENTS.md uses 32KB recommended max)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with profile/context.ts and loadAgentsMdForRoots(), then inspect profile/types.ts, profile/default/system.md, and test/profile/context.test.ts. Determine the agreed Phase 1 behavior for global and project memory files, precedence, limits, and gitignore handling before implementation. Done means the accepted memory-loading and system-prompt behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100