@tangle-network/agent-knowledge 4.0.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/AGENTS.md +35 -19
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +220 -943
  4. package/dist/benchmarks/index.d.ts +3 -2
  5. package/dist/benchmarks/index.js +1 -1
  6. package/dist/{chunk-EUAXSBMH.js → chunk-AKYJG2MR.js} +224 -224
  7. package/dist/chunk-AKYJG2MR.js.map +1 -0
  8. package/dist/{chunk-BBCIB4UL.js → chunk-EYIA5PLQ.js} +27 -195
  9. package/dist/chunk-EYIA5PLQ.js.map +1 -0
  10. package/dist/{chunk-3CAAGJCE.js → chunk-LMR53POQ.js} +1227 -574
  11. package/dist/chunk-LMR53POQ.js.map +1 -0
  12. package/dist/{chunk-WCYW2GDA.js → chunk-MYFM6LKH.js} +2 -2
  13. package/dist/chunk-MYFM6LKH.js.map +1 -0
  14. package/dist/cli.js +1 -1
  15. package/dist/index-Cf7txrYP.d.ts +790 -0
  16. package/dist/index.d.ts +252 -73
  17. package/dist/index.js +2813 -2229
  18. package/dist/index.js.map +1 -1
  19. package/dist/memory/index.d.ts +8 -709
  20. package/dist/memory/index.js +2 -2
  21. package/dist/sources/index.d.ts +17 -33
  22. package/dist/sources/index.js +1 -1
  23. package/dist/{types-ZzY_x0r7.d.ts → types-BY-xLVw-.d.ts} +28 -67
  24. package/docs/eval/investment-material-facts.md +28 -29
  25. package/docs/eval/rag-eval-roadmap.md +21 -17
  26. package/docs/results/adaptive.md +13 -13
  27. package/docs/results/claim-grounding.md +11 -11
  28. package/docs/results/cost-quality.md +4 -4
  29. package/docs/results/investment-thesis.md +56 -56
  30. package/docs/results/research-driving.md +54 -54
  31. package/docs/two-agent-research-ab.md +94 -94
  32. package/package.json +11 -11
  33. package/skills/build-with-agent-knowledge/SKILL.md +97 -0
  34. package/dist/chunk-3CAAGJCE.js.map +0 -1
  35. package/dist/chunk-BBCIB4UL.js.map +0 -1
  36. package/dist/chunk-EUAXSBMH.js.map +0 -1
  37. package/dist/chunk-WCYW2GDA.js.map +0 -1
@@ -1,10 +1,10 @@
1
- # Does driving research DEEPER beat just collecting it? A held-out deep-question A/B — and an honest null
1
+ # Research-driving versus collection: a held-out deep-question result
2
2
 
3
3
  *Tangle Network · `agent-knowledge`*
4
4
 
5
- ## Verdict (BLUF)
5
+ ## Verdict
6
6
 
7
- We built a research driver whose job is to push a web-research loop **deeper** —
7
+ We built a research driver whose job is to push a web-research loop **deeper**:
8
8
  extract each source's claims, demand a second independent source for every claim,
9
9
  generate comparative / mechanism / contradiction sub-questions, and steer the
10
10
  worker to chase them. The hypothesis: a KB built this way answers **more held-out
@@ -13,7 +13,7 @@ verifier.
13
13
 
14
14
  On a **firewalled exam of 20 deep questions across 5 ML topics**, graded with a
15
15
  $0 deterministic check the loop never sees, at equal compute, **the driving loop
16
- did NOT reliably beat plain collection and cost ~12–16× more.** The verdict
16
+ did NOT reliably beat plain collection, and cost ~12–16× more.** The verdict
17
17
  flips with the compute budget, which is the tell that it is **noise, not signal**:
18
18
 
19
19
  | arm | answered @ B=4 | answered @ B=6 | cost (5 topics) | tokens |
@@ -24,20 +24,20 @@ flips with the compute budget, which is the tell that it is **noise, not signal*
24
24
 
25
25
  Driving "wins" at B=4 (16 > 15 > 13) and "loses" at B=6 (13 < 15), while the
26
26
  single-agent arm itself swings 15→13 and driving swings 16→13 on the *same* exam.
27
- At n=5 topics a ±1–3 question difference is within the run-to-run web variance
27
+ At n=5 topics a ±1–3 question difference is within the run-to-run web variance;
28
28
  the arms are not separated by topology, they are separated by **which pages the
29
29
  web returned that minute**. The one thing that is stable and large is the **cost**:
