fix(agent-core): refresh KIMI_NOW on resume#498
Conversation
🦋 Changeset detectedLatest commit: 387ae91 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 387ae9179b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return systemPrompt.replace( | ||
| KIMI_NOW_LINE_RE, | ||
| `The current date and time in ISO format is \`${new Date().toISOString()}\`.`, |
There was a problem hiding this comment.
Handle custom KIMI_NOW prompt templates
When a resumed session was created with a custom or extended profile that uses {{ KIMI_NOW }} anywhere other than the built-in English sentence, this replacement is a no-op and the next model request still receives the session-creation timestamp. Profiles render KIMI_NOW from arbitrary systemPromptTemplate values before persisting config.update, so the refresh needs to account for those prompts too rather than matching only the default prose line.
Useful? React with 👍 / 👎.
Related Issue
Resolve #446
Problem
See linked issue.
Native sessions persist the rendered system prompt in wire history. On resume, the persisted
KIMI_NOWvalue was replayed as-is, so the next model request could still receive the session creation timestamp instead of the resume-time timestamp.What changed
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Verification
pnpm --filter @moonshot-ai/agent-core exec vitest run test/session/init.test.tspnpm --filter @moonshot-ai/agent-core exec vitest run test/agent/config.test.ts test/agent/resume.test.ts test/profile/default-agent-profiles.test.tspnpm --filter @moonshot-ai/kimi-code-sdk exec vitest run test/session-prompt-events.test.tspnpm --filter @moonshot-ai/agent-core testpnpm run typecheckpnpm testpnpm run lint(0 errors; existing repo-wide warnings remain)