Skill / Tool / Agent / Model / Inference 全流程
用户请求
- 自然语言输入
- 文件 / 资源 / 当前状态
Capability / Skill Discovery
- Skill Registry
- Tool Registry
- MCP / API
- Rule + Retrieval + LLM Rerank
Skill Loading
- Metadata 先可见
- 触发后读取 SKILL.md
- 按需读取 references / scripts / templates
Build Main Context
- system
- conversation
- state
- skills
- tool schemas
- retrieved docs
Model API
- messages
- tools
- schema / response format
Model Serving
- Tokenize
- Forward Pass
- Logits
- Sampling
- Constrained Decoding
Parser / SDK
- Text / Tool Call / Structured Output
- 解析成 Action
Runtime Validation
- Schema
- Business Rules
- Permission
- Approval
Branch Execution
- load_skill
- tool_call
- ask_user
- message
- finish
Verification
- 结果验证
- 失败则 repair / retry
Final Output
- 答案
- 文件
- 报告
- PPT / Summary
1. Skill System:Skill 到底由什么组成
财务分析
证据型研究
演示文稿生成
PDF 处理
法律审阅
代码审阅
任务目标
执行步骤 / SOP
约束 / 禁止事项
什么时候、如何使用 Tool
输出规范
失败时怎么办
模板
Few-shot / 示例
可执行脚本
领域知识
校验表
风格规范
2. Skill Discovery / Capability Discovery
用户请求
Conversation
State Summary
权限 / 当前环境
Skill Registry
Tool Registry
MCP Servers / APIs
Docs / Resources
Keyword / Regex
Rule Routing
Embedding Search
Semantic Retrieval
Permission Filter
Policy Filter
LLM Rerank
Top-K Selection
False Negative
False Positive
Routing Policy
3. Skill Loading / Context Engineering
| Loading 目标 | 风险 | 控制手段 |
|---|---|---|
| 给模型正确的信息 | 加载过少 | 补充 references / tool docs / retrieved data |
| 控制 Context Budget | 加载过多 | 按需、分阶段、摘要、卸载 |
| 减少冲突 | Skill / system / style 指令冲突 | 优先级、scope、阶段切换 |
4. Agent 调用模型:Model API / Serving Interface
普通自然语言回答
工具名 + arguments
符合 schema 的结构化对象
拒绝、异常、停止原因
5. Model Serving Stack / Inference Engine
6. Structured Output:Schema、Prompt、Constrained Decoding 的区别
只是提高合法输出概率
仍可能输出额外文本、缺字段、格式错误
字段、类型、enum、required 等
模型理解“应该填什么”
生成到当前位置时,只允许 grammar 合法 token
非法 token 概率被置零 / 屏蔽
7. Tool Calling / Action:模型输出如何变成 Runtime 指令
执行外部工具
动态读取 Skill 内容
请求补充信息
普通模型消息
进入最终输出阶段
8. Agent Runtime:Execution Loop
用户输入 / Tool Result / Files / State
装配 system + skills + state + tools + docs
请求 Model API / Serving Stack
解析 tool_call / load_skill / finish ...
schema / business / policy / approval
执行 Tool、加载 Skill、追问、结束
保存工具结果、文件、已完成步骤、phase
失败恢复、重试、降级、异常处理
重新 Observe → Build Context → Call Model
9. Runtime Validation:为什么“结构正确”还不够
| 层 | 检查什么 | 例子 | 负责者 |
|---|---|---|---|
| 1. Syntax / Schema | 字段、类型、必填项 | amount 必须是 number | Decoder / SDK / Runtime |
| 2. Business Validation | 参数是否业务上合理 | 退款金额不能超过订单金额 | Runtime / Business Logic |
| 3. Permission / Policy | 是否允许执行 | 用户是否有权删除文件 | Runtime |
| 4. Approval | 敏感动作是否需要确认 | 发送邮件 / 金钱操作 | Runtime + Human |
| 5. Execution Guard | timeout / retry / idempotency | API 超时后能否安全重试 | Runtime |
Structural Reliability
Reasoning Reliability
Execution Reliability
10. Tools / External Systems / MCP
公开网页检索
网站交互
读取 / 写入文件
文档处理
代码运行
查询 / 写入数据
消息 / 日历动作
暴露 tools / resources / prompts
CRM / ERP / 内部 API
确定性计算
Skill
SOP / workflow / knowledge
Tool
API / function / external action
Runtime
state / retry / permission / validation
11. Final Verification / Completion
任务是否完成
核心结论是否覆盖
数字 / 结论 / 引用是否一致
文件是否存在
格式 / 页面 / 布局是否正确
是否满足权限 / 审批 / 输出约束
进入 Final Answer / File / Report / PPT / Summary
Repair / Retry / Re-run Tool / Reload Context
Ask User → 获取补充信息 → 回到 Build Context
12. 全栈责任边界:到底是谁在负责什么
| 层 | 主要职责 | 典型内容 |
|---|---|---|
| Skill | 方法 / SOP / 知识 | 什么时候用、怎么做、步骤、规则、工具指南、输出格式 |
| Discovery | 找到能力 | Registry、Retrieval、Routing、Rerank、Permission Filter |
| Loading / Context | 给模型看什么 | Progressive Disclosure、Just-in-time、Context Budget、Task Scope |
| LLM | 理解 / 推理 / 选择 | 判断任务、选 Tool、决定参数内容、生成语言 |
| Inference Engine | 运行模型 / 生成 token | forward pass、logits、sampling、KV cache、constrained decoding |
| Agent Runtime | 执行 / 调度 / 控制 | Action 解析、state、workflow、tool execution、retry、approval、validation |
| Tool / External System | 真正操作外部世界 | Search、Browser、Files、DB、Email、MCP、API、Code |
| Verification | 保证任务完成 | 结果检查、文件检查、引用检查、修复 / 重试 |