episode-complete
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEpisode Complete
完成Episode
Complete and score a learning episode to extract patterns and update heuristics.
完成学习episode并为其评分,以提取模式并更新启发式规则。
Purpose
目的
Finalize an episode with outcome scoring, reflection generation, and pattern extraction for future retrieval.
通过结果评分、反思生成和模式提取来收尾episode,以便未来检索使用。
Steps
步骤
-
Gather outcome data:
- Final verdict (success, partial_success, failure)
- Total time spent
- Total tokens used (if applicable)
- Key artifacts produced
- Errors encountered
-
Create TaskOutcome:rust
let outcome = TaskOutcome { verdict: Verdict::Success, time_ms: total_time, tokens: total_tokens, artifacts: vec![/* paths to created/modified files */], errors: vec![/* any errors encountered */], }; -
Call complete_episode:rust
memory.complete_episode(episode_id, outcome).await?; -
System processes:
- Computes RewardScore based on:
- Success/failure
- Time efficiency
- Code quality
- Generates Reflection:
- What worked well
- What could be improved
- Key learnings
- Extracts Patterns:
- Tool sequences
- Decision points
- Common pitfalls
- Computes RewardScore based on:
-
Update storage:
- Store in Turso (permanent record)
- Update redb cache
- Index by task_type and timestamp
- Update related patterns and heuristics
-
Validation:
- Verify episode was scored
- Check patterns were extracted
- Ensure heuristics were updated
-
收集结果数据:
- 最终结论(success、partial_success、failure)
- 总耗时
- 总使用token数(如适用)
- 生成的关键工件
- 遇到的错误
-
创建TaskOutcome:rust
let outcome = TaskOutcome { verdict: Verdict::Success, time_ms: total_time, tokens: total_tokens, artifacts: vec![/* paths to created/modified files */], errors: vec![/* any errors encountered */], }; -
调用complete_episode:rust
memory.complete_episode(episode_id, outcome).await?; -
系统处理流程:
- 基于以下指标计算RewardScore:
- 成功/失败状态
- 时间效率
- 代码质量
- 生成反思内容:
- 哪些部分表现良好
- 哪些部分可以改进
- 关键学习点
- 提取模式:
- 工具使用序列
- 决策节点
- 常见陷阱
- 基于以下指标计算RewardScore:
-
更新存储:
- 存储到Turso(永久记录)
- 更新redb缓存
- 按task_type和时间戳建立索引
- 更新相关模式与启发式规则
-
验证:
- 确认episode已完成评分
- 检查模式是否已提取
- 确保启发式规则已更新
Pattern Types Extracted
提取的模式类型
- ToolSequence: Common tool usage patterns
- DecisionPoint: Key decision moments and outcomes
- ErrorPattern: Common errors and resolutions
- PerformancePattern: Optimization opportunities
- ToolSequence: 常见工具使用模式
- DecisionPoint: 关键决策时刻及结果
- ErrorPattern: 常见错误与解决方案
- PerformancePattern: 优化机会
Scoring Rubric
评分标准
- Success: Task completed, tests pass, meets requirements
- Partial Success: Task mostly complete, minor issues
- Failure: Task incomplete, major issues, tests failing
- Success: 任务完成,测试通过,满足需求
- Partial Success: 任务基本完成,存在小问题
- Failure: 任务未完成,存在重大问题,测试失败
Example
示例
rust
let outcome = TaskOutcome {
verdict: Verdict::Success,
time_ms: 45000,
tokens: 12000,
artifacts: vec![
"src/storage/batch.rs".to_string(),
"tests/integration/batch_test.rs".to_string(),
],
errors: vec![],
};
memory.complete_episode(episode_id, outcome).await?;rust
let outcome = TaskOutcome {
verdict: Verdict::Success,
time_ms: 45000,
tokens: 12000,
artifacts: vec![
"src/storage/batch.rs".to_string(),
"tests/integration/batch_test.rs".to_string(),
],
errors: vec![],
};
memory.complete_episode(episode_id, outcome).await?;Post-Completion
完成后操作
- Patterns are now available for future retrieval
- Heuristics updated for similar tasks
- Episode stored for long-term learning
- Embeddings computed (if service configured)
- 提取的模式可用于未来检索
- 针对相似任务更新启发式规则
- Episode被存储用于长期学习
- 计算嵌入向量(若服务已配置)