[Bug]: Dynamic runtime context blocks in system prompt invalidate tools KV cache across sessions and workspaces
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- ai-infra-agents
Research direction
Start by tracing where the system prompt, tool definitions, and runtime context blocks are assembled; the issue does not name specific files or tests. Check how session and workspace context enters the request, then verify that the system and tools prefix stays invariant across sessions while the context remains available in messages. Done means this ordering is covered by an appropriate test.
Written by the indexing model from the issue text.
Description
Summary
Because prefix caching evaluates requests in system → tools → messages order, embedding workspace- and session-specific runtime context blocks directly in system invalidates the KV cache for both system and the entire tools definition block on every new session or workspace switch.
Current Behavior
Dynamic/workspace-dependent sections (environment/OS/cwd/date, session info, memory, skills, project instructions / AGENTS.md, etc.) are placed directly into the system prompt.
As a result:
- Changing workspace, project instructions, memory, or session metadata changes the
systemprefix. - Because
toolssit aftersystemin the prefix cache (system → tools → messages), the entiretoolsschema block misses the cache at session startup, even though tool definitions are identical across sessions and projects.
Expected Behavior / Suggestion
Remove the dynamic/workspace-dependent runtime context blocks from system (keeping system strictly static and invariant across sessions/workspaces) and place those runtime context blocks after tools (in messages).
This keeps the system + tools prefix stable and reusable across new sessions and workspaces, giving immediate token/cost and latency savings from cache hits right from the start of each session.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 315
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from MiniMax-AI/minimax-code
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MiniMax-AI/minimax-code#639 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MiniMax-AI/minimax-code#636 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MiniMax-AI/minimax-code#615 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MiniMax-AI/minimax-code#556 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MiniMax-AI/minimax-code#507 ·
Maintainers usually reply within 1 day
All issues in MiniMax-AI/minimax-code
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
tashfeenahmed/freellmapi#2217 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
remotion-dev/skills#37 ·
-
gui: a narrow window's gateway key row with a line under it wraps its faded badges onto blank linesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Slider: Escape during a thumb drag keeps and commits the dragged value, unlike ui-sdk's other dragsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vercel-labs/ui#1758 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nicobailon/pi-subagents#3425 ·
Maintainers usually reply within 1 day