Skip to content

Commit 390833b

Browse files
committed
Add native harness full benchmark summary
1 parent 74ae4f2 commit 390833b

14 files changed

Lines changed: 601 additions & 131 deletions

File tree

README.md

Lines changed: 83 additions & 23 deletions
Large diffs are not rendered by default.

README_ZH.md

Lines changed: 84 additions & 24 deletions
Large diffs are not rendered by default.

bayesian_agent/harness/llm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ def _post_json(self, url: str, payload: Mapping[str, Any]) -> Dict[str, Any]:
7676
with urllib.request.urlopen(request, timeout=int(self.timeout_seconds), context=context) as response:
7777
raw = response.read().decode("utf-8", errors="replace")
7878
return json.loads(raw)
79-
except (urllib.error.URLError, TimeoutError, http.client.RemoteDisconnected, json.JSONDecodeError) as exc:
79+
except (
80+
urllib.error.URLError,
81+
TimeoutError,
82+
http.client.RemoteDisconnected,
83+
http.client.IncompleteRead,
84+
json.JSONDecodeError,
85+
) as exc:
8086
last_error = exc
8187
if attempt >= int(self.max_retries or 0):
8288
break

docs/adapters.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Adapters
22

3-
Bayesian-Agent is designed to integrate with external agent harnesses without copying their code. This is one of the main reasons the project is not just another agent framework: the Bayesian layer can improve whichever harness emits verified trajectories.
3+
Bayesian-Agent now has a first-party native harness, and it still integrates with external agent harnesses without copying their code. This is one of the main reasons the project is not just another monolithic framework: the Bayesian layer can improve whichever harness emits verified trajectories.
44

55
## Adaptation Advantage
66

77
Bayesian-Agent separates Skill evolution from task execution:
88

99
```text
10-
Harness executes -> Bayesian-Agent learns -> Adapter injects model-facing Skill/SOP text -> Harness reruns
10+
Native or external harness executes -> Bayesian-Agent learns -> Skill/SOP text updates -> Harness reruns
1111
```
1212

1313
That separation enables three deployment styles:
@@ -16,6 +16,28 @@ That separation enables three deployment styles:
1616
- repair only the failed tasks from an existing agent run
1717
- reuse the same Skill belief registry across compatible harnesses
1818

19+
## Native Harness First
20+
21+
The default execution backend is now the Bayesian-Agent native harness:
22+
23+
```bash
24+
python experiments/run_benchmarks.py \
25+
--harness bayesian-agent \
26+
--model deepseek-v4-flash \
27+
--bench core \
28+
--mode all \
29+
--limit 1
30+
```
31+
32+
The native harness owns only the minimal execution substrate:
33+
34+
- LLM: a small OpenAI-compatible chat client.
35+
- Tools: workspace-scoped `file_read`, `file_write`, `code_run`, and `finish`.
36+
- Memory: three layers, `hippocampus`, intermediate `state`, and persistent `cortex`.
37+
- Loop: turn execution, tool dispatch, transcript capture, usage accounting, and trajectory persistence.
38+
39+
The harness layer is intentionally simple and efficient. Most capability improvement is meant to come from Bayesian Skill/SOP evolution, where verified trajectories update reusable procedures instead of hiding behavior inside a large runtime.
40+
1941
## Adapter Contract
2042

2143
An external harness should satisfy the `AgentAdapter` protocol:
@@ -71,17 +93,25 @@ External systems should emit:
7193

7294
Bayesian-Agent can then update beliefs, keep posterior audit artifacts, and render the next model-facing Skill/SOP text.
7395

74-
## Planned Bayesian-Agent Harness
96+
## Optional Compatibility Backends
97+
98+
External harnesses remain useful for comparison and transfer. Current optional backend names are:
99+
100+
```bash
101+
--harness genericagent
102+
--harness mini-swe-agent
103+
--harness claude-code
104+
```
75105

76-
Current experiments use GenericAgent as the backend harness. A dedicated Bayesian-Agent harness is planned so users can run the full loop without depending on GenericAgent, while still keeping GenericAgent and other frameworks as optional backends.
106+
Each backend should emit enough trajectory evidence for Bayesian-Agent to update Skill beliefs: task identity, outcome, failure mode, token usage, tool/runtime metadata, and artifacts.
77107

