@tangle-network/agent-bench 0.14.4 → 1.0.2
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.
- package/CHANGELOG.md +46 -0
- package/README.md +2 -3
- package/dist/adapters.d.ts +2 -5
- package/dist/adapters.js +3 -4
- package/dist/benchmarks/_harness.d.ts +17 -20
- package/dist/benchmarks/_harness.js +4 -4
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +1 -4
- package/dist/benchmarks/aec-bench.js +1 -2
- package/dist/benchmarks/agentbench.d.ts +2 -5
- package/dist/benchmarks/agentbench.js +1 -2
- package/dist/benchmarks/appworld.d.ts +8 -10
- package/dist/benchmarks/appworld.js +23 -23
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -5
- package/dist/benchmarks/bfcl.js +1 -2
- package/dist/benchmarks/cad-design.d.ts +2 -5
- package/dist/benchmarks/cad-design.js +2 -3
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +1 -4
- package/dist/benchmarks/cadbench.js +1 -2
- package/dist/benchmarks/cadgenbench.d.ts +1 -4
- package/dist/benchmarks/cadgenbench.js +1 -2
- package/dist/benchmarks/commit0.d.ts +2 -5
- package/dist/benchmarks/commit0.js +1 -2
- package/dist/benchmarks/crag.d.ts +1 -4
- package/dist/benchmarks/crag.js +3 -3
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -5
- package/dist/benchmarks/dabstep.js +2 -3
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
- package/dist/benchmarks/enterpriseops-gym.js +1 -2
- package/dist/benchmarks/finresearchbench.d.ts +2 -5
- package/dist/benchmarks/finresearchbench.js +2 -3
- package/dist/benchmarks/finsearchcomp.d.ts +2 -5
- package/dist/benchmarks/finsearchcomp.js +4 -4
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +3 -19
- package/dist/benchmarks/frames.js +13 -39
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -14
- package/dist/benchmarks/hotpotqa.js +12 -32
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +9 -12
- package/dist/benchmarks/humaneval.js +2 -3
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +13 -16
- package/dist/benchmarks/mcad-bench.js +2 -3
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
- package/dist/benchmarks/mcad-cq-bench.js +2 -3
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
- package/dist/benchmarks/mcad-cq-golds.js +1 -2
- package/dist/benchmarks/mcad-golds.d.ts +1 -4
- package/dist/benchmarks/mcad-golds.js +0 -1
- package/dist/benchmarks/mcad-tasks.d.ts +5 -8
- package/dist/benchmarks/mcad-tasks.js +7 -8
- package/dist/benchmarks/mcad-tasks.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -5
- package/dist/benchmarks/mind2web.js +2 -3
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +1 -4
- package/dist/benchmarks/nomiracl.js +1 -2
- package/dist/benchmarks/open-rag-bench.d.ts +1 -4
- package/dist/benchmarks/open-rag-bench.js +3 -3
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -5
- package/dist/benchmarks/programbench.js +1 -2
- package/dist/benchmarks/rag-shared.d.ts +30 -22
- package/dist/benchmarks/rag-shared.js +8 -2
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +1 -4
- package/dist/benchmarks/ragbench.js +3 -3
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -18
- package/dist/benchmarks/simpleqa.js +5 -31
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +7 -10
- package/dist/benchmarks/swe-bench.js +4 -4
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +1 -4
- package/dist/benchmarks/t2-ragbench.js +3 -3
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
- package/dist/benchmarks/tau-bench-shared.js +4 -4
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -5
- package/dist/benchmarks/tau2-bench.js +1 -2
- package/dist/benchmarks/tau3-banking.d.ts +1 -4
- package/dist/benchmarks/tau3-banking.js +1 -2
- package/dist/benchmarks/terminal-bench.d.ts +1 -4
- package/dist/benchmarks/terminal-bench.js +4 -4
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -5
- package/dist/benchmarks/toollm.js +1 -2
- package/dist/benchmarks/trata-hedge.d.ts +1 -4
- package/dist/benchmarks/trata-hedge.js +2 -3
- package/dist/benchmarks/types.d.ts +6 -9
- package/dist/benchmarks/webarena-verified.d.ts +2 -5
- package/dist/benchmarks/webarena-verified.js +1 -2
- package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
- package/dist/cadbench-DhAndllg.js.map +1 -0
- package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
- package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
- package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
- package/package.json +10 -10
- package/pier_agents/tangle_candidate.py +15 -23
- package/scripts/run-package-tests.mjs +8 -15
- package/src/atom-mcp-e2e.mts +2 -2
- package/src/benchmarks/frames.ts +10 -44
- package/src/benchmarks/hotpotqa.ts +9 -29
- package/src/benchmarks/rag-shared.ts +12 -0
- package/src/benchmarks/simpleqa.ts +2 -36
- package/src/commit0-prereqs.sh +0 -0
- package/src/corpus-replay.mts +8 -8
- package/src/corpus-report.mts +21 -21
- package/src/corpus.test.mts +5 -5
- package/src/corpus.ts +16 -16
- package/src/directives.ts +0 -38
- package/src/examples/lean-verify.ts +1 -1
- package/src/gate.ts +7 -7
- package/src/generate-eval/certify.ts +2 -2
- package/src/index.ts +1 -0
- package/src/refine-loop.ts +5 -5
- package/src/resolve-client.ts +1 -1
- package/src/router-turn.ts +3 -11
- package/src/run-pool.ts +1 -1
- package/src/runtime-hook-recorder.ts +2 -2
- package/src/search-bench/tasks.ts +1 -1
- package/src/selector.test.mts +13 -13
- package/src/selector.ts +19 -19
- package/src/swe-bench-env.ts +4 -12
- package/src/swe-jail.ts +5 -156
- package/src/swe-structural-judge-policy.ts +3 -3
- package/src/swe-structural-policy.ts +3 -3
- package/src/swe-structural-provenance.ts +4 -4
- package/src/terminal-compare.ts +10 -10
- package/src/worker-blender.ts +2 -106
- package/src/worker-build123d.ts +2 -81
- package/tb_agents/opencode_router_agent.py +1 -1
- package/dist/cadbench-BRF-59Mt.js.map +0 -1
- package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
- package/dist/router-turn-uTYO6KQ1.js.map +0 -1
- package/scripts/cadbench_prepare.py +0 -22
- package/scripts/cadgenbench_hard_parts.py +0 -48
- package/scripts/clbench_codebase_judge.py +0 -73
- package/scripts/render-gate-chart.mjs +0 -176
- package/scripts/trata-hedge/README.md +0 -57
- package/scripts/trata-hedge/run.sh +0 -64
- package/src/cloud-loop.mts +0 -156
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -141
- package/src/profiles.ts +0 -128
- package/src/research-gate.mts +0 -132
- package/src/research-shot.ts +0 -144
- package/src/router-executor.ts +0 -51
- package/src/sandbox-run.ts +0 -108
- package/src/search-bench/bridge.ts +0 -182
- package/src/search-bench/export.mts +0 -0
- package/src/search-bench/parametric-check.mts +0 -78
- package/src/search-bench/profiles.ts +0 -113
- package/src/search-bench/run.mts +0 -286
- package/src/search-bench/tasks-fresh.ts +0 -688
- package/src/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-improve.mts +0 -284
- package/src/swe-structural.mts +0 -707
- package/src/tb-container-executor.mts +0 -266
- package/src/tb-container-executor.test.mts +0 -134
- package/src/tb-supervisor-sidecar.mts +0 -208
- package/src/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
package/src/sandbox-run.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared sandbox-rollout helpers for the bench harnesses.
|
|
3
|
-
*
|
|
4
|
-
* The worker plumbing every sandbox-backed bench needs, independent of how the
|
|
5
|
-
* loop is driven: build the standard `AgentRunSpec` (`sandboxAgentRun`), parse
|
|
6
|
-
* the agent's final answer from the event stream (`answerOutput`), name the
|
|
7
|
-
* cost-dial backend (`WorkerBackendType`), and run a single-model "review the
|
|
8
|
-
* prior attempt" analyst (`llmAnalyst`/`AnalystFn`). These are pure profile /
|
|
9
|
-
* backend / parsing plumbing — no experiment shell, no topology arms.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
type AgentProfile,
|
|
14
|
-
type AgentRunSpec,
|
|
15
|
-
type OutputAdapter,
|
|
16
|
-
} from '@tangle-network/agent-runtime/kernel'
|
|
17
|
-
import { parseExactAgentProfile } from '@tangle-network/agent-runtime/candidate-execution'
|
|
18
|
-
|
|
19
|
-
// `BackendType` is the sandbox SDK's harness union and its canonical home. Runtime consumes it
|
|
20
|
-
// from there too; benchmark profiles use the same values as their exact harness identity.
|
|
21
|
-
import type { BackendType } from '@tangle-network/sandbox'
|
|
22
|
-
import { assertExecutableAgentProfile } from '../../src/runtime/supervise/model-policy'
|
|
23
|
-
import { benchRouterProfile, runBenchRouterTurn } from './router-turn'
|
|
24
|
-
|
|
25
|
-
/** Parse the agent's final answer from the event stream (harness-agnostic).
|
|
26
|
-
* The default deliverable; a benchmark whose artifact is a file overrides via
|
|
27
|
-
* its own `OutputAdapter` that reads from the run. */
|
|
28
|
-
export const answerOutput: OutputAdapter<string> = {
|
|
29
|
-
parse(events) {
|
|
30
|
-
let answer = ''
|
|
31
|
-
for (const ev of events) {
|
|
32
|
-
const d = (ev as { data?: Record<string, unknown> })?.data
|
|
33
|
-
const t = d?.finalText ?? d?.text ?? d?.result
|
|
34
|
-
if (typeof t === 'string' && t.length > 0) answer = t
|
|
35
|
-
}
|
|
36
|
-
return answer
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** What an analyst sees of each prior attempt: its output, its verdict, and its
|
|
41
|
-
* raw trace events. The events are the trace an analyst reads. */
|
|
42
|
-
export type SteerHistory = ReadonlyArray<{
|
|
43
|
-
output?: string
|
|
44
|
-
verdict?: { valid?: boolean; score?: number; notes?: string }
|
|
45
|
-
events?: readonly unknown[]
|
|
46
|
-
}>
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The investigation: read the prior attempt's trace, return targeted feedback for
|
|
50
|
-
* the next one. It observes BEHAVIOR (output, trace), never the judge's verdict —
|
|
51
|
-
* the selector != judge firewall.
|
|
52
|
-
*/
|
|
53
|
-
export type AnalystFn = (history: SteerHistory, task?: string) => Promise<string>
|
|
54
|
-
|
|
55
|
-
/** Simple analyst: ONE model call reads the public task plus a bounded view of the
|
|
56
|
-
* last attempt (its output + a tail of its trace events) and returns a concrete
|
|
57
|
-
* correction. Selector != judge firewall: it NEVER reads the held-out judge's
|
|
58
|
-
* verdict or failure detail — that would be a non-deployable oracle gradient
|
|
59
|
-
* toward the reference answer. A deployable steerer must locate the fault from the
|
|
60
|
-
* task and the agent's own behavior alone. */
|
|
61
|
-
export const llmAnalyst = (cfg: { routerBaseUrl: string; routerKey: string; model: string }): AnalystFn =>
|
|
62
|
-
async (history, task) => {
|
|
63
|
-
const last = history.at(-1)
|
|
64
|
-
const traceTail = (last?.events ?? [])
|
|
65
|
-
.slice(-12)
|
|
66
|
-
.map((e) => (typeof e === 'string' ? e : JSON.stringify(e)))
|
|
67
|
-
.join('\n')
|
|
68
|
-
.slice(-2000)
|
|
69
|
-
const systemPrompt =
|
|
70
|
-
"You review an AI agent's previous attempt at a task. From the task, the attempt's output, and its execution trace ALONE, judge whether it correctly and completely solved the task. If you find a specific fault — a wrong value, a guessed API signature, a missing step, a misread requirement — name it and give the concrete correction in 1-3 sentences. Reply exactly 'no change needed' if the attempt looks correct and complete."
|
|
71
|
-
const turn = await runBenchRouterTurn(
|
|
72
|
-
{
|
|
73
|
-
routerBaseUrl: cfg.routerBaseUrl,
|
|
74
|
-
routerKey: cfg.routerKey,
|
|
75
|
-
profile: benchRouterProfile('sandbox-run-analyst', cfg.model, { systemPrompt }),
|
|
76
|
-
},
|
|
77
|
-
`Task:\n${task ?? '(task unavailable)'}\n\nPrevious answer:\n${last?.output ?? '(none)'}\n\nTrace tail:\n${traceTail}`,
|
|
78
|
-
)
|
|
79
|
-
return turn.finalText
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Cost-dial backend = the SDK's canonical `BackendType` (single source of truth; no local
|
|
83
|
-
* literal copy that drifts from the harness set). `hermes` = the inference-router agent (the
|
|
84
|
-
* cheap "router llm-call" dial); the rest are agent CLIs. The ONLY knob that changes which
|
|
85
|
-
* agent runs — no per-backend worker. */
|
|
86
|
-
export type WorkerBackendType = BackendType
|
|
87
|
-
|
|
88
|
-
/** Build the standard sandbox `AgentRunSpec` for a benchmark. The complete profile is the only
|
|
89
|
-
* behavioral input: its harness selects the box backend and its provider/model select inference.
|
|
90
|
-
* Extra sandbox env remains infrastructure, not a second model-selection path. */
|
|
91
|
-
export function sandboxAgentRun(opts: {
|
|
92
|
-
profile: AgentProfile
|
|
93
|
-
taskToPrompt?: (task: string) => string
|
|
94
|
-
/** Extra box-level env (e.g. `TANGLE_SEARCH_DEFAULT_PROVIDER` to pin the in-box
|
|
95
|
-
* agent's web-search provider, provider keys like EXA_API_KEY). Allowlisted
|
|
96
|
-
* keys only reach the spawned CLI. Must NOT carry router/model credentials. */
|
|
97
|
-
env?: Record<string, string>
|
|
98
|
-
}): AgentRunSpec<string> {
|
|
99
|
-
const profile = parseExactAgentProfile(opts.profile, 'sandboxAgentRun profile')
|
|
100
|
-
assertExecutableAgentProfile(profile, 'sandboxAgentRun profile')
|
|
101
|
-
const name = profile.name ?? 'sandbox-worker'
|
|
102
|
-
return {
|
|
103
|
-
profile,
|
|
104
|
-
name,
|
|
105
|
-
taskToPrompt: opts.taskToPrompt ?? ((t) => t),
|
|
106
|
-
...(opts.env ? { sandboxOverrides: { env: opts.env } } : {}),
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cli-bridge cell executor — the unblocked path to the head-to-head numbers
|
|
3
|
-
* while the sandbox sidecar image is pending #1810.
|
|
4
|
-
*
|
|
5
|
-
* Same arms, same deterministic oracle, same export. The only difference from
|
|
6
|
-
* the sandbox path is HOW the harness runs: a single OpenAI-compatible chat call
|
|
7
|
-
* to the local cli-bridge (`/v1/chat/completions`) with an `agent_profile` that
|
|
8
|
-
* (a) disables native web tools via `metadata.disallowedTools` and (b) adds the
|
|
9
|
-
* provider search MCP via `mcp` — both PROVEN to work on the bridge. Native arm
|
|
10
|
-
* leaves the harness untouched.
|
|
11
|
-
*
|
|
12
|
-
* The bridge model id IS the harness selector (e.g. `claude-code/sonnet`,
|
|
13
|
-
* `opencode/zai-coding-plan/glm-5.1`), so `harness` here is just the label.
|
|
14
|
-
*/
|
|
15
|
-
import { createExecutor } from '@tangle-network/agent-runtime/kernel'
|
|
16
|
-
import {
|
|
17
|
-
defineAgentProfileSecretRef,
|
|
18
|
-
harnessProviders,
|
|
19
|
-
type AgentProfile,
|
|
20
|
-
type HarnessType,
|
|
21
|
-
} from '@tangle-network/agent-interface'
|
|
22
|
-
import type { SearchArm } from './profiles'
|
|
23
|
-
import { armLabel } from './profiles'
|
|
24
|
-
import type { SearchCellResult } from './run.mts'
|
|
25
|
-
import { type SearchTask, scoreTask, taskToPrompt } from './tasks'
|
|
26
|
-
|
|
27
|
-
const nativeWebDisallowed = ['WebSearch', 'WebFetch', 'web_search', 'web_fetch', 'websearch', 'webfetch', 'fetch']
|
|
28
|
-
|
|
29
|
-
/** Build the cli-bridge `agent_profile` for one arm (bridge dialect: disable via
|
|
30
|
-
* `metadata.disallowedTools`, search MCP via `mcp.<name>.transport:'http'`). */
|
|
31
|
-
function bridgeProfile(
|
|
32
|
-
arm: SearchArm,
|
|
33
|
-
routerSearchMcp: string,
|
|
34
|
-
tangleApiKey: string,
|
|
35
|
-
label: string,
|
|
36
|
-
harness: HarnessType,
|
|
37
|
-
wireModel: string,
|
|
38
|
-
): AgentProfile {
|
|
39
|
-
const prefix = `${harness}/`
|
|
40
|
-
if (!wireModel.startsWith(prefix)) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
`bridgeProfile: wire model '${wireModel}' must start with harness '${prefix}'`,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
const modelPath = wireModel.slice(prefix.length)
|
|
46
|
-
const segments = modelPath.split('/').filter(Boolean)
|
|
47
|
-
if (segments.length === 0) {
|
|
48
|
-
throw new Error(`bridgeProfile: wire model '${wireModel}' has no model id`)
|
|
49
|
-
}
|
|
50
|
-
let provider: string
|
|
51
|
-
let model: string
|
|
52
|
-
if (segments.length === 1) {
|
|
53
|
-
const providers = harnessProviders(harness)
|
|
54
|
-
if (providers?.length !== 1) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`bridgeProfile: wire model '${wireModel}' must include a provider for harness '${harness}'`,
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
provider = providers[0]!
|
|
60
|
-
model = segments[0]!
|
|
61
|
-
} else {
|
|
62
|
-
provider = segments[0]!
|
|
63
|
-
model = segments.slice(1).join('/')
|
|
64
|
-
}
|
|
65
|
-
const identity: AgentProfile = {
|
|
66
|
-
name: `search-bench-${label}`,
|
|
67
|
-
harness,
|
|
68
|
-
model: { provider, default: model },
|
|
69
|
-
}
|
|
70
|
-
if (arm === 'native') return identity
|
|
71
|
-
const base: AgentProfile = {
|
|
72
|
-
...identity,
|
|
73
|
-
metadata: { disallowedTools: nativeWebDisallowed },
|
|
74
|
-
}
|
|
75
|
-
if (arm === 'off') return base
|
|
76
|
-
if (!tangleApiKey) {
|
|
77
|
-
throw new Error(`bridgeProfile: provider arm requires TANGLE_API_KEY`)
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
...base,
|
|
81
|
-
mcp: {
|
|
82
|
-
tangle_search: {
|
|
83
|
-
transport: 'http',
|
|
84
|
-
url: `${routerSearchMcp}?provider=${encodeURIComponent(arm.provider)}`,
|
|
85
|
-
headers: {
|
|
86
|
-
Authorization: defineAgentProfileSecretRef('TANGLE_API_KEY', 'bearer'),
|
|
87
|
-
},
|
|
88
|
-
enabled: true,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const urlRe = /https?:\/\/[^\s)\]}"'<>]+/gi
|
|
95
|
-
function citationsOf(answer: string): string[] {
|
|
96
|
-
return [...new Set((answer.match(urlRe) ?? []).map((u) => u.replace(/[.,;]+$/, '')))]
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface BridgeCfg {
|
|
100
|
-
bridgeUrl: string
|
|
101
|
-
bridgeBearer: string
|
|
102
|
-
tangleApiKey: string
|
|
103
|
-
/** Router search-MCP endpoint, e.g. https://router.tangle.tools/v1/search/mcp */
|
|
104
|
-
routerSearchMcp: string
|
|
105
|
-
/** harness label → cli-bridge model id (the harness selector). */
|
|
106
|
-
bridgeModels: Record<string, string>
|
|
107
|
-
timeoutMs?: number
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export async function runBridgeCell(
|
|
111
|
-
cfg: BridgeCfg,
|
|
112
|
-
task: SearchTask,
|
|
113
|
-
harness: HarnessType,
|
|
114
|
-
arm: SearchArm,
|
|
115
|
-
): Promise<SearchCellResult> {
|
|
116
|
-
const startedAt = Date.now()
|
|
117
|
-
const armId = armLabel(arm)
|
|
118
|
-
const base = {
|
|
119
|
-
taskId: task.id,
|
|
120
|
-
domain: task.domain,
|
|
121
|
-
harness,
|
|
122
|
-
arm: armId,
|
|
123
|
-
model: cfg.bridgeModels[harness] ?? harness,
|
|
124
|
-
ts: new Date(startedAt).toISOString(),
|
|
125
|
-
}
|
|
126
|
-
const controller = new AbortController()
|
|
127
|
-
const timer = setTimeout(() => controller.abort(), cfg.timeoutMs ?? 300_000)
|
|
128
|
-
try {
|
|
129
|
-
// One harness turn through the unified bridge executor — same backend the
|
|
130
|
-
// loop path uses; this cell scorer just adds oracle scoring + citations.
|
|
131
|
-
const profile = bridgeProfile(
|
|
132
|
-
arm,
|
|
133
|
-
cfg.routerSearchMcp,
|
|
134
|
-
cfg.tangleApiKey,
|
|
135
|
-
`${harness}-${armId}`,
|
|
136
|
-
harness,
|
|
137
|
-
cfg.bridgeModels[harness] ?? harness,
|
|
138
|
-
)
|
|
139
|
-
const exec = createExecutor({
|
|
140
|
-
backend: 'bridge',
|
|
141
|
-
bridgeUrl: cfg.bridgeUrl,
|
|
142
|
-
bridgeBearer: cfg.bridgeBearer,
|
|
143
|
-
timeoutMs: cfg.timeoutMs ?? 300_000,
|
|
144
|
-
})({ profile, harness: null }, { signal: controller.signal, seams: {} })
|
|
145
|
-
// bridgeExecutor is one-shot (async execute resolves an ExecutorResult).
|
|
146
|
-
const artifact = (await exec.execute(taskToPrompt(task), controller.signal)) as {
|
|
147
|
-
out: unknown
|
|
148
|
-
spent: { tokens: { input: number; output: number }; usd: number }
|
|
149
|
-
}
|
|
150
|
-
const out = artifact.out as { content?: string; toolCalls?: string[] }
|
|
151
|
-
const answer = out.content ?? ''
|
|
152
|
-
const names = out.toolCalls ?? []
|
|
153
|
-
const { score, reasons } = scoreTask(task, answer)
|
|
154
|
-
return {
|
|
155
|
-
...base,
|
|
156
|
-
score,
|
|
157
|
-
reasons,
|
|
158
|
-
...(artifact.spent.usd ? { costUsd: artifact.spent.usd } : {}),
|
|
159
|
-
...(artifact.spent.tokens.input ? { tokensIn: artifact.spent.tokens.input } : {}),
|
|
160
|
-
...(artifact.spent.tokens.output ? { tokensOut: artifact.spent.tokens.output } : {}),
|
|
161
|
-
wallMs: Date.now() - startedAt,
|
|
162
|
-
toolCalls: names.length,
|
|
163
|
-
toolNames: [...new Set(names)],
|
|
164
|
-
citations: citationsOf(answer),
|
|
165
|
-
answer,
|
|
166
|
-
}
|
|
167
|
-
} catch (err) {
|
|
168
|
-
return {
|
|
169
|
-
...base,
|
|
170
|
-
score: null,
|
|
171
|
-
reasons: [],
|
|
172
|
-
wallMs: Date.now() - startedAt,
|
|
173
|
-
toolCalls: 0,
|
|
174
|
-
toolNames: [],
|
|
175
|
-
citations: [],
|
|
176
|
-
answer: '',
|
|
177
|
-
infraError: err instanceof Error ? err.message : String(err),
|
|
178
|
-
}
|
|
179
|
-
} finally {
|
|
180
|
-
clearTimeout(timer)
|
|
181
|
-
}
|
|
182
|
-
}
|
|
Binary file
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Discrimination check: how many fresh-docs tasks does a model get WRONG from
|
|
3
|
-
* memory (no tools, no search)? A high parametric fail-rate is the prerequisite
|
|
4
|
-
* for the whole comparison — if the model already knows the answer, no search
|
|
5
|
-
* backend can help. This is a pure router chat-completion per task, scored by
|
|
6
|
-
* the same deterministic oracle the sandbox run uses. No sandbox, no deploy dep.
|
|
7
|
-
*
|
|
8
|
-
* Run:
|
|
9
|
-
* dotenvx run -f ~/company/devops/secrets/.env.keys -f ~/company/devops/secrets/agent-state.env -- \
|
|
10
|
-
* env MODEL=gpt-4.1 CONCURRENCY=4 pnpm exec tsx src/search-bench/parametric-check.mts
|
|
11
|
-
*/
|
|
12
|
-
import { writeFileSync } from 'node:fs'
|
|
13
|
-
import { runPool } from '../run-pool'
|
|
14
|
-
import { runBenchRouterTurn } from '../router-turn'
|
|
15
|
-
import { freshTasks } from './tasks-fresh'
|
|
16
|
-
import { scoreTask, taskToPrompt } from './tasks'
|
|
17
|
-
|
|
18
|
-
async function main(): Promise<void> {
|
|
19
|
-
const model = process.env.MODEL ?? 'deepseek-v4-flash'
|
|
20
|
-
const routerKey = process.env.TANGLE_API_KEY
|
|
21
|
-
if (!routerKey) throw new Error('missing TANGLE_API_KEY')
|
|
22
|
-
const cfg = {
|
|
23
|
-
routerBaseUrl: process.env.ROUTER_BASE_URL ?? 'https://router.tangle.tools/v1',
|
|
24
|
-
routerKey,
|
|
25
|
-
model,
|
|
26
|
-
}
|
|
27
|
-
const conc = Number(process.env.CONCURRENCY ?? 4)
|
|
28
|
-
|
|
29
|
-
const outcomes = await runPool(freshTasks, conc, async (task) => {
|
|
30
|
-
try {
|
|
31
|
-
const res = await runBenchRouterTurn(
|
|
32
|
-
{
|
|
33
|
-
routerBaseUrl: cfg.routerBaseUrl,
|
|
34
|
-
routerKey: cfg.routerKey,
|
|
35
|
-
profile: {
|
|
36
|
-
name: 'search-parametric-check',
|
|
37
|
-
model: { provider: 'tangle-router', default: model },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
taskToPrompt(task),
|
|
41
|
-
)
|
|
42
|
-
const { score } = scoreTask(task, res.finalText)
|
|
43
|
-
return {
|
|
44
|
-
id: task.id,
|
|
45
|
-
score: score as 0 | 1 | null,
|
|
46
|
-
cost: res.usage.usdKnown === false ? undefined : res.usage.costUsd,
|
|
47
|
-
err: undefined as string | undefined,
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
return { id: task.id, score: null as 0 | 1 | null, cost: undefined, err: err instanceof Error ? err.message : String(err) }
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
const rows = outcomes.map((o) => o.value!).filter(Boolean)
|
|
54
|
-
|
|
55
|
-
const scored = rows.filter((r) => r.score !== null)
|
|
56
|
-
const passed = scored.filter((r) => r.score === 1).length
|
|
57
|
-
const failed = scored.length - passed
|
|
58
|
-
console.log(`\n=== Parametric (no-search) discrimination · ${model} · n=${scored.length} ===`)
|
|
59
|
-
for (const r of rows.sort((a, b) => (a.score ?? -1) - (b.score ?? -1))) {
|
|
60
|
-
console.log(` ${r.score === null ? 'ERR ' : r.score === 1 ? 'KNEW' : 'MISS'} ${r.id}${r.err ? ` (${r.err})` : ''}`)
|
|
61
|
-
}
|
|
62
|
-
console.log(
|
|
63
|
-
`\nparametric FAIL (search-correctable headroom): ${failed}/${scored.length} = ${((failed / scored.length) * 100).toFixed(0)}%` +
|
|
64
|
-
` · model already knew: ${passed}/${scored.length}`,
|
|
65
|
-
)
|
|
66
|
-
if (process.env.PARAM_OUT) {
|
|
67
|
-
writeFileSync(
|
|
68
|
-
process.env.PARAM_OUT,
|
|
69
|
-
rows.map((r) => JSON.stringify({ id: r.id, model, knewParametrically: r.score === 1, score: r.score })).join('\n') + '\n',
|
|
70
|
-
)
|
|
71
|
-
console.log(`wrote per-task baseline → ${process.env.PARAM_OUT}`)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
main().catch((e) => {
|
|
76
|
-
console.error(e)
|
|
77
|
-
process.exit(1)
|
|
78
|
-
})
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-arm AgentProfiles for the coding-harness web-search comparison.
|
|
3
|
-
*
|
|
4
|
-
* Three arms, one variable (the search backend the agent can reach):
|
|
5
|
-
* - `native` — the harness's built-in web search/fetch, untouched. No MCP.
|
|
6
|
-
* - `provider` — native search DISABLED + a router-backed search MCP added
|
|
7
|
-
* (provider-pinned: you / exa / …). The agent's only web access is the MCP.
|
|
8
|
-
*
|
|
9
|
-
* The disable directive is the harness-agnostic `tools` map landed in
|
|
10
|
-
* agent-container#1810 (claude `--disallowed-tools`, codex
|
|
11
|
-
* `-c tools.web_search=false`, opencode `tools.{websearch,webfetch}`). We set
|
|
12
|
-
* both canonical (`web_search`/`web_fetch`) and opencode-native
|
|
13
|
-
* (`websearch`/`webfetch`) keys so a single profile is correct on every harness
|
|
14
|
-
* pre- and post-deploy, plus the opencode `permission.webfetch=deny` belt.
|
|
15
|
-
*
|
|
16
|
-
* The provider MCP mirrors the SDK's official `buildTangleRouterSearchProfile`
|
|
17
|
-
* shape — a `transport:'http'` server at the router's `/v1/search/mcp` endpoint,
|
|
18
|
-
* provider pinned via the `?provider=` query param.
|
|
19
|
-
*/
|
|
20
|
-
import {
|
|
21
|
-
type AgentProfile,
|
|
22
|
-
type HarnessType,
|
|
23
|
-
agentProfileSchema,
|
|
24
|
-
defineAgentProfileSecretRef,
|
|
25
|
-
} from '@tangle-network/agent-interface'
|
|
26
|
-
|
|
27
|
-
export type SearchArm = 'native' | 'off' | { provider: string }
|
|
28
|
-
|
|
29
|
-
const routerSearchMcpUrl = (provider: string, routerBaseUrl: string): string => {
|
|
30
|
-
// routerBaseUrl is typically https://router.tangle.tools/v1 — the search MCP
|
|
31
|
-
// lives at /v1/search/mcp, so trim a trailing /v1 then re-append the path.
|
|
32
|
-
const root = routerBaseUrl.replace(/\/+$/, '').replace(/\/v1$/, '')
|
|
33
|
-
return `${root}/v1/search/mcp?provider=${encodeURIComponent(provider)}`
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Tool keys that turn OFF a harness's native web search/fetch across harnesses. */
|
|
37
|
-
const nativeWebToolsDisabled: Record<string, boolean> = {
|
|
38
|
-
web_search: false,
|
|
39
|
-
web_fetch: false,
|
|
40
|
-
websearch: false,
|
|
41
|
-
webfetch: false,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface BuildArmProfileArgs {
|
|
45
|
-
arm: SearchArm
|
|
46
|
-
/** Router base URL (…/v1). Used to derive the search-MCP endpoint. */
|
|
47
|
-
routerBaseUrl: string
|
|
48
|
-
/** Bearer for the router search MCP. Required for a provider arm. Valid for the
|
|
49
|
-
* `bridge` (local) backend; in `sandbox` mode the box egress proxy rejects
|
|
50
|
-
* foreign router credentials (403), so the provider arm needs the box-side
|
|
51
|
-
* credential flow before sandbox-backed provider runs are trustworthy. */
|
|
52
|
-
tangleApiKey: string
|
|
53
|
-
harness: HarnessType
|
|
54
|
-
model: string
|
|
55
|
-
provider: string
|
|
56
|
-
/** Optional name/metadata to merge. */
|
|
57
|
-
name?: string
|
|
58
|
-
metadata?: Record<string, unknown>
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Build the complete executable AgentProfile for one search arm.
|
|
63
|
-
*/
|
|
64
|
-
export function buildArmProfile(args: BuildArmProfileArgs): AgentProfile {
|
|
65
|
-
const { arm, routerBaseUrl, tangleApiKey } = args
|
|
66
|
-
const base: AgentProfile = {
|
|
67
|
-
name: args.name ?? 'search-bench-worker',
|
|
68
|
-
harness: args.harness,
|
|
69
|
-
model: { provider: args.provider, default: args.model },
|
|
70
|
-
...(args.metadata ? { metadata: args.metadata } : {}),
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (arm === 'native') {
|
|
74
|
-
// Native web tools stay on (harness default). No search MCP. For codex,
|
|
75
|
-
// whose web_search ships off, explicitly enable it so the native arm is real.
|
|
76
|
-
return agentProfileSchema.parse({ ...base, tools: { web_search: true } })
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (arm === 'off') {
|
|
80
|
-
// No web access at all — the parametric floor (search contributes nothing).
|
|
81
|
-
return agentProfileSchema.parse({
|
|
82
|
-
...base,
|
|
83
|
-
tools: { ...nativeWebToolsDisabled },
|
|
84
|
-
permission: { webfetch: 'deny' },
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!tangleApiKey) {
|
|
89
|
-
throw new Error(`buildArmProfile: provider arm "${arm.provider}" requires a tangleApiKey for the search MCP`)
|
|
90
|
-
}
|
|
91
|
-
return agentProfileSchema.parse({
|
|
92
|
-
...base,
|
|
93
|
-
tools: { ...nativeWebToolsDisabled },
|
|
94
|
-
permission: { webfetch: 'deny' },
|
|
95
|
-
mcp: {
|
|
96
|
-
tangle_search: {
|
|
97
|
-
transport: 'http',
|
|
98
|
-
url: routerSearchMcpUrl(arm.provider, routerBaseUrl),
|
|
99
|
-
headers: {
|
|
100
|
-
Authorization: defineAgentProfileSecretRef('TANGLE_API_KEY', 'bearer'),
|
|
101
|
-
},
|
|
102
|
-
enabled: true,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Stable condition label for the corpus: `<harness>:<arm>`. */
|
|
109
|
-
export function armLabel(arm: SearchArm): string {
|
|
110
|
-
if (arm === 'native') return 'native'
|
|
111
|
-
if (arm === 'off') return 'off'
|
|
112
|
-
return arm.provider
|
|
113
|
-
}
|