Cross Task Learner 标志

Cross Task Learner

社区
jmagly
cross-task-learner

Enable agent loops to learn from similar past tasks and share patterns across loops

概览

发布者jmagly
代码仓库aiwg
技能名称cross-task-learner
星标数
225
复刻数
34
附带文件
1
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 jmagly 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Cross Task Learner AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/jmagly/aiwg/tree/main/agentic/code/addons/agent-loop/skills/cross-task-learner
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jmagly/aiwg.git /tmp/aiwg
mkdir -p .claude/skills
cp -r /tmp/aiwg/agentic/code/addons/agent-loop/skills/cross-task-learner .claude/skills/cross-task-learner
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Cross Task Learner,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Cross Task Learner。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Cross Task Learner 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Cross-Task Learner Skill

Enable agent loops to learn from similar past tasks and share discovered patterns across multiple concurrent or sequential loops.

Research Foundation: REF-013 MetaGPT - 159% improvement with shared state

Version 2.0: Multi-loop awareness with loop_id tracking


Overview

This skill provides two core capabilities:

  1. Pattern Extraction - On loop completion, extract reusable patterns from execution history
  2. Pattern Injection - On loop start, inject relevant patterns from previous loops

Benefits

BenefitImpact
Faster resolutionPatterns eliminate redundant debugging
Higher success ratesProven approaches applied automatically
Accumulated wisdomSystem gets smarter over time
Anti-pattern detectionFailed approaches flagged and avoided

Research Basis

From REF-013 MetaGPT:

  • 159% improvement with shared state across agents
  • Publish-subscribe pattern enables knowledge sharing
  • Structured outputs become inputs for other agents
  • Memory persistence critical for cross-session learning

Pattern Extraction (On Loop Completion)

Trigger

  • Agent loop completion (success, partial, or failure)
  • Manual extraction request via aiwg ralph-extract-patterns {loop_id}

Process

yaml
extraction_steps:
  1_analyze_loop_history:
    - Load loop state from .aiwg/ralph/loops/{loop_id}/state.json
    - Load iteration analytics
    - Load debug memory
    - Load reflection history

  2_identify_error_fix_pairs:
    - Scan iterations for test failures
    - Identify fixes that resolved errors
    - Extract error signature + fix approach
    - Compute initial success rate (1.0 for first occurrence)

  3_identify_successful_approaches:
    - Analyze task category (testing, debugging, refactoring, etc.)
    - Extract step sequence that led to success
    - Note tools used and iteration count
    - Identify preconditions and benefits

  4_identify_failure_patterns:
    - Detect repeated same errors (anti-patterns)
    - Note approaches that led to scope creep
    - Flag patterns that caused quality degradation
    - Record better alternatives if discovered

  5_extract_code_templates:
    - Identify successful code changes
    - Generalize with placeholders
    - Document use case and placeholders
    - Tag by language and purpose

  6_check_for_duplicates:
    - Compare against existing patterns in registry
    - Merge if >80% similar
    - Update usage count and success rate if duplicate

  7_store_in_registry:
    - Add to .aiwg/ralph/shared/patterns/{type}-patterns.json
    - Update patterns index for semantic search
    - Link to source loop_id

  8_update_effectiveness_metrics:
    - Increment pattern counts
    - Update cross-loop benefit statistics
    - Log extraction event

Example Extraction

Input (from loop ralph-fix-auth-a1b2c3d4):

yaml
iteration_2:
  error:
    type: "TypeError"
    message: "Cannot read property 'email' of null"
    location: "src/auth/validate.ts:42"

iteration_3:
  fix_applied:
    description: "Added null check for user object"
    diff: |
      + if (user == null) {
      +   throw new ValidationError("User is required");
      + }
  test_results:
    passed: 12
    failed: 0

Output (extracted pattern):

yaml
pattern_id: "pat-error-null-check-015"
type: "error_pattern"
error_signature:
  error_type: "TypeError"
  error_pattern: "Cannot read property '.*' of null"
  error_location_hints:
    - "*.ts:validate*"
