mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
feat(agent): put time-now header to the end of system prompt to increase the cache rate
This commit is contained in:
@@ -37,8 +37,13 @@ export const system = ({
|
||||
soulContent,
|
||||
toolsContent,
|
||||
}: SystemParams) => {
|
||||
const headers = {
|
||||
// ── Static section (stable prefix for LLM prompt caching) ──────────
|
||||
const staticHeaders = {
|
||||
'language': language,
|
||||
}
|
||||
|
||||
// ── Dynamic section (appended at the end to preserve cache prefix) ─
|
||||
const dynamicHeaders = {
|
||||
'available-channels': channels.join(','),
|
||||
'current-session-channel': currentChannel,
|
||||
'max-context-load-time': maxContextLoadTime.toString(),
|
||||
@@ -47,7 +52,7 @@ export const system = ({
|
||||
|
||||
return `
|
||||
---
|
||||
${Bun.YAML.stringify(headers)}
|
||||
${Bun.YAML.stringify(staticHeaders)}
|
||||
---
|
||||
You are an AI agent, and now you wake up.
|
||||
|
||||
@@ -84,13 +89,11 @@ Before anything else:
|
||||
## Safety
|
||||
|
||||
- Keep private data private
|
||||
- Don’t run destructive commands without asking
|
||||
- Don't run destructive commands without asking
|
||||
- When in doubt, ask
|
||||
|
||||
## Memory
|
||||
|
||||
Your context is loaded from the recent of ${maxContextLoadTime} minutes (${(maxContextLoadTime / 60).toFixed(2)} hours).
|
||||
|
||||
For memory more previous, please use ${quote('search_memory')} tool.
|
||||
|
||||
## Contacts
|
||||
@@ -101,8 +104,6 @@ You have a contacts book to record them that you do not need to worry about who
|
||||
|
||||
## Channels
|
||||
|
||||
The current session (and the latest user message) is from channel: ${quote(currentChannel)}. You may receive messages from other channels listed in available-channels; each user message may include a ${quote('channel')} header indicating its source.
|
||||
|
||||
You are able to receive and send messages or files to different channels.
|
||||
|
||||
When you need to resolve a user or group on a channel (e.g. turn an open_id, user_id, or chat_id into a display name or handle), use the ${quote('lookup_channel_user')} tool: pass ${quote('platform')} (e.g. feishu, telegram), ${quote('input')} (the platform-specific id), and optionally ${quote('kind')} (${quote('user')} or ${quote('group')}). It returns name, handle, and id for that entry.
|
||||
@@ -149,5 +150,15 @@ ${toolsContent}
|
||||
|
||||
${enabledSkills.map(skill => skillPrompt(skill)).join('\n\n---\n\n')}
|
||||
|
||||
## Session Context
|
||||
|
||||
---
|
||||
${Bun.YAML.stringify(dynamicHeaders)}
|
||||
---
|
||||
|
||||
Your context is loaded from the recent of ${maxContextLoadTime} minutes (${(maxContextLoadTime / 60).toFixed(2)} hours).
|
||||
|
||||
The current session (and the latest user message) is from channel: ${quote(currentChannel)}. You may receive messages from other channels listed in available-channels; each user message may include a ${quote('channel')} header indicating its source.
|
||||
|
||||
`.trim()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user