核心项目
Swarm 多智能体 DAG 编排,意图解析双层架构,自适应团队组建。代码量最大、踩坑最多的项目。7 个 Agent 听起来很酷,实际上意图解析链路太长、错误层层放大。砍到 3 个核心 Agent + 工具调用,反而更稳定。
class SwarmEngine:
"""Swarm 编排主引擎"""
_AGENT_CN_NAMES = {
"fundamental": "基本面分析师",
"technical": "技术分析师",
"risk": "风控专家",
"synthesizer": "首席策略师",
}
架构踩坑
7 个 Agent 协作听起来很酷,实际上意图解析链路太长、错误层层放大。砍到 3 个核心 Agent + 工具调用,反而更稳定。少即是多。
class ExecutionMode(Enum):
DIRECT_LLM = "direct_llm"
TOOL_CALLING = "tool_calling"
SUBAGENT_ASYNC = "subagent_async"
EXPERT_INVOKE = "expert_invoke"
SKILL_INVOKE = "skill_invoke"
实战技巧
Prompt Engineering 被吹得很玄,但真正的难点不在 prompt,而在:怎么拆解任务、怎么定义工具接口、怎么处理 LLM 的不确定性。这跟管理一个聪明但粗心的实习生很像。
# LLM 输出不可靠 — 必须用 Pydantic 严格校验
class IntentResult(BaseModel):
mode: ExecutionMode
tools: list[str]
confidence: float = Field(ge=0, le=1)
# 不要信任任何 LLM 的格式输出
工程实战
FinBuddy_Web 的 LLM 代理服务、Promo_Web 的 Skill 组合引擎、SkillStore 的自动分类、Basic_Web 的通用脚手架。从零搭建,持续迭代。
# Promo — Skill 四层组合机制
# framework → style → adapter → enhancer
def assemble_prompt(self, product, persona,
framework_skill, style_skill,
adapter_skill, enhancer_skills):
variables = {
"product_name": product.name,
"selling_points": "、".join(product.selling_points),
}
Vibe Coding
用 AI 辅助编程的实战心得:什么时候让 AI 写、Cursor 对话坏习惯、AI 代码 review 方法。包括失败案例——不是每次 Vibe Coding 都能成功。