协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
parallel-skill-runner【开发与工程】Implements intelligent parallel skill runner with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: parallel-skill-runner compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for parallel skill runner workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.
┌───────────────────────────────────────────────────────────────────────────────┐ │ Orchestration Flow │ └───────────────────────────────────────────────────────────────────────────────┘
User Request ↓ ┌─────────────────┐ │ Parse Request │ │ & Extract │ │ Features │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Evaluate Available Skills │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Skill A │ │ Skill B │ │ Skill C │ │ │ │ - Match Score│ │ - Match Score│ │ - Match Score│ │ │ │ - Confidence │ │ - Confidence │ │ - Confidence │ │ │ │ - History │ │ - History │ │ - History │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ └─────────────────┴─────────────────┘ │ │ ↓ │ │ Select Best Skill │ └─────────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────┐ │ Execute Skill │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Handle Result │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Error Handling & Fallback │ │ │ │ Success? ────────► Return Result │ │ │ │ Fail? ────────┐ │ │ ↓ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ Fallback Chain │ │ │ │ │ │ │ │ 1. Retry with adjusted parameters │ │ │ │ 2. Try Alternative Skill (if available) │ │ │ │ 3. Defer to Human Operator (if critical) │ │ │ │ 4. Log & Return Error │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
Parse and Analyze Request - Extract intent, entities, and constraints from user input. Checkpoint: All required parameters must be present and in valid format before proceeding.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
def evaluate_parallel_candidates(
task: str,
candidate_skills: List[SkillMetadata],
historical_registry: Dict[str, HistoricalRecord]
) -> List[RankedSkill]:
"""Score and rank skills for parallel dispatch based on multi-factor metrics.
Applies Law 2 (Parse at boundary) by validating inputs upfront.
Returns immutable ranked list for deterministic routing.
"""
if not task or not candidate_skills:
raise ValueError("Task and candidate_skills must be non-empty")
parsed_task = _parse_intent_and_entities(task)
ranked = []
for skill in candidate_skills:
if not _is_skill_available(skill):
continue
text_match = _cosine_similarity(parsed_task.terms, skill.trigger_terms)
history = historical_registry.get(skill.id, HistoricalRecord())
success_rate = history.success_count / max(history.total_runs, 1)
availability_score = _get_current_load_score(skill.endpoint)
composite_score = (0.4 * text_match) + (0.4 * success_rate) + (0.2 * availability_score)
ranked.append(RankedSkill(
skill=skill,
confidence=composite_score,
expected_latency_ms=_estimate_latency(skill, parsed_task)
))
ranked.sort(key=lambda x: x.confidence, reverse=True)
return ranked
async def run_parallel_with_fallback(
ranked_skills: List[RankedSkill],
task_context: Dict,
fallback_map: Dict[str, List[str]],
timeout_seconds: float = 30.0
) -> ParallelExecutionResult:
"""Execute top N skills in parallel with per-skill fallback chains.
Implements Law 4 (Fail Fast/Loud) by isolating failures and applying fallbacks.
Returns aggregated results without mutating original context.
"""
if not ranked_skills:
raise ParallelExecutionError("No skills available for parallel execution")
selected = ranked_skills[:3] # Execute top 3 in parallel
tasks = []
for ranked in selected:
tasks.append(_execute_single_skill_with_fallback(
skill=ranked.skill,
context=task_context,
fallback_chain=fallback_map.get(ranked.skill.id, []),
timeout=timeout_seconds
))
results = await asyncio.gather(*tasks, return_exceptions=True)
aggregated = ParallelExecutionResult(
success_count=0,
failed_count=0,
results=[],
fallbacks_triggered=[]
)
for ranked, result in zip(selected, results):
if isinstance(result, Exception):
aggregated.failed_count += 1
aggregated.fallbacks_triggered.append(ranked.skill.id)
else:
aggregated.success_count += 1
aggregated.results.append(result)
return aggregated
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
agent-confidence-based-selector | Provides the confidence-based selection layer that this parallel runner orchestrates across multiple candidates |
agent-task-routing | Handles sequential task routing — use this when tasks must be ordered rather than parallelized |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.