Bug Description
The system prompt variable KIMI_NOW (injected via Jinja2 template in system.md) is evaluated only once at session creation time and then persisted to context.jsonl. On every subsequent session resume, the cached value is reused instead of being regenerated. This causes the agent to receive a stale timestamp that can be days or weeks old.
Reproduction Steps
- Create a new Kimi CLI session at time T0.
- Close / suspend the session.
- Wait some time (e.g., several days).
- Resume the same session.
- Observe that
KIMI_NOW in the system prompt still shows T0.
Concrete Evidence
In our environment:
- Session directory birth time:
2026-05-08 00:00:17
- Current system time (via
date): 2026-06-05T02:42:13+08:00
- System prompt injected to the model:
2026-05-08T00:00:18
- The stale timestamp is stored in the first line of
context.jsonl:
{"role":"_system_prompt","content":"...The current date and time in ISO format is 2026-05-08T00:00:18..."}
Root Cause
In kimi_cli/soul/agent.py:
# Line ~307
builtin_args=BuiltinSystemPromptArgs(
KIMI_NOW=datetime.now().astimezone().isoformat(), # <-- evaluated once at Runtime() construction
...
)
Runtime (and thus BuiltinSystemPromptArgs) is constructed when the session is first created. On resume, context.py reads the previously persisted system prompt from context.jsonl instead of regenerating it:
# context.py ~293
if role == "_system_prompt":
self._system_prompt = content
Impact
- Agent makes incorrect time-based judgments (file modification age, commit recency, web search relevance windows, etc.)
- The system prompt itself tells the agent: "If you need the exact time, use Shell tool with proper command," yet the stale timestamp is silently presented as fact, leading the agent to skip verification.
- In our case the agent directly quoted the injected time (2026-05-08) without running
date, causing a ~4-week error in date-sensitive reasoning.
Environment
- Version: kimi-cli 1.46.0
- OS: Ubuntu (Linux)
- Shell: bash
Suggested Fixes
Option A — Remove KIMI_NOW entirely:
The system prompt already contains the instruction "If you need the exact time, use Shell tool." Removing the variable eliminates the stale-data hazard without adding token cost.
Option B — Regenerate on each turn:
Re-evaluate datetime.now() and rebuild the system prompt on every turn. Accurate, but increases token usage.
Option C — Lazy substitution (recommended):
Keep the cached system prompt in context.jsonl, but replace KIMI_NOW with a sentinel (e.g., __KIMI_NOW_PLACEHOLDER__). At turn-time, substitute the placeholder with the actual current time before sending to the LLM. This preserves cache efficiency while guaranteeing freshness.
Happy to provide more details or test a patch.
Bug Description
The system prompt variable
KIMI_NOW(injected via Jinja2 template insystem.md) is evaluated only once at session creation time and then persisted tocontext.jsonl. On every subsequent session resume, the cached value is reused instead of being regenerated. This causes the agent to receive a stale timestamp that can be days or weeks old.Reproduction Steps
KIMI_NOWin the system prompt still shows T0.Concrete Evidence
In our environment:
2026-05-08 00:00:17date):2026-06-05T02:42:13+08:002026-05-08T00:00:18context.jsonl:{"role":"_system_prompt","content":"...The current date and time in ISO format is 2026-05-08T00:00:18..."}Root Cause
In
kimi_cli/soul/agent.py:Runtime(and thusBuiltinSystemPromptArgs) is constructed when the session is first created. On resume,context.pyreads the previously persisted system prompt fromcontext.jsonlinstead of regenerating it:Impact
date, causing a ~4-week error in date-sensitive reasoning.Environment
Suggested Fixes
Option A — Remove
KIMI_NOWentirely:The system prompt already contains the instruction "If you need the exact time, use Shell tool." Removing the variable eliminates the stale-data hazard without adding token cost.
Option B — Regenerate on each turn:
Re-evaluate
datetime.now()and rebuild the system prompt on every turn. Accurate, but increases token usage.Option C — Lazy substitution (recommended):
Keep the cached system prompt in
context.jsonl, but replaceKIMI_NOWwith a sentinel (e.g.,__KIMI_NOW_PLACEHOLDER__). At turn-time, substitute the placeholder with the actual current time before sending to the LLM. This preserves cache efficiency while guaranteeing freshness.Happy to provide more details or test a patch.