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
uv over pip")
- No mechanism for the agent to learn from past sessions (e.g. "this project uses
pnpm test, not npm test")
ContextMemory and 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.md is team-shared (checked into VCS); personal preferences shouldn't be
- Different precedence and lifecycle —
memory.md is personal, AGENTS.md is project/team
- Keeps the conceptual boundary clean: AGENTS.md = instructions, memory = preferences/learnings
Implementation surface (small):
profile/context.ts: add loadMemory() mirroring loadAgentsMdForRoots()
profile/types.ts: add memory?: string to SystemPromptContext
profile/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
PostCompact hook) or on session end
- A new
remember tool 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
/memory command
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.md file vs. extending AGENTS.md with a personal section — I lean toward separate for the reasons above, but open to alternatives
- Project-level
memory.md default .gitignore behavior — should kimi-code auto-add it?
- Token budget for memory content (Claude Code uses 25KB; kimi-code's AGENTS.md uses 32KB recommended max)
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
uvnotpip", "reply in Chinese", "push directly without asking"). This wastes tokens and degrades the experience over time.Current state
Kimi Code has
AGENTS.mdfor project/team instructions (loaded viaprofile/context.ts), but:uvoverpip")pnpm test, notnpm test")ContextMemoryand compaction are session-scoped — nothing survives session endComparison with other agents
CLAUDE.md~/.claude/memdir/, AI-extracted)AGENTS.md~/.codex/memories/, async background)AGENTS.mdProposed approach
A two-phase design that reuses existing infrastructure (AGENTS.md loading, injection system, compaction hooks).
Phase 1: Manual memory file (MVP)
Load
memory.mdfiles alongsideAGENTS.md, injected into the system prompt as a separate section:Example
~/.kimi-code/memory.md:Why a separate file instead of extending AGENTS.md:
AGENTS.mdis team-shared (checked into VCS); personal preferences shouldn't bememory.mdis personal,AGENTS.mdis project/teamImplementation surface (small):
profile/context.ts: addloadMemory()mirroringloadAgentsMdForRoots()profile/types.ts: addmemory?: stringtoSystemPromptContextprofile/default/system.md: add{{ KIMI_MEMORY }}sectiontest/profile/context.test.tsPhase 2: Auto memory (follow-up)
Agent extracts durable facts from sessions and writes them to
~/.kimi-code/memories/<project>/memory.md:PostCompacthook) or on session endremembertool lets the agent actively save a note/memorycommandDesign principles
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:
memory.mdfile vs. extendingAGENTS.mdwith a personal section — I lean toward separate for the reasons above, but open to alternativesmemory.mddefault.gitignorebehavior — should kimi-code auto-add it?