agentsclimarketplace

Preference

Skill Makiato1999/agentic-travel/.claude/skills/preference

An LLM-powered multi-agent business travel planning system that integrates RAG knowledge retrieval, user preference memory, real-time information querying, and itinerary generation.

Install
npx -y skills add Makiato1999/agentic-travel --skill preference

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use this skill when the user states or updates their preferences, e.g. hotel brands, airlines, home location, seat preference. Triggers when user says "我喜欢住汉庭", "我还喜欢如家", "我搬家到上海了", "我常坐东航". This skill uses PreferenceAgent and requires a MemoryManager to persist preferences; when used standalone, apply returned preferences via memory_manager.long_term.save_preference.

SKILL.md

6.3 KB, ~1.8k tokens by cl100k_base, as published. Nobody here has run it

Preference (偏好管理)

识别用户偏好并支持追加(还、也)与覆盖(搬家到、改成)。使用 PreferenceAgent。持久化由 MemoryManager 完成:在协调器流程中由协调器写回;单独调用时需根据返回的 preferences 列表自行调用 memory_manager.long_term.save_preference()

When to Use

  • 用户说「我喜欢XX」「我还喜欢XX」「我搬家到XX」「我常坐东航」等

Agent

  • PreferenceAgent (agents/preference_agent.py)
  • 入参:modelmemory_manager(用于读取当前偏好;写回由协调器或调用方完成)
  • 异步reply()async,需 await

行为

  • append:识别「还」「也」等,在已有列表上追加
  • replace:识别「搬家到」「改成」等,覆盖原值
  • 偏好类型:hotel_brands, airlines, home_location, seat_preference, meal_preference, budget_level 等,支持自定义

复合任务处理

  • 如果用户一句话中同时包含偏好表达其他任务(如天气查询、知识库问答、行程规划、历史查询),只提取偏好相关内容,忽略非偏好部分
  • 不要因为句子里出现了出发地、目的地、天气、报销、规划等内容,就放弃提取偏好
  • 典型复合表达:
    • 「我常住苏州,喜欢高铁和安静酒店。下周我要去成都出差,帮我查天气并规划行程」
    • 该句中,本 skill 只输出偏好:home_location=苏州transportation_preference=高铁accommodation_preference=安静酒店

初始化与调用

import asyncio
import json
from agentscope.message import Msg
from agentscope.model import OpenAIChatModel
from config_agentscope import init_agentscope
from config import LLM_CONFIG
from context.memory_manager import MemoryManager
from agents.preference_agent import PreferenceAgent

async def save_preference(user_query: str, user_id: str = "default_user", session_id: str = "default"):
    init_agentscope()
    model = OpenAIChatModel(
        model_name=LLM_CONFIG["model_name"],
        api_key=LLM_CONFIG["api_key"],
        client_kwargs={"base_url": LLM_CONFIG["base_url"], "timeout": 60},
        temperature=LLM_CONFIG.get("temperature", 0.7),
        max_tokens=LLM_CONFIG.get("max_tokens", 2000),
    )
    memory_manager = MemoryManager(user_id=user_id, session_id=session_id, llm_model=model)
    agent = PreferenceAgent(name="PreferenceAgent", model=model, memory_manager=memory_manager)
    user_msg = Msg(name="user", content=user_query, role="user")
    result = await agent.reply(user_msg)
    data = json.loads(result.content) if isinstance(result.content, str) else result.content
    if data.get("has_preferences") and data.get("preferences"):
        for item in data["preferences"]:
            pref_type = item.get("type")
            value = item.get("value")
            action = item.get("action", "replace")
            current = memory_manager.long_term.get_preference().get(pref_type)
            if action == "append" and isinstance(current, list):
                memory_manager.long_term.save_preference(pref_type, current + [value])
            else:
                memory_manager.long_term.save_preference(pref_type, value)
    return data

# 使用
data = asyncio.run(save_preference("我还喜欢如家"))
# data: {"preferences": [{"type": "hotel_brands", "value": "如家", "action": "append"}], "has_preferences": true}

返回格式

  • preferences: 列表,每项 { "type", "value", "action": "append"|"replace" }
  • has_preferences: bool

偏好提取规则

【任务说明】 你需要判断用户的意图:

  1. 追加(append):用户想在已有偏好基础上增加新的选项

    • 关键词:「还」、「也」、「另外」、「以及」
    • 示例:"我还喜欢汉庭" → 追加到 hotel_brands
    • 示例:"我也常坐东航" → 追加到 airlines
  2. 覆盖(replace):用户想更新/替换原有的偏好

    • 关键词:「搬家到」、「改成」、「现在是」、「换成」
    • 示例:"我搬家到上海了" → 覆盖 home_location
    • 示例:"我现在喜欢靠窗座位" → 覆盖 seat_preference
  3. 首次设置:用户第一次提及某个偏好

    • 如果当前偏好中没有这个字段,默认使用 replace

【常见偏好类型】

  • home_location: 家庭地址/常住地
  • hotel_brands: 酒店品牌偏好
  • airlines: 航空公司偏好
  • seat_preference: 座位偏好
  • meal_preference: 餐食偏好
  • budget_level: 预算等级
  • transportation_preference: 交通偏好
  • food_preference: 美食偏好
  • accommodation_preference: 住宿环境偏好(如安静、离地铁近、安全性高) (支持自定义新的偏好类型)

【偏好识别提示】

  • 「更喜欢高铁而不是飞机」→ transportation_preference
  • 「不吃辣」→ food_preference
  • 「酒店希望安静一些」→ accommodation_preference
  • 「更关注酒店安全」→ accommodation_preference
  • 「预算不要太高」→ budget_level
  • 「离地铁近一点」→ accommodation_preference

【输出格式】(严格JSON) {{ "preferences": [ {{ "type": "hotel_brands", "value": "汉庭", "action": "append" }}, {{ "type": "home_location", "value": "上海浦东新区", "action": "replace" }} ], "has_preferences": true }}

【重要规则】

  1. action 只能是 "append" 或 "replace"
  2. 根据用户的语气和上下文判断 action
  3. 如果用户使用「还」、「也」等词,使用 append
  4. 如果用户使用「搬家」、「改成」等词,使用 replace
  5. 如果是首次提及,使用 replace
  6. 如果用户一句话中混有多个任务,优先从中提取偏好片段,不要因为存在其他任务而返回空
  7. 如果用户未提及任何偏好,返回 {{"preferences": [], "has_preferences": false}}

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.