Files
steven_li 6e9e74d1ee feat(engine): 添加运行时上下文支持并重构工具迭代限制
添加 RuntimeContext 类用于捕获模型运行时的日期时间信息,
包括UTC时间、本地时间和时区信息,并在系统提示中显示这些信息。

同时增加最大上下文消息数和工具迭代次数的配置选项,
将验证服务从引擎加载器中移除,并更新相关的数据结构和接口。

BREAKING CHANGE: 移除了验证服务,相关字段被替换为证据状态和接受状态。

- 添加 RuntimeContext 类和相关渲染方法
- 增加 max_context_messages 和 max_tool_iterations 配置
- 移除 ValidationService 相关代码
- 更新消息记录中的验证状态字段
- 添加原始工具调用检测和回退处理
2026-05-26 11:18:35 +08:00

59 lines
3.3 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="zh-CN">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Memory 模块蓝图</title><link rel="stylesheet" href="blueprint.css"></head>
<body><main class="page">
<header class="topbar"><h1>Memory</h1><p>Memory 模块提供三类持久上下文curated memory、session/run memory、skill learning memory。主链 prompt 使用 frozen curated snapshot审计和学习使用 session/run evidenceTask evidence 只作为事实记录。</p></header>
<nav class="nav"><a href="index.html">索引</a><a href="engine.html">Engine</a><a href="skills.html">Skills</a><a href="prompt-atlas.html">Prompt Atlas</a></nav>
<section class="content">
<h2>大模块流程</h2>
<div class="flow">
<div class="step"><strong>Curated</strong>MEMORY.md / USER.md</div><div class="arrow">-&gt;</div>
<div class="step"><strong>Snapshot</strong>run 开始前冻结</div><div class="arrow">-&gt;</div>
<div class="step"><strong>Prompt</strong>ContextBuilder 注入 system sections</div><div class="arrow">-&gt;</div>
<div class="step"><strong>Session</strong>运行事件和可见历史</div><div class="arrow">-&gt;</div>
<div class="step"><strong>Learning</strong>run receipts / skill effects</div>
</div>
<h2>小模块拆分</h2>
<article class="module">
<h3>curated</h3>
<p>人工或工具维护的长期记忆文件。MemoryService 在每个 run 开始前捕获 snapshotContextBuilder 只读 snapshot避免运行中变化影响同一轮 prompt。</p>
<div class="subflow">
<div>读取 workspace 下的 memory 文件。</div>
<div>生成 MemorySnapshot。</div>
<div><code>as_prompt_sections()</code> 渲染为 system prompt sections。</div>
</div>
</article>
<article class="module">
<h3>sessions</h3>
<p>SQLite session store 保存 message/event 流、usage、system prompt snapshot、tool call、tool result、task evidence 与 acceptance 事件等,并支持 FTS 检索。</p>
<div class="subflow">
<div>AgentLoop append_message 记录每一步。</div>
<div>context_visible=false 的内部事件不进入普通对话历史。</div>
<div>get_history 给 ContextBuilder 取可见历史。</div>
<div>session_search 工具使用检索能力找历史证据。</div>
</div>
</article>
<article class="module">
<h3>runs</h3>
<p>run memory 记录一次 run 的 receipts、acceptance metadata、skill effects。它是 skill learning 的主要证据来源,但 learning 入口由 task accepted 触发,而不是单个 run 触发。</p>
<div class="subflow">
<div>run_completed 后记录 run receipt。</div>
<div>用户 acceptance accept/revise/abandon 更新 task 状态,并为 skill learning 标记 final accepted run。</div>
<div>skill effects 根据成功率重算版本分数。</div>
</div>
</article>
<article class="module">
<h3>skills learning store</h3>
<p>保存 learning candidates、drafts、review 状态和发布记录。它把一次运行经验变成可审核的长期能力改动。</p>
<div class="subflow">
<div>从 accepted task evidence 建 candidate包含 task 的所有 runs 和 final_accepted_run_id。</div>
<div>candidate 进入 synthesis。</div>
<div>生成 draft 后由人审阅发布。</div>
</div>
</article>
</section></main></body></html>