Skip to content

Commit ee99f34

Browse files
committed
wip: auto-checkpoint from Cursor agent session 20260419T130425
1 parent e3a2118 commit ee99f34

5 files changed

Lines changed: 82 additions & 17 deletions

File tree

docs/POLYGLOT.md

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Forge on Aider polyglot
22

3-
**Current standing (as of 2026-04-18, single-run, Mode A worker-only):**
4-
**Python 34/34 (100%)** + **Rust 30/30 (100%)**. 161 of 225 exercises
5-
remain. See Stage 2 / Stage 2b below for the full numbers and caveats.
3+
**Current standing (as of 2026-04-19, Mode A worker-only):**
4+
**Python 34/34 x 3 runs (100%, median $6.53/run)**, **Rust 30/30
5+
(100%, single-run)**, **Go 5/5 smoke (100%)**. 156 of 225 exercises
6+
remain (full Go + JS + C++ + Java). See Stage 2 / Stage 2b / Open
7+
items below.
68

79
Forge's second cross-benchmark evaluation. After SWE-Bench
810
(`docs/SWE-BENCH.md`) pointed out that real-world agent-scale tasks
@@ -249,16 +251,61 @@ To produce a headline "Forge scores X% on Aider polyglot" number:
249251
always 0 (key-name mismatch in the harness)
250252
- [x] Add the 4 remaining language runners (go / javascript / cpp /
251253
java) with stage-time un-skip preprocessing
252-
- [ ] Re-run Python x3 and report median + variance (single run
253-
isn't publishable). Aggregator is ready in
254-
`scripts/_polyglot_aggregate.py`.
255-
- [ ] Re-run Rust x3 and report median + variance (same caveat)
254+
- [x] Re-run Python x3 and report median + variance. Three full
255+
runs with a live Bedrock key on 2026-04-19:
256+
**34/34 / 34/34 / 34/34 PASS**. Median cost **$6.53/run**
257+
(range $6.43-$7.46). Median mean-wall-per-exercise **85.8s**
258+
(range 81.8-95.9s). Zero regressions across runs. Aggregate
259+
at `.forge/eval/polyglot/python-aggregate-20260419T102859.json`.
260+
Python baseline is saturated under Mode A.
261+
- [ ] Re-run Rust x3 and report median + variance (Rust still
262+
single-run)
256263
- [ ] Investigate `scale-generator` 32773s wall-clock anomaly
257264
(likely measurement artifact; instrument LLM-vs-test wall
258265
separately)
259-
- [ ] Run the remaining 161 exercises once a valid Bedrock key is
260-
available (S3 Task 3)
261-
- [ ] Promote to `forge eval polyglot` (S3 Task 4-5)
266+
- [ ] Run the remaining 161 exercises (Go / JS / C++ / Java).
267+
Go 5-exercise smoke: **5/5 PASS**, 276s total, $0.93 total
268+
(`.forge/eval/polyglot/go-20260419T125821/`). Full 34-Go
269+
sweep is the next target; JS / C++ / Java are the most
270+
likely places to see real failures.
271+
- [x] Promote to `forge eval polyglot` (S3 Task 4-5)
272+
273+
### Reasoning effort: why we did NOT wire `opencode --thinking`/`--variant`
274+
275+
Tested empirically on 2026-04-19 (Sonnet 4.5 via Bedrock, same
276+
prompt, three configurations):
277+
278+
| Config | input | output | reasoning tokens | cache write | cost |
279+
| --- | --- | --- | --- | --- | --- |
280+
| baseline | 2 | 704 | **0** | 11,101 | $0.052 |
281+
| `--variant high` | 9 | 1,531 | **0** | 22,248 | $0.106 |
282+
| `--variant max` | 9 | 2,968 | **0** | 22,248 | $0.128 |
283+
284+
Findings:
285+
286+
1. `opencode --thinking` is documented as **"show thinking blocks"**
287+
-- a display toggle. It does not change the request. Our probe
288+
confirmed: identical tokens/cost to baseline.
289+
2. `opencode --variant {high,max}` doubles context (~11k extra
290+
cache write, likely a different system preset) and grows output
291+
2-4x. `tokens.reasoning` is **always 0** in the event stream on
292+
Bedrock Sonnet 4.5 and no `<thinking>` block is emitted. Either
293+
opencode's Bedrock stream parser folds reasoning into `output`,
294+
or Bedrock silently ignores the `reasoningConfig.budgetTokens`
295+
it sends. Empirically the cost roughly doubles with no visible
296+
quality telemetry.
297+
3. Baseline Python is **34/34 x 3** (100% three runs in a row).
298+
There are no failing Python exercises to measure uplift against,
299+
so `--variant` has no demonstrable quality justification at a
300+
2-3x cost multiplier.
301+
302+
Conclusion: a minimal `--variant` passthrough was added to
303+
`LocalRuntime` / `_run_opencode` / `forge eval polyglot` (opt-in,
304+
default off, zero behaviour change) so it can be A/B-tested in the
305+
future if a language emerges where baseline actually fails. The
306+
full runtime-layer TDD wiring (Docker / Routing / ClaudeCode) was
307+
**not** done: Python / Go baselines give it nothing to prove.
308+
Revisit once JS / C++ / Java produce real failures.
262309

263310
## References
264311

platform/forge/eval/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def main(argv: Sequence[str] | None = None) -> int:
132132
skip=args.skip,
133133
max_attempts=args.max_attempts,
134134
resume=args.resume,
135+
variant=(getattr(args, "variant", "") or None),
135136
)
136137