fix_approach:
  description: "Add null check before property access"
  fix_category: "add_null_check"
  code_template: |
    if ({{variable}} == null) {
      throw new ValidationError("{{message}}");
    }
  code_template_language: "typescript"
source_loops:
  - loop_id: "ralph-fix-auth-a1b2c3d4"
    timestamp: "2026-02-02T15:00:00Z"
    contributed_by: "software-implementer"
success_rate: 1.0
usage_count: 1
first_discovered: "2026-02-02T15:00:00Z"
last_used: "2026-02-02T15:00:00Z"
tags:
  - "typescript"
  - "null-safety"
  - "validation"

Configuration

yaml
# In aiwg.yml or .aiwg/config.yml
ralph:
  cross_loop_learning:
    extraction:
      enabled: true
      auto_extract_on_completion: true
      min_success_rate_threshold: 0.6
      min_usage_count_for_evaluation: 3
      extract_code_templates: true
      merge_similar_patterns: true
      similarity_threshold: 0.80

Pattern Injection (On Loop Start)

Trigger

  • Agent loop start
  • Manual injection request via aiwg ralph-inject-patterns {loop_id}

Process

yaml
injection_steps:
  1_analyze_task_description:
    - Extract task text
    - Identify task category (testing, debugging, refactoring, etc.)
    - Generate task embedding for semantic matching

  2_search_error_patterns:
    - Query error patterns by task category
    - Match error signatures to likely error types
    - Filter by min success rate (default 0.6)
    - Sort by effectiveness

  3_search_success_patterns:
    - Query success patterns by task category match
    - Use semantic similarity on task description
    - Filter by min success rate
    - Sort by average iterations (lower is better)

  4_search_anti_patterns:
    - Query anti-patterns by task category
    - Identify failure modes to avoid
    - Include better alternatives

  5_search_code_templates:
    - Query templates by language and task type
    - Filter by success rate
    - Sort by usage count

  6_filter_and_rank:
    - Combine all pattern types
    - Remove duplicates
    - Rank by relevance × effectiveness
    - Take top-k (default k=5)

  7_inject_into_context:
    - Format patterns for display
    - Add to loop context as "Cross-Loop Learning Context"
    - Track which patterns were injected (for effectiveness measurement)

  8_track_usage:
    - Log pattern injection event
    - Record loop_id and injected pattern_ids
    - Enable later effectiveness analysis

Example Injection

Input (loop ralph-fix-validation-b2c3d4e5 starting):

yaml
task: "Fix TypeScript type errors in user validation"
category: "debugging"

Patterns Retrieved:

yaml
retrieved_patterns:
  error_patterns:
    - pattern_id: "pat-error-null-check-015"
      relevance: 0.95
      success_rate: 1.0
      usage_count: 1

    - pattern_id: "pat-error-type-mismatch-003"
      relevance: 0.88
      success_rate: 0.94
      usage_count: 18

  success_patterns:
    - pattern_id: "pat-success-type-fixing-002"
      relevance: 0.92
      success_rate: 0.87
      average_iterations: 2.8

  anti_patterns:
    - pattern_id: "pat-anti-premature-optimization-001"
      relevance: 0.65
      failure_rate: 0.85

Injected Context (top 5 patterns):

markdown
## Cross-Loop Learning Context

Patterns from previous loops that may help with this task:

### Error Patterns

1. **TypeError: null property access** (100% success, 1 use)
   - Error: "Cannot read property '.*' of null"
   - Fix: Add null check before property access
   - Template:
     ```typescript
     if ({{variable}} == null) {
       throw new ValidationError("{{message}}");
     }
     ```
   - Source: ralph-fix-auth-a1b2c3d4

2. **TypeError: type mismatch** (94% success, 18 uses)
   - Error: "Type 'X' is not assignable to type 'Y'"
   - Fix: Update interface definition or add type assertion
   - Source: 18 previous loops

### Success Patterns

1. **Type error fixing approach** (87% success, avg 2.8 iterations)
   - Steps:
     1. Run tsc --noEmit to see all errors
     2. Group errors by file/type
     3. Fix interface definitions first
     4. Fix usages second
     5. Verify with tsc again
   - Source: 12 successful loops