78108
## MinimalAgent Status
79109

80-
MinimalAgent adapter support is intentionally not included in v0.4.
110+
MinimalAgent adapter support is intentionally not included in v0.5.
81111

82112
The recommended path is:
83113

84-
1. stabilize the GenericAgent boundary
114+
1. keep the native harness small and inspectable
85115
2. keep the core trace schema portable
86-
3. upload the dedicated Bayesian-Agent harness
116+
3. use GA, mini-swe-agent, and Claude Code as compatibility backends
87117
4. add more adapters only after the adapter contract has enough real usage

docs/architecture.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Architecture
22

3-
Bayesian-Agent is intentionally small. The framework core is independent from any specific agent harness, so the same Bayesian Skill/SOP evolution loop can support full runs, incremental repair, and cross-harness adaptation.
3+
Bayesian-Agent is intentionally small. The framework core is independent from any specific external agent harness, so the same Bayesian Skill/SOP evolution loop can support first-party native runs, GenericAgent-backed runs, incremental repair, and cross-harness adaptation.
44

55
<div align="center">
66
<img src="assets/bayesian_agent_framework_v2.svg" width="900" alt="Bayesian-Agent framework"/>
@@ -11,7 +11,7 @@ Bayesian-Agent is intentionally small. The framework core is independent from an
1111
## Data Flow
1212

1313
```text
14-
Any Compatible Harness Run
14+
Native BA Harness or Compatible External Harness
1515
|
1616
v
1717
TrajectoryEvidence
@@ -26,7 +26,7 @@ SkillBelief + RewritePolicy
2626
SkillContextBuilder
2727
|
2828
v
29-
Adapter
29+
Native Harness / Adapter
3030
|
3131
v
3232
Any Compatible Harness Next Run
@@ -43,23 +43,35 @@ bayesian_agent/
4343
policy.py # default rewrite policy
4444
context.py # posterior audit and Skill context rendering
4545
repair.py # result normalization and repair summaries
46+
harness/
47+
native.py # first-party LLM/tool turn loop
48+
llm.py # OpenAI-compatible chat client
49+
tools.py # workspace-scoped tools
50+
core.py # task envelope, artifacts, three-layer memory bridge
51+
memory/
52+
layers.py # hippocampus, intermediate state, cortex
4653
adapters/
4754
base.py # AgentAdapter protocol
55+
bayesian_agent.py
4856
generic_agent.py
57+
mini_swe_agent.py
58+
claude_code.py
4959
cli.py
5060
```
5161

5262
## Core Boundaries
5363

5464
`bayesian_agent.core` is framework-agnostic. It knows nothing about GenericAgent, benchmark runners, browser tools, or model APIs.
5565

56-
`bayesian_agent.adapters` defines how external harnesses can connect. The GenericAgent adapter in v0.4 is intentionally a boundary placeholder, not a vendored copy of GenericAgent.
66+
`bayesian_agent.harness` contains the first-party native harness. It runs the OpenAI-compatible LLM loop, dispatches workspace tools, captures trajectories, and bridges into the three-layer memory system.
67+
68+
`bayesian_agent.adapters` defines how external harnesses can connect. GenericAgent, mini-swe-agent, and Claude Code are optional compatibility backends, not vendored runtimes.
5769

5870
This separation is what prevents Bayesian-Agent from being swallowed by the agent framework category. It is a reusable Bayesian evolution layer that can sit beside multiple harnesses rather than competing with all of them as another monolithic runtime.
5971

6072
`schemas/` defines portable JSON shapes for trajectories and Skill beliefs.
6173

62-
`artifacts/` contains result files from the initial GenericAgent validation. GenericAgent is the current experimental harness; a dedicated Bayesian-Agent harness is planned.
74+
`artifacts/` contains result files from the initial GenericAgent validation. `results/native_harness_deepseek_v4_flash_full/` and `results/native_harness_deepseek_v4_pro_full/` contain local full-sample results from the first-party native harness.
6375

6476
## Persistence Model
6577