137138
parser.error(f"Unknown subcommand: {args.subcommand}")

platform/forge/eval/polyglot.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ def run_exercise(
325325
exercise_dir: Path,
326326
lang: str,
327327
max_attempts: int,
328+
variant: str | None = None,
328329
) -> ExerciseResult:
329330
# Lazy imports: only pull in the studio runtime when actually
330331
# running an exercise. Keeps the module import cheap for tests
@@ -371,6 +372,7 @@ def run_exercise(
371372
cwd=str(work),
372373
role="worker",
373374
timeout=300,
375+
variant=variant,
374376
)
375377
llm_total += time.time() - t_llm
376378

@@ -474,6 +476,7 @@ def run(
474476
max_attempts: int = 2,
475477
resume: str = "",
476478
results_root: Path = RESULTS_ROOT,
479+
variant: str | None = None,
477480
) -> int:
478481
"""Run the polyglot benchmark for one language. Returns exit code."""
479482
exercises = _select_exercises(lang, only, skip, limit)
@@ -483,10 +486,11 @@ def run(
483486
run_dir.mkdir(parents=True, exist_ok=True)
484487
else:
485488
ts = time.strftime("%Y%m%dT%H%M%S")
486-
run_dir = results_root / f"{lang}-{ts}"
489+
suffix = f"-{variant}" if variant else ""
490+
run_dir = results_root / f"{lang}-{ts}{suffix}"
487491
run_dir.mkdir(parents=True, exist_ok=True)
488492

489-
print(f"[polyglot] lang={lang} n={len(exercises)} run_dir={run_dir}")
493+
print(f"[polyglot] lang={lang} n={len(exercises)} variant={variant or '-'} run_dir={run_dir}")
490494
print(f"[polyglot] first 5: {[e.name for e in exercises[:5]]}")
491495

492496
results: list[ExerciseResult] = []
@@ -512,7 +516,7 @@ def run(
512516
continue
513517

514518
print(f"[{i:02d}/{len(exercises)}] {ex.name} -- running...", flush=True)
515-
r = run_exercise(ex, lang, max_attempts)
519+
r = run_exercise(ex, lang, max_attempts, variant=variant)
516520
results.append(r)
517521
(run_dir / f"{ex.name}.json").write_text(json.dumps(r.record, indent=2))
518522
write_summary(run_dir, results, lang=lang)
@@ -569,6 +573,11 @@ def add_subparser(sub) -> None:
569573
"--resume", default="",
570574
help="resume prior run directory (skips exercises whose JSON already exists)",
571575
)
576+
p.add_argument(
577+
"--variant", default="",
578+
help="opencode --variant (provider-specific reasoning effort, e.g. high, max, minimal). "
579+
"Probe-only: currently only forwarded by LocalRuntime.",
580+
)
572581

573582

574583
def main(argv: list[str] | None = None) -> int:
@@ -586,6 +595,7 @@ def main(argv: list[str] | None = None) -> int:
586595
skip=args.skip,
587596
max_attempts=args.max_attempts,
588597
resume=args.resume,
598+
variant=(args.variant or None),
589599
)
590600

591601

platform/forge/runtime/local.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def run(
102102
model: str,
103103
timeout: int,
104104
role: str | None = None,
105+
variant: str | None = None,
105106
) -> dict[str, Any]:
106107
env = os.environ.copy()
107108

@@ -123,12 +124,14 @@ def run(
123124
"--format", "json",
124125
"--dangerously-skip-permissions",
125126
"-m", model,
126-
prompt,
127127
]
128+
if variant:
129+
cmd.extend(["--variant", variant])
130+
cmd.append(prompt)
128131

129132
_log.info(
130-
"opencode: running (local) model=%s, timeout=%ds, cwd=%s",
131-
model, timeout, cwd,
133+
"opencode: running (local) model=%s, variant=%s, timeout=%ds, cwd=%s",
134+
model, variant or "-", timeout, cwd,
132135
)
133136

134137
from forge.engine import process_tracker as _pt

studio/workflows/tdd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def _run_opencode(
102102
cwd: str | None = None,
103103
model: str | None = None,
104104
role: str | None = None,
105+
variant: str | None = None,
105106
) -> dict:
106107
"""Run opencode via the configured WorkerRuntime.
107108
@@ -120,13 +121,16 @@ def _run_opencode(
120121
except Exception:
121122
timeout = get_timeout("worker")
122123

123-
return _get_runtime().run(
124+
kwargs: dict = dict(
124125
prompt=prompt,
125126
cwd=source_dir,
126127
model=model,
127128
timeout=timeout,
128129
role=role,
129130
)
131+
if variant:
132+
kwargs["variant"] = variant
133+
return _get_runtime().run(**kwargs)
130134

131135

132136
def preflight_node(state: ForgeState) -> dict:

0 commit comments

Comments
 (0)