feat: improve system prompts

This commit is contained in:
Acbox
2026-02-22 23:40:48 +08:00
parent 85831732d3
commit c17d56c9d1
5 changed files with 58 additions and 18 deletions
+1
View File
@@ -23,6 +23,7 @@
"jsdom": "^27.4.0", "jsdom": "^27.4.0",
"toml": "^3.0.0", "toml": "^3.0.0",
"turndown": "^7.2.2", "turndown": "^7.2.2",
"yaml": "^2.8.2",
"zod": "^4.3.6" "zod": "^4.3.6"
} }
} }
+2 -2
View File
@@ -1,4 +1,5 @@
import { Schedule } from '../types' import { Schedule } from '../types'
import { stringify } from 'yaml'
export interface ScheduleParams { export interface ScheduleParams {
schedule: Schedule schedule: Schedule
@@ -9,14 +10,13 @@ export const schedule = (params: ScheduleParams) => {
const headers = { const headers = {
'schedule-name': params.schedule.name, 'schedule-name': params.schedule.name,
'schedule-description': params.schedule.description, 'schedule-description': params.schedule.description,
'schedule-id': params.schedule.id,
'max-calls': params.schedule.maxCalls ?? 'Unlimited', 'max-calls': params.schedule.maxCalls ?? 'Unlimited',
'cron-pattern': params.schedule.pattern, 'cron-pattern': params.schedule.pattern,
} }
return ` return `
** This is a scheduled task automatically send to you by the system ** ** This is a scheduled task automatically send to you by the system **
--- ---
${Bun.YAML.stringify(headers)} ${stringify(headers)}
--- ---
${params.schedule.command} ${params.schedule.command}
+8 -9
View File
@@ -1,3 +1,5 @@
import { stringify } from 'yaml'
export interface SubagentParams { export interface SubagentParams {
date: Date date: Date
name: string name: string
@@ -10,13 +12,10 @@ export const subagentSystem = ({ date, name, description }: SubagentParams) => {
'description': description, 'description': description,
'time-now': date.toISOString(), 'time-now': date.toISOString(),
} }
return ` return [
--- description,
${Bun.YAML.stringify(headers)} '---'
--- + stringify(headers)
+ '---'
You are a subagent, which is a specialized assistant for a specific task. ].join('\n\n')
Your task is communicated with the master agent to complete a task.
`
} }
+44 -7
View File
@@ -1,5 +1,6 @@
import { block, quote } from './utils' import { block, quote } from './utils'
import { AgentSkill, InboxItem } from '../types' import { AgentSkill, InboxItem } from '../types'
import { stringify } from 'yaml'
export interface SystemParams { export interface SystemParams {
date: Date date: Date
@@ -69,9 +70,9 @@ export const system = ({
return ` return `
--- ---
${Bun.YAML.stringify(staticHeaders)} ${stringify(staticHeaders)}
--- ---
You are an AI agent, and now you wake up. You are just woke up.
${quote('/data')} is your HOME — you can read and write files there freely. ${quote('/data')} is your HOME — you can read and write files there freely.
@@ -94,10 +95,29 @@ Use ${quote('search_memory')} to recall earlier conversations beyond the current
- ${quote('send')}: send a message to a channel target. Requires a ${quote('target')} — use ${quote('get_contacts')} to find available targets. - ${quote('send')}: send a message to a channel target. Requires a ${quote('target')} — use ${quote('get_contacts')} to find available targets.
- ${quote('react')}: add or remove an emoji reaction on a message - ${quote('react')}: add or remove an emoji reaction on a message
Use message tools when:
- Schedule tasks are triggered.
- You need to send a message to other channels.
- You want to reply or react an inbox message.
Do not:
- Use message tools to respond to the user directly
## Contacts ## Contacts
You may receive messages from different people, bots, and channels. Use ${quote('get_contacts')} to list all known contacts and conversations for your bot. You may receive messages from different people, bots, and channels. Use ${quote('get_contacts')} to list all known contacts and conversations for your bot.
It returns each route's platform, conversation type, and ${quote('target')} (the value you pass to ${quote('send')}). It returns each route's platform, conversation type, and ${quote('target')} (the value you pass to ${quote('send')}).
## Your Inbox
You have an inbox full of notifications, they may be from:
- Different groups you are in, they are not mentioned you, but you can be a watcher.
- Other platforms you are connected to, like email, etc.
Knows when to react:
- You can use ${quote('send')} or ${quote('react')} to respond to the inbox messages.
- But remember, Not all messages are needed to be responded to.
- Chat like a human, reply your interesting message.
- Sometimes, an emoji reaction is better than a long text.
## Attachments ## Attachments
**Receiving**: Uploaded files are saved to your workspace; the file path appears in the message header. **Receiving**: Uploaded files are saved to your workspace; the file path appears in the message header.
@@ -119,6 +139,25 @@ Rules:
- No extra text inside ${quote('<attachments>...</attachments>')} - No extra text inside ${quote('<attachments>...</attachments>')}
- The block can appear anywhere in your response; it will be parsed and stripped from visible text - The block can appear anywhere in your response; it will be parsed and stripped from visible text
## Schedule Tasks
You can create and manage schedule tasks via cron.
Use ${quote('schedule')} to create a new schedule task, and fill ${quote('command')} with natural language.
When cron pattern is valid, you will receive a schedule mesasage with your ${quote('command')}.
Using ${quote('send')} to respond is a better way than responding directly.
## Subagent
For complex tasks like:
- Create a website
- Research a topic
- Generate a report
- etc.
You can create a subagent to help you with these tasks,
${quote('description')} will be the system prompt for the subagent.
## Skills ## Skills
${skills.length} skills available via ${quote('use_skill')}: ${skills.length} skills available via ${quote('use_skill')}:
${skills.map(skill => `- ${skill.name}: ${skill.description}`).join('\n')} ${skills.map(skill => `- ${skill.name}: ${skill.description}`).join('\n')}
@@ -139,11 +178,9 @@ ${enabledSkills.map(skill => skillPrompt(skill)).join('\n\n---\n\n')}
${formatInbox(inbox)} ${formatInbox(inbox)}
## Session Context <context>
${stringify(dynamicHeaders)}
--- </context>
${Bun.YAML.stringify(dynamicHeaders)}
---
Context window covers the last ${maxContextLoadTime} minutes (${(maxContextLoadTime / 60).toFixed(2)} hours). Context window covers the last ${maxContextLoadTime} minutes (${(maxContextLoadTime / 60).toFixed(2)} hours).
+3
View File
@@ -142,6 +142,9 @@ importers:
typescript: typescript:
specifier: ^5 specifier: ^5
version: 5.9.3 version: 5.9.3
yaml:
specifier: ^2.8.2
version: 2.8.2
zod: zod:
specifier: ^4.3.6 specifier: ^4.3.6
version: 4.3.6 version: 4.3.6