### Anti-Patterns to Avoid

1. **Premature optimization** (85% failure rate)
   - Don't optimize before tests pass
   - Complete primary task first
   - Better alternative: pat-success-refactor-module-002

Configuration

yaml
ralph:
  cross_loop_learning:
    injection:
      enabled: true
      top_k_patterns: 5
      min_success_rate: 0.6
      max_patterns_injected: 10
      include_error_patterns: true
      include_success_patterns: true
      include_anti_patterns: true
      include_code_templates: true

Multi-Loop Awareness (Version 2.0)

Loop ID Tracking

All patterns now track their source loop IDs:

yaml
pattern:
  pattern_id: "pat-error-null-check-015"
  source_loops:
    - loop_id: "ralph-fix-auth-a1b2c3d4"
      timestamp: "2026-02-02T15:00:00Z"
      contributed_by: "software-implementer"
    - loop_id: "ralph-fix-validation-b2c3d4e5"
      timestamp: "2026-02-02T16:30:00Z"
      contributed_by: "debugger"

Aggregation Across Loops

Patterns aggregate learnings from multiple loops:

Example: Pattern seen in 3 loops

yaml
pattern_id: "pat-error-type-mismatch-003"
source_loops: [ralph-a, ralph-b, ralph-c]
usage_count: 18  # Total across all loops
success_rate: 0.94  # Aggregated success rate (17/18)

effectiveness_trend:
  - timestamp: "2026-02-01T10:00:00Z"
    success_rate_snapshot: 1.0
    sample_size: 1
    source_loop: "ralph-a"
  - timestamp: "2026-02-01T14:00:00Z"
    success_rate_snapshot: 0.90
    sample_size: 10
    source_loops: ["ralph-a", "ralph-b"]
  - timestamp: "2026-02-02T15:00:00Z"
    success_rate_snapshot: 0.94
    sample_size: 18
    source_loops: ["ralph-a", "ralph-b", "ralph-c"]

Cross-Loop Pattern Updates

When a loop uses a pattern, it updates the shared registry:

yaml
on_pattern_application:
  1_increment_usage_count:
    - pattern.usage_count += 1

  2_update_success_rate:
    - If application succeeded:
        pattern.successful_applications += 1
    - Else:
        pattern.failed_applications += 1
    - pattern.success_rate = successful / (successful + failed)

  3_update_effectiveness_trend:
    - Add new snapshot with current success rate and sample size

  4_add_source_loop:
    - If loop_id not in source_loops:
        pattern.source_loops.append({
          loop_id: current_loop_id,
          timestamp: now,
          contributed_by: current_agent
        })

  5_update_last_used:
    - pattern.last_used = now

Pattern Lineage

Patterns maintain full lineage across loops:

Pattern: pat-error-null-check-015

Discovered: ralph-fix-auth-a1b2c3d4 (2026-02-02T15:00:00Z)
Applied:    ralph-fix-validation-b2c3d4e5 (2026-02-02T16:30:00Z) ✓
Applied:    ralph-fix-user-c3d4e5f6 (2026-02-02T18:00:00Z) ✓
Applied:    ralph-fix-api-d4e5f6a7 (2026-02-02T19:15:00Z) ✗

Success rate: 75% (3/4)

Effectiveness Measurement

Metrics Tracked

All metrics now support multi-loop aggregation:

yaml
effectiveness_metrics:
  total_patterns: 47
  patterns_by_type:
    error_patterns: 24
    success_patterns: 15
    anti_patterns: 5
    code_templates: 3

  pattern_usage_stats:
    total_applications: 156
    successful_applications: 142
    failed_applications: 14
    overall_success_rate: 0.91

  cross_loop_benefit:
    loops_with_pattern_injection: 23
    loops_without_pattern_injection: 8
    average_iterations_with: 3.2
    average_iterations_without: 5.1
    improvement_percentage: 37.3  # (5.1 - 3.2) / 5.1 * 100

  last_updated: "2026-02-02T20:00:00Z"

Per-Loop Impact

Each loop tracks which patterns it used:

