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/10-parallelizing.md

View on GitHub
# 模式 ⑩ Parallelizing (并行工作流)

> 同一任务的多个子任务并发执行,大幅减少端到端延迟
> 延迟 max(子任务) · 可预测性 ★★★★☆ · 适合可独立并行的子任务

## 核心理念

将一个请求拆成 N 个独立子任务,并发执行后合并结果。
总延迟 = max(子任务延迟),而非 sum(子任务延迟)。

两种变体:
1. **Sectioning** — 不同子任务做不同事情(分工)
2. **Voting** — 多个子任务做同一件事,投票取最优(冗余)

## 适用场景

### Sectioning (分工)
- 多维度分析(同时分析情感/主题/实体)
- 多数据源查询(同时查订单/商品/物流)
- 多格式生成(同时生成摘要/标题/标签)

### Voting (投票)
- 意图分类置信度增强(3 个模型投票)
- 内容安全检测(多检测器并行)
- 翻译质量(多翻译取最优)

## 实现

```typescript
// Sectioning — 不同 prompt 不同任务
async function parallelSection(
  input: string,
  sections: { id: string; prompt: string; model?: string }[],
): Promise<Record<string, string>> {
  const results = await Promise.all(
    sections.map(async (section) => {
      const response = await llm.chat({
        model: section.model ?? 'gpt-4o-mini',
        messages: [{ role: 'user', content: `${section.prompt}\n\n输入: ${input}` }],
        temperature: 0,
      });
      return [section.id, response.content] as const;
    }),
  );
  return Object.fromEntries(results);
}

// Voting — 同一 prompt 多次执行
async function parallelVote<T>(
  input: string,
  prompt: string,
  models: string[],
  aggregator: (results: string[]) => T,
): Promise<T> {
  const results = await Promise.all(
    models.map(async (model) => {
      const response = await llm.chat({
        model,
        messages: [{ role: 'user', content: `${prompt}\n\n${input}` }],
        temperature: 0,
      });
      return response.content;
    }),
  );
  return aggregator(results);
}
```

## 示例: 商品描述多维生成

```typescript
const productDescription = await parallelSection(productData, [
  { id: 'title', prompt: '生成一句吸引人的商品标题 (≤20字)' },
  { id: 'highlights', prompt: '提取 3-5 个卖点,每个 ≤15字' },
  { id: 'description', prompt: '写一段 100-200 字的商品描述' },
  { id: 'tags', prompt: '生成 5 个 SEO 标签,JSON数组格式' },
]);

// 总延迟 ≈ 单次 LLM 调用,而非 4 倍
```

## 示例: 意图分类投票

```typescript
const classificationResult = await parallelVote(
  userInput,
  intentClassificationPrompt,
  ['gpt-4o-mini', 'claude-haiku', 'qwen-turbo'],
  (results) => {
    const parsed = results.map(r => JSON.parse(r));
    // 多数投票
    const intentCounts = new Map<string, number>();
    for (const r of parsed) {
      intentCounts.set(r.intent, (intentCounts.get(r.intent) ?? 0) + 1);
    }
    // 返回得票最多的意图
    return [...intentCounts.entries()].sort((a, b) => b[1] - a[1])[0][0];
  },
);
```

## 注意事项

- 子任务必须**真正独立**,不能有数据依赖
- 并发数受 API rate limit 约束,需要限流器
- Voting 模式的成本 = N 倍,仅用于高价值决策
- 失败处理: 使用 `Promise.allSettled` 容忍部分失败
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