pref0 — Preference Learning for AI Agents
You have access to the pref0 API. It learns user preferences from conversations and serves them back at inference time. The more conversations you track, the better it gets.
When to use this skill
After a conversation ends → Track it
After finishing a conversation (or at natural breakpoints), send the messages to pref0 so it can extract preferences. This is especially valuable when the user corrects you (e.g., "use pnpm, not npm") or states explicit preferences (e.g., "always use metric units").
Before responding to a user → Fetch their preferences
Before generating a response, fetch the user's learned preferences and follow them. This prevents the user from having to repeat themselves across sessions.
API Reference
Base URL: https://api.pref0.com
Auth: INLINECODE1
Track a conversation (POST /v1/track)
Send a conversation so pref0 can learn from it. It extracts corrections, explicit preferences, and behavioral patterns automatically.
CODEBLOCK0
Response:
CODEBLOCK1
The response tells you how many messages were processed (messagesAnalyzed) and exactly what changed: created (new preference learned), reinforced (existing preference seen again, confidence increased), decreased (user retracted, confidence lowered), removed (fully retracted and deleted).
Get learned preferences (GET /v1/profiles/:userId)
Retrieve the user's learned preference profile. Use ?minConfidence=0.5 to only get well-learned preferences suitable for system prompt injection.
CODEBLOCK2
Response:
CODEBLOCK3
Each preference includes evidence (the quote that triggered extraction), firstSeen (when first learned), and lastSeen (when last reinforced). The prompt field is a ready-to-use string you can append directly to your system prompt.
Delete a user profile (DELETE /v1/profiles/:userId)
Reset a user's learned preferences. Use for preference resets or data deletion requests.
CODEBLOCK4
Returns 204 No Content.
How to integrate into your workflow
- 1. Identify the user. Use a stable user ID (email, account ID, phone number — whatever you have).
- 2. At the start of a session, fetch preferences:
- Call
GET /v1/profiles/{userId}?minConfidence=0.5
- Use the
prompt field to inject into your system prompt directly, or use the structured
preferences array for more control.
- 3. At the end of a session, track the conversation:
- Call
POST /v1/track with the full message history
- pref0 handles extraction and confidence scoring automatically
- 4. Preferences compound over time. Corrections start at 0.70 confidence, implied preferences at 0.40. Each repeated signal adds +0.15, capped at 1.0.
Confidence guide
| Signal type | Starting confidence | Example |
|---|
| Explicit correction | 0.70 | "Use Tailwind, not Bootstrap" |
| Implied preference |
0.40 | "Deploy it to Vercel" |
| Behavioral pattern | 0.30 | User consistently wants short replies |
| Each repeat | +0.15 | Same preference across sessions |
Setup
- 1. Sign up at pref0.com
- Create an API key in the dashboard
- Set the
PREF0_API_KEY environment variable - First 100 requests/month are free, then $5 per 1,000 requests
pref0 — AI代理的偏好学习
你可以访问pref0 API。它能从对话中学习用户偏好,并在推理时提供这些偏好。你追踪的对话越多,效果就越好。
何时使用此技能
对话结束后 → 追踪对话
在完成对话后(或在自然断点处),将消息发送给pref0,以便它提取偏好。当用户纠正你(例如使用pnpm,不要用npm)或明确表达偏好(例如始终使用公制单位)时,这一点尤其有价值。
回复用户前 → 获取他们的偏好
在生成回复之前,获取用户已学习的偏好并遵循它们。这可以防止用户在不同会话中重复表达相同的内容。
API参考
基础URL: https://api.pref0.com
认证: Authorization: Bearer $PREF0APIKEY
追踪对话(POST /v1/track)
发送对话以便pref0从中学习。它会自动提取纠正、明确偏好和行为模式。
bash
curl -X POST https://api.pref0.com/v1/track \
-H Authorization: Bearer $PREF0APIKEY \
-H Content-Type: application/json \
-d {
userId: <用户ID>,
messages: [
{ role: user, content: 帮我设置一个新项目 },
{ role: assistant, content: 这里是一个使用npm和JavaScript的项目... },
{ role: user, content: 使用pnpm,不要用npm。并且用TypeScript。 },
{ role: assistant, content: 已更新为pnpm和TypeScript... }
]
}
响应:
json
{
messagesAnalyzed: 4,
preferences: { created: 2, reinforced: 0, decreased: 0, removed: 0 },
patterns: { created: 1, reinforced: 0 }
}
响应告诉你处理了多少条消息(messagesAnalyzed)以及具体变化:created(学习到的新偏好)、reinforced(再次看到已有偏好,置信度提高)、decreased(用户撤回,置信度降低)、removed(完全撤回并删除)。
获取已学习的偏好(GET /v1/profiles/:userId)
检索用户已学习的偏好配置文件。使用?minConfidence=0.5仅获取适合注入系统提示的、学习充分的偏好。
bash
curl https://api.pref0.com/v1/profiles/<用户ID>?minConfidence=0.5 \
-H Authorization: Bearer $PREF0APIKEY
响应:
json
{
userId: user_abc123,
preferences: [
{
key: language,
value: typescript,
confidence: 0.85,
evidence: 用户说:使用TypeScript,不要用JavaScript,
firstSeen: 2026-01-15T10:00:00.000Z,
lastSeen: 2026-02-05T14:30:00.000Z
},
{
key: package_manager,
value: pnpm,
confidence: 0.85,
evidence: 用户说:使用pnpm代替npm,
firstSeen: 2026-01-15T10:00:00.000Z,
lastSeen: 2026-02-03T09:15:00.000Z
},
{
key: css_framework,
value: tailwind,
confidence: 0.70,
evidence: 用户说:使用Tailwind,不要用Bootstrap,
firstSeen: 2026-01-20T16:45:00.000Z,
lastSeen: 2026-01-20T16:45:00.000Z
}
],
patterns: [
{ pattern: 偏好明确的工具选择而非默认值, confidence: 0.60 }
],
prompt: 以下偏好是从该用户之前的对话中学习到的。除非明确告知,否则请遵循这些偏好:\n- language: typescript\n- packagemanager: pnpm\n- cssframework: tailwind\n\n观察到的行为模式:\n- 偏好明确的工具选择而非默认值
}
每个偏好都包含evidence(触发提取的引用)、firstSeen(首次学习时间)和lastSeen(最后强化时间)。prompt字段是一个可直接追加到系统提示中的即用字符串。
删除用户配置文件(DELETE /v1/profiles/:userId)
重置用户已学习的偏好。用于偏好重置或数据删除请求。
bash
curl -X DELETE https://api.pref0.com/v1/profiles/<用户ID> \
-H Authorization: Bearer $PREF0APIKEY
返回204 No Content。
如何集成到你的工作流程中
- 1. 识别用户。 使用稳定的用户ID(电子邮件、账户ID、电话号码——你拥有的任何标识)。
- 2. 在会话开始时,获取偏好:
- 调用GET /v1/profiles/{userId}?minConfidence=0.5
- 使用prompt字段直接注入到系统提示中,或使用结构化的preferences数组进行更精细的控制。
- 3. 在会话结束时,追踪对话:
- 调用POST /v1/track,传入完整的消息历史记录
- pref0会自动处理提取和置信度评分
- 4. 偏好会随时间累积。 纠正的初始置信度为0.70,隐含偏好为0.40。每次重复信号增加+0.15,上限为1.0。
置信度指南
| 信号类型 | 初始置信度 | 示例 |
|---|
| 明确纠正 | 0.70 | 使用Tailwind,不要用Bootstrap |
| 隐含偏好 |
0.40 | 部署到Vercel |
| 行为模式 | 0.30 | 用户始终希望简短回复 |
| 每次重复 | +0.15 | 跨会话的相同偏好 |
设置
- 1. 在pref0.com注册
- 在控制面板中创建API密钥
- 设置PREF0API_KEY环境变量
- 每月前100次请求免费,之后每1,000次请求收费5美元