Files
beaver_project/projcet_review/backend_blueprint/index.html
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

88 lines
6.5 KiB
HTML
Raw 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>Beaver Backend 多页模块蓝图</title>
<link rel="stylesheet" href="blueprint.css">
</head>
<body>
<main class="page">
<header class="topbar">
<h1>Beaver Backend 多页模块蓝图</h1>
<p>基于 <code>app-instance/backend/beaver</code> 源码拆出的模块级审阅文档。每个大模块独立成页,页内继续拆小模块、执行流程、数据流和 prompt 组装点。</p>
</header>
<nav class="nav">
<a href="index.html">索引</a>
<a href="foundation.html">Foundation</a>
<a href="interfaces.html">Interfaces</a>
<a href="services.html">Services</a>
<a href="engine.html">Engine</a>
<a href="providers.html">Providers</a>
<a href="tasks.html">Tasks</a>
<a href="coordinator.html">Coordinator</a>
<a href="tools.html">Tools</a>
<a href="skills.html">Skills</a>
<a href="memory.html">Memory</a>
<a href="integrations.html">Integrations</a>
<a href="permissions.html">Permissions</a>
<a href="prompt-atlas.html">Prompt Atlas</a>
</nav>
<section class="content">
<h2>项目在做什么</h2>
<p class="lead">这个后端是 Beaver 的本地/服务端 agent runtime。它把 Web、CLI、MCP、定时任务等入口统一成 session run再通过 Intent Agent 判断是否进入内部 Task 模式Task 模式会计划单 agent 或 team graph装配 skills/tools/memory调用 provider执行工具循环收集 evidence并把结果交给用户验收。只有用户接受后的 Task evidence 才进入 skill learning生成候选、草稿、审核和发布链路。</p>
<div class="flow">
<div class="step"><strong>入口</strong>Web / CLI / Gateway / Cron</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>服务编排</strong>AgentService / CronService / TeamService</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>运行内核</strong>AgentLoop + ContextBuilder</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>能力装配</strong>Skills / Tools / Memory</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>模型与工具</strong>Providers + ToolExecutor</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>任务验收</strong>Evidence / User Acceptance</div>
</div>
<h2>大模块页</h2>
<div class="grid">
<article class="module"><h3><a href="foundation.html">Foundation</a></h3><p>配置、事件总线、cron 数据结构、embedding 检索基础设施。</p><p class="meta">beaver/foundation</p></article>
<article class="module"><h3><a href="interfaces.html">Interfaces</a></h3><p>Web API、静态 UI、CLI、Gateway、MCP server 和外部通道入口。</p><p class="meta">beaver/interfaces</p></article>
<article class="module"><h3><a href="services.html">Services</a></h3><p>产品级用例层,负责把入口请求变成 agent run、task run、cron run、team run。</p><p class="meta">beaver/services</p></article>
<article class="module"><h3><a href="engine.html">Engine</a></h3><p>运行内核,负责加载依赖、构造上下文、执行 LLM/tool loop、落 session 事件。</p><p class="meta">beaver/engine</p></article>
<article class="module"><h3><a href="providers.html">Providers</a></h3><p>统一 provider 协议和 OpenAI/LiteLLM/Anthropic/Codex/Custom 的适配转换。</p><p class="meta">beaver/engine/providers</p></article>
<article class="module"><h3><a href="tasks.html">Tasks</a></h3><p>内部 Task 模式路由、计划、team 技能解析、事实证据和用户验收。</p><p class="meta">beaver/tasks</p></article>
<article class="module"><h3><a href="coordinator.html">Coordinator</a></h3><p>把 team graph 节点调度到本地子 agent管理依赖输出和节点证据。</p><p class="meta">beaver/coordinator</p></article>
<article class="module"><h3><a href="tools.html">Tools</a></h3><p>工具规格、注册表、按 run 选择工具、执行器、内置工具和 MCP 工具包装。</p><p class="meta">beaver/tools</p></article>
<article class="module"><h3><a href="skills.html">Skills</a></h3><p>Skill 目录、LLM 选择、注入、草稿、审核、发布、学习流水线。</p><p class="meta">beaver/skills</p></article>
<article class="module"><h3><a href="memory.html">Memory</a></h3><p>curated memory、session SQLite、run receipt、skill learning store。</p><p class="meta">beaver/memory</p></article>
<article class="module"><h3><a href="integrations.html">Integrations</a></h3><p>MCP、AuthZ、Outlook 等外部集成边界。</p><p class="meta">beaver/integrations</p></article>
<article class="module"><h3><a href="permissions.html">Permissions</a></h3><p>当前是预留骨架,用来承载后续权限策略。</p><p class="meta">beaver/permissions</p></article>
</div>
<h2>Prompt 组装总图</h2>
<p>所有直接构造 LLM messages 的位置集中在 <a href="prompt-atlas.html">Prompt Atlas</a>。模块页中只保留与该模块有关的 prompt 流程详细字段顺序、system/user message 内容结构、fallback 逻辑都在 Prompt Atlas 展开。</p>
<div class="flow">
<div class="step"><strong>Intent Agent</strong>判断 simple/task/revise/new/close</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>Planner</strong>判断 single/team生成 graph</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>Skill Select</strong>选择 published skill 或临时 guidance</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>ContextBuilder</strong>system prompt + skill activation + history + user</div>
<div class="arrow">-&gt;</div>
<div class="step"><strong>User Acceptance</strong>用户接受、修改或放弃</div>
</div>
<h2>已知核对点</h2>
<div class="callout">
<strong>定时任务路径有一处疑似运行时错误:</strong>
<code>services/agent_service.py</code><code>run_scheduled_task()</code> 末尾写 event payload 时引用了未定义的 <code>job</code><code>run</code>,应改用函数参数 <code>cron_job_id</code><code>scheduled_run_id</code><code>cron_job_name</code>
</div>
</section>
</main>
</body>
</html>