30
30
  driving spends an order of magnitude more for no reliable quality gain.
31
31
 
32
32
  **Why** (the autopsy that explains it, §4): every arm finished in **one effective
33
- round** (`passes=2` on every topic, every budget). The generic readiness gate
34
- "one source closes the gap" is satisfied by the first round's fetch, so the
33
+ round** (`passes=2` on every topic, every budget). The generic readiness gate,
34
+ "one source closes the gap", is satisfied by the first round's fetch, so the
35
35
  loop *stops before the driving driver ever steers a second round*. Driving's
36
36
  entire mechanism is multi-round (extract → demand corroboration → re-search). So
37
- the headline A/B under-tests it. **We then gave it its fairest test** a
38
- controlled probe (§5) that *forces* 3 rounds so the driver actually steers and
37
+ the headline A/B under-tests it. **We then ran a controlled test**, a
38
+ controlled probe (§5) that *forces* 3 rounds so the driver actually steers, and
39
39
  it **still does not win: 8 vs 8 against a blind worker, at ~9× the cost.** The
40
- negative result is robust, not a gate artifact.
40
+ same result remains after controlling the stopping condition.
41
41
 
42
42
  This is a real negative result, and we report it as one.
43
43
 
@@ -45,7 +45,7 @@ This is a real negative result, and we report it as one.
45
45
 
46
46
  The prior A/B in this repo
47
47
  ([two-agent-research-ab.md](../two-agent-research-ab.md)) measured **cleanliness**
48
- how *few* sources a verifier admits at equal coverage. That is the right metric
48
+ - how *few* sources a verifier admits at equal coverage. That is the right metric
49
49
  for a verifier whose job is to filter. It is the **wrong** metric for the driving
50
50
  driver, whose thesis is the opposite: it is not trying to admit fewer sources, it
51
51
  is trying to build a KB that *answers more*. Measuring it on admitted-count would
@@ -60,21 +60,21 @@ So we need a metric for research **quality**, not hygiene. We use:
60
60
 
61
61
  [`tests/loops/held-out-exam.ts`](../../tests/loops/held-out-exam.ts). 5 ML topics,
62
62
  4 questions each = **20 deep questions**. Each is a *depth* question by
63
- construction comparative, mechanism-level, or contradiction-aware chosen so a
63
+ construction, comparative, mechanism-level, or contradiction-aware, chosen so a
64
64
  single web search for the topic name does **not** surface the answer:
65
65
 
66
- - *speculative decoding* the rejection-sampling acceptance rule and why output
66
+ - *speculative decoding*, the rejection-sampling acceptance rule and why output
67
67
  is lossless; how self-speculative/Medusa (no draft model) trades off vs the
68
68
  two-model scheme; what bounds the speedup; why one verify pass is ~free.
69
- - *LoRA* the `W = W₀ + BA` update and which matrices train; QLoRA's 4-bit
69
+ - *LoRA*, the `W = W₀ + BA` update and which matrices train; QLoRA's 4-bit
70
70
  tradeoff; why LoRA adds zero inference latency (merge); the very-low-rank claim.
71
- - *grouped-query attention* the MQA↔GQA↔MHA spectrum of KV heads; the real
71
+ - *grouped-query attention*, the MQA↔GQA↔MHA spectrum of KV heads; the real
72
72
  bottleneck (KV cache / memory bandwidth, not FLOPs); uptraining from a
73
73
  checkpoint; the MQA quality cost GQA recovers.
74
- - *RLHF/PPO* the KL-to-reference penalty and what it prevents; the pairwise
74
+ - *RLHF/PPO*, the KL-to-reference penalty and what it prevents; the pairwise
75
75
  preference reward model + Bradley-Terry loss; DPO's reward-model-free insight;
76
76
  PPO's clipped surrogate.
77
- - *mixture-of-experts* top-k routing and sparse activation; load imbalance + the
77
+ - *mixture-of-experts*, top-k routing and sparse activation; load imbalance + the
78
78
  auxiliary balancing loss; params-decoupled-from-FLOPs; the memory cost at
79
79
  inference.
80
80
 
@@ -83,7 +83,7 @@ any loop.** A loop is told only the topic name and the *same generic readiness
83
83
  specs* every arm gets ("what X is and how it works" / "results, mechanisms,
84
84
  trade-offs"). It researches blind. **After** it finishes, we grade the KB it built
85
85
  against the held-out questions with a **$0 deterministic substring grader** (no
86
- LLM so the exam cannot leak into a model the loop observes), where each question
86
+ LLM, so the exam cannot leak into a model the loop observes), where each question
87
87
  carries the specific load-bearing answer tokens as keyword groups (a number, a
88
88
  name, a mechanism phrase), with synonym groups so a faithful page in its own words
