设计 Agent 系统提示词、上下文结构或按需加载的 Skill 时使用——覆盖 API 消息角色与「静态前缀 + 轨迹」结构、系统提示词写法(结构化、SOP、业务规则细化、few-shot)、Agent Skills 渐进式披露与 SKILL.md 编写、提示注入的上下文层防御,以及注意力位置偏好等布局原则。
83%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
上下文是 Agent 在每个决策点实际「看到」的全部信息:系统提示词、工具定义、用户消息、模型回复、工具执行结果。上下文工程就是系统性设计、组织、供给这些信息——模型智力只是基础,上下文质量才是 Agent 能力的真正关键。一个中等能力的模型配上精心组织的上下文,往往胜过一个顶级模型在信息匮乏下的盲目摸索。
SKILL.md(元数据、路由描述、正文分层)tools 字段。 system(开发者规则,通常只有一条且在最前)、user(终端用户输入)、assistant(模型回复含 tool_calls)、tool(框架执行结果,靠 tool_call_id 与调用关联);工具定义走请求顶层 tools 字段,不是消息角色。You MUST answer concisely with fewer than 4 lines;无法完成任务时 keep your response to 1-2 sentences 且不要解释为什么不能做。大写(NEVER do X)比 Please avoid doing X 更能引起注意,但过度使用会稀释效果,只留给真正关键的约束。#、##)提供人可读的层次,XML 标签提供机器可解析的精确语义(<file_operation>、<network_request>),标签名本身携带语义。双层配合:Markdown 管组织逻辑,XML 管语义边界。NEVER use percentage_based_one_time for refunds and service cancellations. Use fixed_fee instead.;成功率阈值直接映射到行为(>60% 可退款、<30% 拒绝任务);计费粒度写死(每分钟 $0.05,汇总四舍五入到整数美元),并明确「节省」只基于现有账单计算。提示词由产品经理基于线上数据设计,工程师负责准确编码,不擅自决定业务逻辑。SKILL.md 顶部 YAML frontmatter 的 name + description,在正文加载前对 Agent 可见,用于路由判断。description 要写得像路由条件而非功能介绍:明确「何时使用」「何时不使用」的边界,给几条典型反例。写 help with backend 这种宽泛描述等于任何后端工作都能触发,路由必然失准。SKILL.md(斜杠命令由客户端本地拦截展开;模型自主触发则多一次 ReAct 往返,正文作为 user message 追加)。html2pptx.md、reference.md),Agent 按需选择性深入。stable_prefix = system_message # 定了就不改
stable_tools = core_tool_schemas # 固定顺序
trajectory = load_message_history(session)
status_message = make_status_message(derive_current_state(trajectory))
if estimated_tokens(stable_prefix, trajectory, status_message) > budget:
trajectory = compress_old_evidence(
trajectory, preserve=[decisions, constraints, failures, citations]
)
request.messages = [stable_prefix] + trajectory + [status_message]
request.tools = stable_tools第一道防线是帮模型分清「指令」与「数据」:
<external_content source="webpage">...</external_content> 包裹并标注来源。kv-cache-design)。chapter1/context/ — 多 provider 上下文感知 Agent,消融实验 1-1 对比 full / no history / no reasoning / no tool calls / no tool results 五种上下文模式。chapter2/prompt-engineering/ — 实验 2-4:基于 Tau-Bench 的提示工程消融框架,量化语气风格、指令组织、工具描述三个维度对任务完成率的影响。book/chapter2.md「上下文:决定 Agent 能力上限的关键」book/chapter2.md「Agent 如何调用大模型:理解 API 的上下文结构」book/chapter2.md「提示工程:优化系统提示词」book/chapter2.md「动态提示词与 Agent Skills」bojieli/ai-agent-book
dbc046e
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.