src/agent/agent.ts 用结构化的 Info 描述 Agent:名称、模式(primary/subagent/all)、权限、模型覆盖、prompt 和步数限制。默认 research 负责通用研究,biology、physics、ml 是领域专长,另有 critique、literature-review 和 reviewer 等辅助 prompt。
这里的关键设计是角色由 prompt、权限和可用工具共同定义,而不是把多个聊天机器人并列展示。研究流程可以由主 Agent 调用子 Agent 做文献综述或批评,再回到主会话;只读的 plan 模式则把“规划”和“执行”分开,减少模型一开始就修改工作区的风险。
Model 层:按请求路由,避免把模型写死
Provider router 把 provider ID 与 model ID 解耦。README 明确支持自带 API key,Atlas 只是可选的托管模型与研究图服务。这样做的工程意义是:研究者可以用强模型完成假设生成,用便宜模型做整理,或切换到本地模型处理隐私数据,而不必改 Agent 业务代码。
Tool 层:科学连接器被压成稳定的工具面
src/tool/science.ts 有一个值得注意的取舍:不论注册多少数据库,模型看到的核心入口仍然是 science_list_dbs 与 science_search(当前版本另增加了 fetch 能力)。先列目录再按 db 查询,把“连接器数量”与“模型工具数量”解耦,避免工具列表随数据库增长而膨胀。
sequenceDiagram
participant H as 人类
participant UI as Workspace
participant S as Local Server
participant A as Agent
participant X as Science Tools
participant K as Kernel/Shell
participant G as Provenance
H->>UI: 提交研究目标
UI->>S: 创建 Session
S->>A: 组装 system + agent prompt
A->>X: 列出数据库并搜索文献
X-->>A: 规范化来源与记录
A->>K: 写代码/运行实验
K-->>A: 数据、日志、图表
A->>G: 记录 run、artifact、source、claim
A-->>UI: 流式输出过程与报告
while not finished: response = model(system_prompt, agent_prompt, context, tools) if response.calls_tool: result = execute(response.tool, response.input) provenance.record(run=response, result=result) context.append(result) else: context.append(response.text) if repeated_tool_or_text_loop(context): compact_or_stop_with_review()