89
89
  still grades as answered.
@@ -95,21 +95,21 @@ still grades as answered.
95
95
  | a one-line topic-definition snippet (what a single search returns) | **0 / 20** |
96
96
  | a deep, mechanism-rich paragraph | **20 / 20** |
97
97
 
98
- So a high score is only reachable by depth the firewall is real, and the gap
98
+ So a high score is only reachable by depth, the firewall is real, and the gap
99
99
  between arms (if any) would be real depth, not grader slack.
100
100
 
101
101
  ## 3. The three arms, at equal compute
102
102
 
103
103
  [`tests/loops/research-driving-ab.test.ts`](../../tests/loops/research-driving-ab.test.ts).
104
104
  All three arms run the **same** real web worker
105
- ([`createWebResearchWorker`](../../src/web-research-worker.ts) glm-5.2 query-gen
105
+ ([`createWebResearchWorker`](../../src/web-research-worker.ts), glm-5.2 query-gen
106
106
  → live `/v1/search` → `politeFetch` → `htmlToText`). They differ **only** in the
107
107
  driver:
108
108
 
109
- - **(A) single-agent collection** the worker alone, no driver. It collects.
110
- - **(B) verify/dedup** [`createVerifyingResearchDriver`](../../src/web-research-worker.ts):
109
+ - **(A) single-agent collection**: the worker alone, no driver. It collects.
110
+ - **(B) verify/dedup**: [`createVerifyingResearchDriver`](../../src/web-research-worker.ts):
111
111
  a second glm-5.2 pass filters each source for relevance / near-duplicates.
112
- - **(C) DRIVING** [`createResearchDrivingDriver`](../../src/research-driving-driver.ts):
112
+ - **(C) DRIVING**: [`createResearchDrivingDriver`](../../src/research-driving-driver.ts):
113
113
  the driver extracts each source's claims (glm-5.2), tracks independent-source
114
114
  support + contradictions, and folds comparative / mechanism / gap /
115
115
  contradiction sub-questions into the worker's next prompt.
@@ -118,10 +118,10 @@ driver:
118
118
  single-agent iteration is 1 worker pass; a two-agent round is 1 worker + 1 driver
119
119
  pass = 2. Each arm gets the same pass ceiling B; the single-agent arm gets more
120
120
  iterations to spend the budget the two-agent arms burn on their driver. Cost is
121
- read per-arm from `RouterClient.usage()` measured dollars/tokens/calls, not
121
+ read per-arm from `RouterClient.usage()`, measured dollars/tokens/calls, not
122
122
  estimates.
123
123
 
124
- ## 4. Result driving does not reliably win, and the verdict flips with budget
124
+ ## 4. Result: driving does not reliably win, and the verdict flips with budget
125
125
 
126
126
  Per-topic held-out questions answered (out of 4 each), at both budgets:
127
127
 
@@ -134,15 +134,15 @@ Per-topic held-out questions answered (out of 4 each), at both budgets:
134
134
  | mixture-of-experts | 4 / 4 | 4 / 3 | 4 / 3 |
135
135
  | **total /20** | **13 / 15** | **15 / 15** | **16 / 13** |
136
136
 
137
- The driving arm answers **16** at B=4 and **13** at B=6 a 3-question swing on
137
+ The driving arm answers **16** at B=4 and **13** at B=6, a 3-question swing on
138
138
  the *same* exam, the same arm, just a different compute ceiling and a different
139
139
  minute of web results. Single swings 13→15; verify is flat 15→15. **The within-arm
140
140
  swing is as large as the between-arm gap**, which is the signature of a null:
141
141
  whatever separates a "win" from a "loss" here is web variance, not the driver.
142
142
 
143
143
  The **cost**, by contrast, is stable and large. Driving spends **~$0.084–0.089**
144
- across 5 topics vs **~$0.005–0.007** for single-agent **12–16× the dollars** and
145
- **~24× the tokens** (~70k vs ~2.5k) because it runs a claim-extraction LLM call
144
+ across 5 topics vs **~$0.005–0.007** for single-agent, **12–16× the dollars** and
145
+ **~24× the tokens** (~70k vs ~2.5k), because it runs a claim-extraction LLM call
146
146
  on every fetched source. For that 12–16× it buys no reliable held-out-question
147
147
  gain over plain collection.
148
148
 
@@ -151,18 +151,18 @@ gain over plain collection.
151
151
  The decisive diagnostic is `passes=2` on **every** topic at **every** budget: the
152
152
  two-agent loop ran exactly **one** worker round before the readiness gate reported
153
153
  done, even with B=6 budget for three rounds. The generic specs require one source
154
- to close a gap, and the worker's first-round fetch closes them so the loop stops
154
+ to close a gap, and the worker's first-round fetch closes them, so the loop stops
155
155
  before round 2. The driving driver's mechanism is *multi-round*: round 1 extracts
156
156
  claims and flags the weakly-supported ones; round 2+ is where it steers the worker
157
157
  to corroborate and go deeper. **It never got a round 2.** So in this setting
158
158
  driving's only active effect was a one-round claim-extraction tax with no chance to
159
- use what it extracted which is exactly what the numbers show: same answers as
159
+ use what it extracted, which is exactly what the numbers show: same answers as
160
160
  collection, much higher cost.
161
161
 
162
162
  That makes the equal-compute/generic-gate A/B a test of the wrong thing for the
163
163
  driving thesis. The fair test has to *force* multiple rounds.
164
164
 
165
- ## 5. Controlled multi-round probe — the driving thesis's fairest test
165
+ ## 5. Controlled multi-round probe
166
166
 
167
167
  To isolate "does depth-steering help **when it actually runs**?", we raise the
168
168
  readiness bar so the gate stays unmet and the loop runs the full round budget,
@@ -172,23 +172,23 @@ worker **re-searches the same gaps blind** (a no-op driver that accepts every
172
172
  source and never steers). If driving's steering has any value, this is where it
173
173
  shows.
174
174
 
175
- **Result 3 rounds, 3 topics, driving steers vs blind re-search:**
175
+ **Result, 3 rounds, 3 topics, driving steers vs blind re-search:**
176
176
 
177
177
  | topic | driving (steered) answered / cost | blind (no steer) answered / cost |
178
178
  |---|---|---|
179
- | speculative decoding | 2/4 $0.032 | **4/4 $0.004** |
180
- | LoRA | 3/4 $0.028 | 3/4 $0.003 |
181
- | RLHF / PPO | **3/4** $0.033 | 1/4 $0.003 |
182
- | **total /12** | **8/12 $0.093** | **8/12 $0.010** |
179
+ | speculative decoding | 2/4; $0.032 | **4/4; $0.004** |
180
+ | LoRA | 3/4; $0.028 | 3/4; $0.003 |
181
+ | RLHF / PPO | **3/4**; $0.033 | 1/4; $0.003 |
182
+ | **total /12** | **8/12; $0.093** | **8/12; $0.010** |
183
183
 
184
- **Steering does not help: 8 vs 8, at ~9× the cost.** Given its fairest test the
185
- full multi-round regime its mechanism was designed for the driving driver ties a
184
+ **Steering does not help: 8 vs 8, at ~9× the cost.** In the controlled test, the
185
+ full multi-round regime its mechanism was designed for, the driving driver ties a
186
186
  blind worker that just re-searches the same gaps three times. It is **better on
187
187
  RLHF** (3 vs 1, the one topic where chasing corroboration found a page blind
188
- re-search missed) and **worse on speculative decoding** (2 vs 4 steering pulled
188
+ re-search missed) and **worse on speculative decoding** (2 vs 4, steering pulled
189
189
  the worker *off* the pages that answered the exam and toward corroborating a
190
190
  narrower claim set). Those cancel. So the depth-steering does change *what* gets
191
- fetched, but not *how many* held-out questions get answered and it pays ~9× the
191
+ fetched, but not *how many* held-out questions get answered, and it pays ~9× the
192
192
  dollars for the privilege. The headline null (§4) is therefore **not** merely a
193
193
  gate artifact: even forced to run, driving does not beat blind collection on
194
194
  research quality at this n.
@@ -198,13 +198,13 @@ research quality at this n.
198
198
  - **Small n, high web variance.** n = 5 topics; one live run per arm per budget.
199
199
  The §4 budget-flip is itself the evidence that the per-run magnitudes are
200
200
  variance-bound. We did not run a paired bootstrap because the within-arm swing
201
- already exceeds the between-arm gap the honest read is "no separation," and a
201
+ already exceeds the between-arm gap, the supported conclusion is "no separation," and a
202
202
  significance test on a known-null at n=5 would dress it up, not clarify it.
203
- - **The gate, not the driver, ended the headline loop (§4) but the probe
203
+ - **The gate, not the driver, ended the headline loop (§4), but the probe
204
204
  controls for it.** The headline A/B's generic one-source readiness gate closed
205
205
  every loop after one round, so on its own it would only show "driving adds a
206
206
  one-round extraction tax." The §5 probe removes that confound by forcing 3
207
- rounds, and driving still ties blind (8 vs 8) so the null survives the fix,
207
+ rounds, and driving still ties blind (8 vs 8), so the null survives the fix,
208
208
  it is not an artifact of the permissive gate.
209
209
  - **The worker is shared and shallow.** All arms use the same ~500-line direct
210
210
  pipeline (query-gen → search → fetch), not an `AgentProfile` on a harness. A
@@ -220,15 +220,15 @@ research quality at this n.
220
220
  ## 7. What this says, plainly
221
221
 
222
222
  Adding a "drive it deeper" agent did **not** make the research measurably better at
223
- answering hard, held-out questions at equal compute (§4) *and* forced to run its
224
- full multi-round mechanism (§5), on this worker, at n=5 and it cost 9–16× more.
223
+ answering hard, held-out questions, at equal compute (§4) *and* forced to run its
224
+ full multi-round mechanism (§5), on this worker, at n=5, and it cost 9–16× more.
225
225
  The steering changes *what* gets fetched (it helped on RLHF, hurt on speculative
226
226
  decoding) but not *how many* held-out questions get answered. The most durable
227
- thing the experiment produced is the **measurement apparatus**: a firewalled
227
+ thing the experiment produced is the **measurement method**: a firewalled
228
228
  deep-question exam with a $0 deterministic grader that *can* tell depth from
229
229
  surface (0/20 vs 20/20), reusable for any future research-quality claim in this
230
- repo. The driving thesis that pursuing depth + corroboration beats plain
231
- collection is, on the evidence here, **not supported**; the cheaper paths
230
+ repo. The driving thesis, that pursuing depth + corroboration beats plain
231
+ collection, is, on the evidence here, **not supported**; the cheaper paths
232
232
  (collect, or dedup) match it. Where it might still earn its cost: a worker rich
233
233
  enough that "go corroborate this claim" reaches a page blind re-search can't
234
234
  (the RLHF case), measured at an n large enough to separate that from variance.
@@ -242,24 +242,24 @@ cd agent-knowledge && pnpm install
242
242
  # offline: the exam wiring + the $0 grader (no credentials)
243
243
  pnpm exec vitest run tests/loops/research-driving-ab.test.ts
244
244
 
245
- # the live 3-arm A/B real web search + glm-5.2, per-arm cost reported
245
+ # the live 3-arm A/B: real web search + glm-5.2, per-arm cost reported
246
246
  export TANGLE_API_KEY=<router key with glm-5.2 credits>
247
247
  AGENT_KNOWLEDGE_LIVE=1 RQ_LIVE_BUDGET=4 \
248
248
  pnpm exec vitest run tests/loops/research-driving-ab.test.ts -t "3-arm A/B"
249
249
  # re-run at RQ_LIVE_BUDGET=6 to see the verdict flip (the §4 variance point)
250
250
 
251
- # the controlled multi-round probe forces N rounds so driving actually steers
251
+ # the controlled multi-round probe: forces N rounds so driving actually steers
252
252
  AGENT_KNOWLEDGE_LIVE=1 RQ_PROBE=1 RQ_PROBE_ROUNDS=3 TANGLE_API_KEY=<…> \
253
253
  pnpm exec vitest run tests/loops/research-driving-ab.test.ts -t "multi-round probe"
254
254
  # (~$0.10 for the 5-topic A/B at one budget; ~$0.10 for the 3-topic probe)
255
255
  ```
256
256
 
257
257
  `RQ_LIVE_TOPICS` takes a `|`-separated subset of the exam topic names to run a
258
- cheaper slice. The exam is held out by construction no flag shows it to a loop.
258
+ cheaper slice. The exam is held out by construction, no flag shows it to a loop.
259
259
 
260
- **Source:** the exam + grader
260
+ **Source:** the exam and grader:
261
261
  [`tests/loops/held-out-exam.ts`](../../tests/loops/held-out-exam.ts);
262
- the 3-arm A/B + multi-round probe
262
+ the 3-arm A/B and multi-round probe:
263
263
  [`tests/loops/research-driving-ab.test.ts`](../../tests/loops/research-driving-ab.test.ts);
264
- the driving driver under test
264
+ the driving driver under test:
265
265
  [`src/research-driving-driver.ts`](../../src/research-driving-driver.ts).