yaml
loop_state:
  loop_id: "ralph-fix-validation-b2c3d4e5"
  cross_loop_learning:
    injected_patterns:
      - pattern_id: "pat-error-null-check-015"
        applied: true
        successful: true
        iteration_used: 2

      - pattern_id: "pat-error-type-mismatch-003"
        applied: true
        successful: true
        iteration_used: 4

    extracted_patterns:
      - pattern_id: "pat-error-optional-types-016"
        new: true
        success_rate: 1.0

    improvement_estimate:
      baseline_iterations: 6  # Estimated without patterns
      actual_iterations: 4
      improvement: 33.3%

Storage Structure

.aiwg/ralph/
├── shared/                          # Cross-loop shared state
│   ├── patterns/
│   │   ├── error-patterns.json      # Error → fix patterns
│   │   ├── success-patterns.json    # Success approaches
│   │   ├── anti-patterns.json       # Failure patterns
│   │   └── code-templates.json      # Reusable code
│   ├── archive/                     # Pruned patterns
│   │   ├── 2026-01-patterns.json
│   │   └── 2026-02-patterns.json
│   └── effectiveness-metrics.json   # Cross-loop metrics
│
├── memory/                          # Cross-task memory
│   ├── task-index.json              # Semantic task index
│   ├── embeddings/                  # Task embeddings
│   ├── reflections/                 # Reflexion-style reflections
│   └── patterns/                    # Patterns integrated here too
│
└── loops/                           # Per-loop state
    ├── ralph-fix-auth-a1b2c3d4/
    │   ├── state.json               # Includes pattern usage
    │   └── analytics/
    │       └── analytics.json       # Pattern effectiveness
    └── ralph-fix-validation-b2c3d4e5/
        └── ...

CLI Commands

Extract Patterns Manually

bash
# Extract from completed loop
aiwg ralph-extract-patterns ralph-fix-auth-a1b2c3d4

# Extract from all completed loops
aiwg ralph-extract-patterns --all

# Extract specific pattern types only
aiwg ralph-extract-patterns ralph-fix-auth-a1b2c3d4 --types error,success

Inject Patterns Manually

bash
# Inject patterns into running loop
aiwg ralph-inject-patterns ralph-current-loop-e5f6a7b8

# Inject with custom filters
aiwg ralph-inject-patterns ralph-current-loop-e5f6a7b8 \
  --min-success-rate 0.8 \
  --top-k 10

List Patterns

bash
# List all patterns
aiwg ralph-patterns list

# Filter by type
aiwg ralph-patterns list --type error

# Filter by success rate
aiwg ralph-patterns list --min-success-rate 0.8

# Filter by source loop
aiwg ralph-patterns list --from-loop ralph-fix-auth-a1b2c3d4

Show Pattern Details

bash
aiwg ralph-patterns show pat-error-null-check-015

Output:

yaml
Pattern: pat-error-null-check-015
Type: Error Pattern
Created: 2026-02-02T15:00:00Z
Last Used: 2026-02-02T19:15:00Z

Effectiveness:
  Success Rate: 75% (3/4 applications)
  Usage Count: 4
  Average Impact: -2.0 iterations

Source Loops:
  - ralph-fix-auth-a1b2c3d4 (discovered)
  - ralph-fix-validation-b2c3d4e5 (applied successfully)
  - ralph-fix-user-c3d4e5f6 (applied successfully)
  - ralph-fix-api-d4e5f6a7 (applied, failed)

Error Signature:
  Type: TypeError
  Pattern: "Cannot read property '.*' of null"

Fix Approach:
  Category: add_null_check
  Template: |
    if ({{variable}} == null) {
      throw new ValidationError("{{message}}");
    }

Tags: typescript, null-safety, validation

Prune Patterns

bash
# Dry run
aiwg ralph-patterns prune --dry-run

# Prune low-success patterns
aiwg ralph-patterns prune --min-success-rate 0.5

# Prune old unused patterns
aiwg ralph-patterns prune --max-age-days 90

Integration with Other Skills

With Reflection Injection

