refactor: system prompts

This commit is contained in:
Acbox
2026-02-06 16:41:00 +08:00
parent fe71e7d36d
commit 4ad7b2abd7
5 changed files with 40 additions and 63 deletions
+4 -4
View File
@@ -13,8 +13,8 @@ export const createAgent = ({
language = 'Same as the user input',
allowedActions = allActions,
identity,
platforms = [],
currentPlatform = 'Unknown Platform',
channels = [],
currentChannel = 'Unknown Channel',
}: AgentParams, fetch: AuthFetcher) => {
const model = createModel(modelConfig)
@@ -23,7 +23,7 @@ export const createAgent = ({
date: new Date(),
language,
maxContextLoadTime: activeContextTime,
platforms,
channels,
skills: [],
enabledSkills: [],
})
@@ -42,7 +42,7 @@ export const createAgent = ({
const text = user(input.query, {
contactId: identity.contactId,
contactName: identity.contactName,
platform: currentPlatform,
channel: currentChannel,
date: new Date(),
attachments: files,
})
+6 -6
View File
@@ -10,8 +10,8 @@ import { allActions } from '../types'
const AgentModel = z.object({
model: ModelConfigModel,
activeContextTime: z.number(),
platforms: z.array(z.string()),
currentPlatform: z.string(),
channels: z.array(z.string()),
currentChannel: z.string(),
allowedActions: z.array(AllowedActionModel).optional().default(allActions),
messages: z.array(z.any()),
skills: z.array(z.string()),
@@ -27,8 +27,8 @@ export const chatModule = new Elysia({ prefix: '/chat' })
const { ask } = createAgent({
model: body.model as ModelConfig,
activeContextTime: body.activeContextTime,
platforms: body.platforms,
currentPlatform: body.currentPlatform,
channels: body.channels,
currentChannel: body.currentChannel,
allowedActions: body.allowedActions,
identity: body.identity,
}, authFetcher)
@@ -46,8 +46,8 @@ export const chatModule = new Elysia({ prefix: '/chat' })
const { stream } = createAgent({
model: body.model as ModelConfig,
activeContextTime: body.activeContextTime,
platforms: body.platforms,
currentPlatform: body.currentPlatform,
channels: body.channels,
currentChannel: body.currentChannel,
allowedActions: body.allowedActions,
identity: body.identity,
}, authFetcher)
+25 -48
View File
@@ -5,7 +5,7 @@ export interface SystemParams {
date: Date
language: string
maxContextLoadTime: number
platforms: string[]
channels: string[]
skills: AgentSkill[]
enabledSkills: AgentSkill[]
}
@@ -23,13 +23,13 @@ export const system = ({
date,
language,
maxContextLoadTime,
platforms,
channels,
skills,
enabledSkills,
}: SystemParams) => {
const headers = {
'language': language,
'available-platforms': platforms.join(','),
'available-channels': channels.join(','),
'max-context-load-time': maxContextLoadTime.toString(),
'time-now': date.toISOString(),
}
@@ -38,69 +38,46 @@ export const system = ({
---
${Bun.YAML.stringify(headers)}
---
You are a personal housekeeper assistant, which able to manage the master's daily affairs.
You are an AI agent, and now you wake up.
Your abilities:
- Long memory: You possess long-term memory; conversations from the last ${maxContextLoadTime} minutes will be directly loaded into your context. Additionally, you can use tools to search for past memories.
- Scheduled tasks: You can create scheduled tasks to automatically remind you to do something.
## Memory
**Memory**
- Your context has been loaded from the last ${maxContextLoadTime} minutes.
- You can use ${quote('search_memory')} to search for past memories with natural language.
Your context is loaded from the recent of ${maxContextLoadTime} minutes (${(maxContextLoadTime / 60).toFixed(2)} hours).
**Schedule**
- We use **Cron Syntax** to schedule tasks.
- You can use ${quote('schedule_list')} to get the list of schedules.
- You can use ${quote('schedule_delete')} to remove a schedule by id.
- You can use ${quote('schedule_create')} to create a new schedule.
+ The ${quote('pattern')} is the pattern of the schedule with **Cron Syntax**.
+ The ${quote('command')} is the natural language command to execute, will send to you when the schedule is triggered, which means the command will be executed by presence of you.
+ The ${quote('max_calls')} is the maximum number of calls to the schedule, If you want to run the task only once, set it to 1.
- The ${quote('command')} should clearly describe what needs to be done when the schedule triggers. You will receive this command and respond accordingly.
For memory more previous, please use ${quote('search_memory')} tool.
**Message**
## Contacts
For normal conversation, your text output is automatically delivered to the master—no tool call needed.
You may receive messages from many people or bots (like yourself), They are from different channels.
The ${quote('send_message')} tool is available for special cases:
- Scheduled task triggers: When a schedule fires, use it to notify the master.
- Sending to a different target: If you need to message someone other than the current conversation partner.
- User explicitly requests: If the master asks you to "send a message" somewhere.
You have a contacts book to record them that you do not need to worry about who they are.
Parameters:
- ${quote('platform')}: The platform to send to (must be one of ${quote('available-platforms')}).
- ${quote('message')}: The message content.
- ${quote('target')}: (Optional) The target chat/user. Omit to reply to the current session.
## Channels
**Contacts (Your Personal Address Book)**
You are able to receive and send messages or files to different channels.
Contacts are YOUR tool for keeping track of who's who. When someone tells you their name, nickname, or identity (e.g., "I'm Zhang San" or "Call me Xiao Ming"), you should proactively create or update their contact entry. This helps you remember people across conversations.
## Attachments
- ${quote('contact_search')}: Look up a contact by name or alias.
- ${quote('contact_create')}: Create a new contact when you learn someone's identity.
- ${quote('contact_update')}: Update a contact's information (name, alias, notes, etc.).
- ${quote('contact_bind_token')}: Issue a one-time token for identity verification.
- ${quote('contact_bind')}: Bind a contact to a platform identity using a token.
### Receive
**Best Practice**: When a user introduces themselves or mentions who they are, use ${quote('contact_update')} to record this information. Your contacts are your memory of the people you interact with.
Files user uploaded will added to your workspace, the file path will be included in the message header.
**Subagent**
When a task is large, you can create a Subagent to help you complete some tasks in order to save your own context.
### Send
- You can use ${quote('create_subagent')} to create a new subagent.
- You can use ${quote('list_subagents')} to list subagents you have created.
- You can use ${quote('delete_subagent')} to delete a subagent by id.
- You can use ${quote('query_subagent')} to ask a subagent to complete a task.
+ The ${quote('name')} is the name of the subagent to ask.
+ The ${quote('query')} is the prompt to ask the subagent to complete the task.
Before asking a subagent, you should first create a subagent if it does not exist.
**For using channel tools**: Add file path to the message header.
**For directly request**: Use the following format:
**Skills**
<attachments>
- /path/to/file.pdf
- /path/to/video.mp4
</attachments>
## Skills
There are ${skills.length} skills available, you can use ${quote('use_skill')} to use a skill.
${skills.map(skill => `- ${skill.name}: ${skill.description}`).join('\n')}
**Enabled Skills**
## Enabled Skills
${enabledSkills.map(skill => skillPrompt(skill)).join('\n\n---\n\n')}
`.trim()
+3 -3
View File
@@ -3,19 +3,19 @@ import { ContainerFileAttachment } from '../types'
export interface UserParams {
contactId: string
contactName: string
platform: string
channel: string
date: Date
attachments: ContainerFileAttachment[]
}
export const user = (
query: string,
{ contactId, contactName, platform, date, attachments }: UserParams
{ contactId, contactName, channel, date, attachments }: UserParams
) => {
const headers = {
'contact-id': contactId,
'contact-name': contactName,
'platform': platform,
'channel': channel,
'time': date.toISOString(),
'attachments': attachments.map(attachment => attachment.path),
}
+2 -2
View File
@@ -41,8 +41,8 @@ export interface AgentParams {
allowedActions?: AgentAction[]
brave?: BraveConfig
identity: IdentityContext
platforms?: string[]
currentPlatform?: string
channels?: string[]
currentChannel?: string
}
export interface AgentInput {