[Bug]: Dynamic runtime context blocks in system prompt invalidate tools KV cache across sessions and workspaces

未关闭
#638 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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 system prefix.
  • Because tools sit after system in the prefix cache (system → tools → messages), the entire tools schema 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.

主要语言
TypeScript
星标
2.3k
派生
315
平均合并
3 小时 54 分钟
30 天内合并 PR
9

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MiniMax-AI/minimax-code 的其他 Issue

查看 MiniMax-AI/minimax-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。