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

61 lines
3.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>Interfaces 模块蓝图</title><link rel="stylesheet" href="blueprint.css"></head>
<body><main class="page">
<header class="topbar"><h1>Interfaces</h1><p>接口层把外部输入转成内部服务调用。它包含 Web API/静态文件、CLI、Gateway、渠道适配和 MCP server。核心原则是入口负责协议转换业务决策交给 Services 和 Engine。</p></header>
<nav class="nav"><a href="index.html">索引</a><a href="services.html">Services</a><a href="engine.html">Engine</a><a href="prompt-atlas.html">Prompt Atlas</a></nav>
<section class="content">
<h2>大模块流程</h2>
<div class="flow">
<div class="step"><strong>外部请求</strong>HTTP / CLI / MCP / Channel</div><div class="arrow">-&gt;</div>
<div class="step"><strong>Schema/参数整理</strong>session、model、thinking、routing</div><div class="arrow">-&gt;</div>
<div class="step"><strong>调用 Services</strong>AgentService / CronService / SkillHubService</div><div class="arrow">-&gt;</div>
<div class="step"><strong>返回响应</strong>chat result、task state、skill artifacts、cron history</div>
</div>
<h2>小模块拆分</h2>
<article class="module">
<h3>web</h3>
<p>Web 应用是主要产品入口,集中提供 chat、task acceptance、cron、session、skill draft/review/publish 等 API并服务前端静态资源。</p>
<div class="subflow">
<div>请求进入 FastAPI route解析 body/query/path。</div>
<div>根据功能调用 AgentService、CronService、SkillHubService 或 SessionProcessProjector。</div>
<div>把内部 dataclass/model 转成 JSON payload并在必要时补充 session/run/task 元数据。</div>
</div>
<p class="meta">关键文件:<code>beaver/interfaces/web/app.py</code><code>beaver/interfaces/web/files.py</code></p>
</article>
<article class="module">
<h3>cli</h3>
<p>CLI 入口用于本地命令行运行 Beaver。它复用同一套 AgentService/AgentLoop因此 CLI 不是第二套 runtime只是更薄的协议层。</p>
<div class="subflow">
<div>读取命令行参数。</div>
<div>构造 session/source/model 参数。</div>
<div>调用 agent run打印最终输出。</div>
</div>
</article>
<article class="module">
<h3>gateway 与 channels</h3>
<p>Gateway 和 channels 是多渠道接入边界,把渠道消息抽象为统一的内部消息。当前代码中通道能力较轻,主要服务未来接入不同聊天来源。</p>
<div class="subflow">
<div>渠道事件进入 adapter。</div>
<div>规范化 user_id、channel、chat_id、content。</div>
<div>转给 AgentService最终仍落入同一个 session/run 体系。</div>
</div>
</article>
<article class="module">
<h3>mcp_servers</h3>
<p>对外暴露 MCP server 能力,让 Beaver 的部分能力可以被其他 MCP client 调用;这和 Beaver 作为 MCP client 使用外部工具是两条边界。</p>
<div class="subflow">
<div>MCP client 调用 server tool。</div>
<div>接口层解析 MCP 参数。</div>
<div>转调内部服务或数据访问层。</div>
</div>
</article>
<h2>修改影响点</h2>
<p>入口层新增字段时,要同步核对 Services 层是否需要进入 prompt例如 <code>thinking_enabled</code> 会影响 router、skill assembler、provider chat kwargs<code>execution_context</code> 会进入 ContextBuilder 的 system prompt。</p>
</section></main></body></html>