Skip to content

northseadl/norix-skills / llm-agent-dev

llm-agent-dev

Unverified

LLM Agent engineering: pattern selection (12-mode matrix), data simulation, convergence iteration. Covers intent routing, function calling, ReAct, MCP, prompt chaining, guardrails, evaluation.

FileKindSize
SKILL.mdskill md17.6 KB
agents/openai.yamlconfig198 B
evals/evals.jsonconfig4.7 KB
references/convergence/iteration-protocol.mdmarkdown8.0 KB
references/eval-loop.mdmarkdown9.4 KB
references/feedback-protocol.mdmarkdown6.0 KB
references/intent-patterns.mdmarkdown5.8 KB
references/paradigms/context-engineering.mdmarkdown6.0 KB
references/paradigms/decision-tree.mdmarkdown2.7 KB
references/paradigms/memory-architecture.mdmarkdown4.0 KB
references/paradigms/observability.mdmarkdown4.5 KB
references/paradigms/pattern-matrix.mdmarkdown3.3 KB
references/paradigms/performance-benchmarking.mdmarkdown15.2 KB
references/paradigms/prompt-patterns.mdmarkdown5.0 KB
references/paradigms/safety-guardrails.mdmarkdown5.5 KB
references/paradigms/tool-design.mdmarkdown2.5 KB
references/patterns/01-crex-rule-router.mdmarkdown6.8 KB
references/patterns/02-slot-filling.mdmarkdown7.1 KB
references/patterns/03-function-calling.mdmarkdown3.9 KB
references/patterns/04-workflow-agent.mdmarkdown5.0 KB
references/patterns/05-react-agent.mdmarkdown3.4 KB
references/patterns/06-router-expert.mdmarkdown3.2 KB
references/patterns/07-mcp-tool-protocol.mdmarkdown5.0 KB
references/patterns/08-handoff-delegation.mdmarkdown4.7 KB
references/patterns/09-prompt-chaining.mdmarkdown3.0 KB
references/patterns/10-parallelizing.mdmarkdown3.2 KB
references/patterns/11-orchestrator-worker.mdmarkdown4.8 KB
references/patterns/12-evaluator-optimizer.mdmarkdown5.5 KB
references/scenarios/coding-assistant.mdmarkdown2.0 KB
references/scenarios/content-generation.mdmarkdown2.7 KB
references/scenarios/customer-service.mdmarkdown2.6 KB
references/scenarios/ecommerce-shopping.mdmarkdown4.2 KB
references/scenarios/food-ordering.mdmarkdown3.1 KB
references/scenarios/knowledge-qa.mdmarkdown2.6 KB
references/simulation/data-generation.mdmarkdown8.1 KB
references/skill-templates.mdmarkdown8.0 KB

references/patterns/05-react-agent.md

View on GitHub
# 模式 ⑤ ReAct Agent (推理-行动循环)

> LLM 在 Thought → Action → Observation 循环中自主推理和执行
> 延迟 3-15s · 可预测性 ★★☆☆☆ · 适合开放式复杂任务

## 适用场景

- 研究调查("帮我比较这三款套餐的性价比")
- 代码生成和调试
- 数据分析("分析最近一个月的销售趋势")
- 自由式问答(知识库检索 + 综合推理)

## 不适用信号

- 延迟 < 3s 的硬需求 → ① CREX 或 ② Slot
- 流程固定,无需推理 → ④ Workflow
- 需要前端实时渲染 → ①② + 异步 ReAct

## 核心循环

```
Thought: 我需要查询这三款套餐的详细信息
Action:  tool=query_products, args={ids: ["A", "B", "C"]}
Observation: [{name: "套餐A", price: 299, ...}, ...]

Thought: 现在我需要从多个维度进行比较分析
Action:  tool=analyze, args={products: [...], dimensions: ["价格", "内容", "评分"]}
Observation: {comparison_table: [...]}

Thought: 我已经有了完整对比,可以生成推荐了
Action:  tool=finish, args={result: "综合分析结果..."}
```

## 实现

```typescript
interface ReActConfig {
  model: string;           // 推荐用较强模型: "sonnet", "gpt-4o"
  tools: ToolDefinition[];
  maxIterations: number;   // 防无限循环: 建议 5-10
  systemPrompt: string;
}

class ReActAgent {
  constructor(private config: ReActConfig) {}

  async run(input: string, context: AgentContext): Promise<SkillResponse> {
    const messages: Message[] = [
      { role: 'system', content: this.config.systemPrompt },
      { role: 'user', content: input },
    ];

    for (let i = 0; i < this.config.maxIterations; i++) {
      const response = await llm.chat({
        model: this.config.model,
        messages,
        tools: this.config.tools,
      });

      // LLM 决定结束
      if (!response.tool_calls?.length) {
        return { type: 'text', content: response.content, actions: [], followUp: null };
      }

      // 执行工具
      for (const call of response.tool_calls) {
        const result = await this.executeTool(call, context);
        messages.push({ role: 'assistant', content: '', tool_calls: [call] });
        messages.push({ role: 'tool', tool_call_id: call.id, content: JSON.stringify(result) });
      }
    }

    return { type: 'error', content: '推理超过最大步数限制', actions: [], followUp: null };
  }
}
```

## 与轻量模式的混合

ReAct 延迟高,通常不直接面向用户。推荐模式:

```
用户输入 → CREX 路由 ─── 简单意图 ──→ 确定性执行 (< 1s)
                      │
                      └── 复杂意图 ──→ 返回 "正在分析中..."
                                        │
                                        └──→ [后台 ReAct Agent]
                                              │
                                              └──→ 完成后推送结果
```

```typescript
const complexAnalysisSkill: SkillHandler = {
  id: 'analysis.complex', name: '深度分析',
  async execute(params, context) {
    // 异步触发 ReAct
    await taskQueue.enqueue('react_analysis', { params, context });

    return {
      type: 'text',
      content: '正在为您深度分析,完成后会通过消息通知您',
      actions: [{ label: '查看进度', action: 'navigate', target: '/tasks/latest' }],
      followUp: null,
    };
  }
};
```
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall