一键导入
main-thread-only-cache-editing
Gate cached microcompact cache edits to the main thread so background forks cannot alter the shared cache state.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Gate cached microcompact cache edits to the main thread so background forks cannot alter the shared cache state.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Collapse multiple change sources into one caller-facing boolean so headless bootstraps know whether a downstream refresh is necessary.
After awaiting persistence work, update the shared budget state for each `tool_use_id` exactly once so no concurrent reader ever sees a half-committed decision.
Issue continuation nudges while the turn stays under budget, then halt once diminishing returns or the budget cap justify stopping.
Lazily extract referenced files for bundled skills so large prompts stay offline until needed.
Persist a cache-safe stop-hook context snapshot only for main session queries so later helpers can resume from stable state without fork pollution.
Sweep stale extension caches before activation, then fall back to a sticky manual-refresh flag if the live refresh fails.
基于 SOC 职业分类
| name | main-thread-only-cache-editing |
| description | Gate cached microcompact cache edits to the main thread so background forks cannot alter the shared cache state. |
| metadata | {"author":"ychampion"} |
Domain: context-management
Trigger: Use when cached microcompact runs and you must prevent subagents or forks from writing cache edits that the main thread shares.
Source Pattern: Distilled from reviewed context, compaction, and memory-governance patterns.
Only perform cache-editing microcompactions when the executing query source is the main thread (repl_main_thread or unspecified). This avoids contaminating shared cachedMCState with tool results that belong to background runs like session-memory compact, prompt suggestion, or other forks. The guard also ensures the cached MC path is never triggered in non-ANT builds that disable the feature altogether.
isMainThreadSource(querySource) so only canonical queries can edit the global cache.feature('CACHED_MICROCOMPACT') to keep the functionality out of builds that do not support it.querySource.startsWith('repl_main_thread') rather than strict equality so styled prompt contexts still match.cachedMCState unexpectedly.When a main-thread REPL session hits the cached microcompact trigger, the guard passes, allowing registerToolResult and createCacheEditsBlock to run. Forked agents such as session memory or prompt suggestion skip this block entirely, leaving the global cache untouched.
cachedMCState; they should always defer to the main thread’s editing path.