Patterns complement reflections:

  • Reflections: What was learned in this specific loop
  • Patterns: Reusable knowledge across all loops

Both are injected into new loop context.

With Auto-Test Execution

Patterns inform test execution:

  • Error patterns suggest which tests to run
  • Success patterns guide test-driven approaches
  • Code templates provide test setup patterns

With Agent Loop Skill

Agent loop skill triggers pattern extraction/injection:

  • On loop start: Inject relevant patterns
  • On loop completion: Extract new patterns
  • On iteration: Update pattern usage tracking

Best Practices

1. Let Patterns Stabilize

Don't prune patterns too early. Allow 5-10 uses before evaluating:

yaml
min_usage_count_for_evaluation: 5

2. Tag Patterns Consistently

Use standardized tags:

  • Language: typescript, python, go
  • Domain: auth, validation, testing
  • Type: null-safety, async, error-handling

3. Monitor Pattern Quality

Regularly review low-success patterns:

bash
aiwg ralph-patterns list --min-success-rate 0.0 --max-success-rate 0.6

4. Share Patterns Across Teams

Export/import patterns for team-wide learning:

bash
# Export team patterns
aiwg ralph-patterns export --output team-patterns.json

# Import on teammate's machine
aiwg ralph-patterns import --input team-patterns.json

Troubleshooting

Pattern Not Injected

Symptom: Loop doesn't receive relevant pattern

Causes:

  1. Pattern below success rate threshold
  2. Task description doesn't match semantically
  3. Injection disabled

Fix:

bash
# Check pattern
aiwg ralph-patterns show {pattern_id}

# Lower threshold
aiwg ralph "task" --min-pattern-success-rate 0.5

# Check config
grep -A10 "cross_loop_learning:" aiwg.yml

Pattern Not Extracted

Symptom: Loop completed but no patterns added

Causes:

  1. Auto-extraction disabled
  2. Loop didn't succeed
  3. Pattern duplicates existing one

Fix:

bash
# Extract manually
aiwg ralph-extract-patterns {loop_id}

# Enable auto-extraction
# In aiwg.yml:
ralph:
  cross_loop_learning:
    extraction:
      auto_extract_on_completion: true

Related

  • @$AIWG_ROOT/agentic/code/addons/agent-loop/schemas/shared-patterns.yaml - Pattern schema
  • @$AIWG_ROOT/agentic/code/addons/agent-loop/schemas/cross-task-memory.yaml - Cross-task memory
  • @$AIWG_ROOT/agentic/code/addons/agent-loop/docs/cross-loop-learning.md - Full documentation
  • .aiwg/research/paper-analysis/REF-013-aiwg-analysis.md - MetaGPT research
  • ralph skill - Iterative loop executor
  • agent-loop skill - Detects iterative loop requests

Version History

  • 2.0.0: Multi-loop awareness with loop_id tracking and cross-loop aggregation (Issue #269)
  • 1.0.0: Initial cross-task learning with semantic matching (Issues #154, #155)

References

  • @$AIWG_ROOT/agentic/code/addons/agent-loop/README.md — Ralph addon overview
  • @$AIWG_ROOT/agentic/code/addons/agent-loop/schemas/shared-patterns.yaml — Pattern schema for cross-loop learning
  • @$AIWG_ROOT/agentic/code/addons/agent-loop/schemas/cross-task-memory.yaml — Cross-task memory schema
  • @$AIWG_ROOT/agentic/code/addons/agent-loop/docs/cross-loop-learning.md — Full cross-loop learning documentation
  • @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/subagent-scoping.md — Subagent scoping rules relevant to loop orchestration

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Cross Task Learner AI 技能有什么作用?

Enable agent loops to learn from similar past tasks and share patterns across loops

为什么在 TypingMind 中使用 Cross Task Learner?

因为您只需安装一次,就能搭配任何模型使用。Cross Task Learner 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Cross Task Learner?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/jmagly/aiwg/tree/main/agentic/code/addons/agent-loop/skills/cross-task-learner。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Cross Task Learner?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Cross Task Learner 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Cross Task Learner 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Cross Task Learner AI 技能免费吗?

是的。jmagly 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