docs/articles/zhihu-bayesian-agent.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> 仓库地址:[https://github.com/DataArcTech/Bayesian-Agent](https://github.com/DataArcTech/Bayesian-Agent)
44
> 文档地址:[https://dataarctech.github.io/Bayesian-Agent/](https://dataarctech.github.io/Bayesian-Agent/)
5-
> 当前版本:v0.4,arXiv coming soon
5+
> 当前版本:v0.5,arXiv coming soon
66
77
过去一年,Agent 框架越来越多。每个框架都在讲工具调用、memory、planner、browser、workflow、multi-agent,但如果把这些概念拨开,本质问题其实很朴素:
88

@@ -40,7 +40,7 @@ P(success | theta, C, skill)
4040

4141
## 仓库架构图
4242

43-
下面这张图是当前仓库结构和数据流。核心点是:Bayesian-Agent 的 `core` 不绑定任何具体 Agent runtime;GenericAgent 只是当前实验使用的 backend harness,未来也会上传我们自己的 Agent harness
43+
下面这张图是当前仓库结构和数据流。核心点是:Bayesian-Agent 的 `core` 不绑定任何具体 Agent runtime;现在默认可以使用 BA 自家的 native harness,GenericAgent、mini-swe-agent 和 Claude Code 保留为可选兼容 backend
4444

4545
<div align="center">
4646
<img src="../assets/bayesian_agent_repository_architecture.svg" width="900" alt="Bayesian-Agent repository architecture"/>
@@ -51,9 +51,11 @@ P(success | theta, C, skill)
5151
仓库中最重要的几层是:
5252

5353
- `bayesian_agent/core/`:框架无关的 Bayesian evolution engine
54+
- `bayesian_agent/harness/`:自家的极简 LLM loop、workspace tools 和 trajectory capture
55+
- `bayesian_agent/memory/`:三层 hippocampus / state / cortex 记忆
5456
- `bayesian_agent/adapters/`:外部 Agent harness 的适配边界
5557
- `schemas/`:trajectory evidence 和 Skill belief 的通用 JSON schema
56-
- `artifacts/`:GenericAgent + deepseek-v4-flash 的实验结果
58+
- `artifacts/``results/`:GenericAgent 历史验证与 BA native 全样本/调试实验结果
5759
- `docs/`:方法、实验、API、adapter 和部署文档
5860

5961
这个边界设计很重要。它意味着 Bayesian-Agent 不需要复制 GenericAgent,也不需要把自己变成一个封闭的大型 Agent 框架。只要某个 Agent framework 能产出统一的 trajectory schema,它就可以接入 Bayesian-Agent。
@@ -105,14 +107,16 @@ Bayesian-Agent 可以从零开始运行任务。没有历史 traces,没有人
105107

106108
**一个 Agent 能不能在没有先验经验的情况下,通过执行和验证自我沉淀 Skill?**
107109

108-
在 SOP-Bench 上,我们用 GenericAgent + `deepseek-v4-flash` 做了原型验证
110+
早期原型先用 GenericAgent + `deepseek-v4-flash` 做验证;v0.5 之后,Bayesian-Agent 也已经能用自家的 native harness 跑完整 benchmark
109111

110112
| Benchmark | Agent | Model | Accuracy | Input Tokens | Output Tokens | Total Tokens | Efficiency |
111113
|---|---|---|---:|---:|---:|---:|---:|
112114
| SOP-Bench | GA | deepseek-v4-flash | 80% | 1.34M | 57k | 1.39M | 11.47 |
113115
| SOP-Bench | GA+Bayesian | deepseek-v4-flash | 100% | 1.07M | 52k | 1.12M | 17.86 |
114116

115-
结果很直观:full mode 不只是把准确率从 80% 拉到 100%,token 使用也从 1.39M 降到了 1.12M。
117+
结果很直观:GA-backed full mode 不只是把准确率从 80% 拉到 100%,token 使用也从 1.39M 降到了 1.12M。
118+
119+
在 BA native harness 的全样本结果里,`deepseek-v4-flash` 在 SOP-Bench 上从 19/20 baseline 修到 20/20,在 Lifelong AgentBench 上也从 19/20 修到 20/20;RealFin-Bench 上 `deepseek-v4-pro` 从 26/40 baseline 提升到 31/40 final。这里更重要的不是把 harness 写复杂,而是证明 BA 可以自己执行、记录 trajectory,并继续把能力提升交给 Bayesian Skill/SOP evolution。
116120

117121
这说明 Skill 进化不是“越写越长”的记忆堆叠。用 posterior belief 过滤和组织经验,反而可能让上下文更短、更准。
118122

@@ -139,8 +143,8 @@ Base Agent -> Failure Traces -> Bayesian Skill Evolution -> Rerun Failures -> Hi
139143

140144
| Benchmark | Agent | Model | Final Accuracy | Incremental Input | Incremental Output | Incremental Total | Incremental Efficiency |
141145
|---|---|---|---:|---:|---:|---:|---:|
142-
| SOP-Bench | GA+BayesianIncremental | deepseek-v4-flash | 100% | 216k | 10k | 226k | 17.73 |
143-
| Lifelong AgentBench | GA+BayesianIncremental | deepseek-v4-flash | 100% | 71k | 7k | 78k | 25.57 |
146+
| SOP-Bench | GA+BayesianIncremental | deepseek-v4-flash | 100% | 254k | 14k | 268k | 14.93 |
147+
| Lifelong AgentBench | GA+BayesianIncremental | deepseek-v4-flash | 100% | 129k | 10k | 139k | 14.41 |
144148

145149
这点非常关键:如果一个 Agent 已经能做到 80% 或 90%,Bayesian-Agent 不需要完整重跑所有任务,只需要针对失败部分做增量修复。
146150

@@ -150,7 +154,7 @@ Base Agent -> Failure Traces -> Bayesian Skill Evolution -> Rerun Failures -> Hi
150154

151155
Bayesian-Agent 最重要的定位,是 **cross-harness adaptation**
152156

153-
我们现在的实验基于 GenericAgent,但仓库没有 copy 一份 GenericAgent,也没有把自己写成 GenericAgent fork。原因很简单:
157+
早期实验基于 GenericAgent,但仓库没有 copy 一份 GenericAgent,也没有把自己写成 GenericAgent fork;现在 BA native、GenericAgent、mini-swe-agent 和 Claude Code 都只是不同执行边界。原因很简单:
154158

155159
**真正有价值的不是某个 harness 本身,而是 Skill/SOP 进化的方法可以跨 harness 复用。**
156160

@@ -167,13 +171,13 @@ class AgentAdapter(Protocol):
167171
...
168172
```
169173

170-
这意味着 GenericAgent、我们后续上传的自研 Agent harness,以及其他 agent frameworks,都可以作为 Bayesian-Agent 的 backend。
174+
这意味着 BA native、GenericAgent、mini-swe-agent、Claude Code 以及其他 agent frameworks,都可以作为 Bayesian-Agent 的 backend。
171175

172176
我们希望 Bayesian-Agent 成为一个 **Skill evolution substrate**,而不是又一个孤立的 Agent 应用。
173177

174178
## 仓库里现在有什么?
175179

176-
v0.4 已经包含:
180+
v0.5 已经包含:
177181

178182
- Bayesian Skill registry
179183
- Bayesian Evidence Model belief update
@@ -182,9 +186,12 @@ v0.4 已经包含:
182186
- posterior audit context builder
183187
- incremental repair utilities
184188
- result summarization CLI
189+
- first-party native harness
190+
- three-layer hippocampus / state / cortex memory
185191
- GenericAgent optional adapter boundary
192+
- mini-swe-agent and Claude Code optional backend boundary
186193
- trajectory 和 skill belief schema
187-
- SOP-Bench / Lifelong AgentBench 实验 artifacts
194+
- SOP-Bench / Lifelong AgentBench / RealFin 实验 artifacts
188195
- MkDocs 文档站和 GitHub Pages 部署
189196

190197
安装方式:
@@ -248,10 +255,10 @@ Bayesian Skill Evolution above
248255

249256
接下来我们会继续做几件事:
250257

251-
- 上传我们自己的 Bayesian-Agent harness,让用户不依赖 GenericAgent 也能完整跑 full loop
258+
- 继续压缩 native harness 的 token 成本,尤其是 RealFin 这类数据密集任务
252259
- 完善更多 agent frameworks 的 adapter examples
253260
- 增加更丰富的 rewrite policy,比如 context-specific split、cost-aware compression、failure taxonomy
254-
- 加入可执行 benchmark runner,方便外部复现实验
261+
- 扩展可执行 benchmark runner,方便外部复现实验
255262
- 推进论文版本,arXiv coming soon
256263

257264
## 结语

0 commit comments

Comments
 (0)