lcode-cli 0.55.0__py3-none-any.whl → 0.57.0__py3-none-any.whl

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.
lcode/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.55.0"
6
+ __version__ = "0.57.0"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
lcode/bench.py CHANGED
@@ -19,6 +19,7 @@ import subprocess
19
19
  import sys
20
20
  import tempfile
21
21
  import time
22
+ from collections import Counter
22
23
  from collections.abc import Callable, Iterator
23
24
  from contextlib import contextmanager
24
25
  from dataclasses import asdict, dataclass, field
@@ -38,6 +39,7 @@ from lcode.ollama import Ollama, OllamaError
38
39
  SCHEMA_VERSION = 1
39
40
  DEFAULT_CONTEXT = 32768 # the same everywhere, so results compare across machines
40
41
  DEFAULT_TIMEOUT = 300 # seconds per task
42
+ DEFAULT_ATTEMPTS = 3 # each task's attempts: one run is within the noise between runs
41
43
  CHECK_TIMEOUT = 60
42
44
  PROBE_WORDS = 3000 # about 4,000 tokens
43
45
  PROBE_TEXT = (
@@ -792,6 +794,46 @@ class TaskResult:
792
794
  errors_by_tool: dict[str, int] = field(default_factory=dict) # which tools failed, "malformed" for unreadable calls
793
795
  first_passed: bool | None = None # with --retry: whether the first try passed (None: no retry was needed)
794
796
  escalations: int = 0 # times the stronger model was asked (--escalate)
797
+ attempt: int = 1 # which of the task's attempts this was (--attempts)
798
+
799
+
800
+ @dataclass
801
+ class PassRates:
802
+ """How often the tasks passed, as `lcode bench --harbor` counts it (lcode.harbor_bench.summarize)."""
803
+
804
+ tries: int # k: each task's tries, its attempts (times the rounds of a --session)
805
+ pass_at_1: float | None # the share of tries that passed, averaged over the tasks
806
+ pass_all: float | None # pass^k: the share of tasks that passed every try (of those with all k)
807
+ attempts: list[tuple[int, int]] # (passed, tasks run) in each attempt, in order
808
+
809
+ @property
810
+ def runs(self) -> list[float]:
811
+ """The pass rate of each attempt that ran every task."""
812
+ full = max((ran for _, ran in self.attempts), default=0)
813
+ return [passed / ran for passed, ran in self.attempts if ran == full and ran]
814
+
815
+ @property
816
+ def spread(self) -> float | None:
817
+ runs = self.runs
818
+ return max(runs) - min(runs) if len(runs) > 1 else None
819
+
820
+
821
+ def pass_rates(results: list[TaskResult], attempts: int) -> PassRates:
822
+ tries: dict[str, list[bool]] = {}
823
+ for result in results:
824
+ tries.setdefault(result.id, []).append(result.passed)
825
+ per_attempt = Counter((result.id, result.attempt) for result in results)
826
+ k = max(1, attempts) * max(per_attempt.values(), default=1)
827
+ full = [passed for passed in tries.values() if len(passed) >= k]
828
+ by_attempt: dict[int, list[bool]] = {}
829
+ for result in results:
830
+ by_attempt.setdefault(result.attempt, []).append(result.passed)
831
+ return PassRates(
832
+ tries=k,
833
+ pass_at_1=statistics.fmean(statistics.fmean(passed) for passed in tries.values()) if tries else None,
834
+ pass_all=statistics.fmean(all(passed[:k]) for passed in full) if full else None,
835
+ attempts=[(sum(passed), len(passed)) for _, passed in sorted(by_attempt.items())],
836
+ )
795
837
 
796
838
 
797
839
  @dataclass
@@ -812,6 +854,10 @@ class ModelRun:
812
854
  session: bool = False # all tasks in one conversation (--session)
813
855
  pruned: int = 0 # times old tool output was removed to make room
814
856
  compacted: int = 0 # times the conversation was summarized
857
+ attempts: int = 1 # each task's attempts, each in a new folder and conversation (--attempts)
858
+
859
+ def rates(self) -> PassRates:
860
+ return pass_rates(self.tasks, self.attempts)
815
861
 
816
862
  @property
817
863
  def passed(self) -> int:
@@ -832,12 +878,19 @@ class ModelRun:
832
878
 
833
879
  def to_json(self) -> dict:
834
880
  data = asdict(self)
881
+ rates = self.rates()
835
882
  data.update(
836
883
  passed=self.passed,
837
884
  total=len(self.tasks),
838
885
  seconds=round(self.seconds, 1),
839
886
  generation_tps=self.generation_tps,
840
887
  tool_errors=self.tool_errors,
888
+ summary={
889
+ "pass_at_1": rates.pass_at_1,
890
+ f"pass^{rates.tries}": rates.pass_all,
891
+ "runs": rates.runs,
892
+ "spread": rates.spread,
893
+ },
841
894
  )
842
895
  return data
843
896
 
@@ -1034,12 +1087,19 @@ def run_model(
1034
1087
  verbose: bool = False,
1035
1088
  session: bool = False,
1036
1089
  retry: bool = False,
1090
+ attempts: int = 1,
1037
1091
  ) -> ModelRun:
1038
- run = ModelRun(name, settings.model, settings.context, settings.num_batch, settings.think, session=session)
1092
+ """Run the tasks `attempts` times: every task once, then every task again, each time in a new folder and
1093
+ conversation (with `session`, each attempt is one conversation for all the tasks)."""
1094
+ attempts = max(1, attempts)
1095
+ run = ModelRun(
1096
+ name, settings.model, settings.context, settings.num_batch, settings.think, session=session, attempts=attempts
1097
+ )
1039
1098
  shared: Agent | None = None # with --session, one conversation for all tasks
1040
1099
  console.print(
1041
1100
  f"\n[bold]{escape(settings.model)}[/] · {format_tokens(settings.context)} context · "
1042
1101
  f"reasoning {'on' if settings.think else 'off'} · {len(tasks)} task{'' if len(tasks) == 1 else 's'}"
1102
+ + (f" · {attempts} attempts each" if attempts > 1 else "")
1043
1103
  )
1044
1104
  options = {"num_ctx": settings.context, **({"num_batch": settings.num_batch} if settings.num_batch else {})}
1045
1105
  started = time.monotonic()
@@ -1065,30 +1125,40 @@ def run_model(
1065
1125
  console.print(f" [dim]Loaded in {run.load_seconds:.0f}s{where}{reads}[/]")
1066
1126
  elif reads: # the server loads the model itself
1067
1127
  console.print(f" [dim]{reads.removeprefix(' · ').capitalize()}[/]")
1068
- for task in tasks:
1069
- log = console if verbose else Console(file=io.StringIO(), width=120, force_terminal=False)
1070
- if session and shared is None:
1071
- shared = Agent(ollama, settings, Path(tempfile.gettempdir()), console=log)
1072
- if shared is not None:
1073
- shared.console = log
1074
- try:
1075
- if verbose:
1076
- console.rule(f"{task.id}: {task.title}")
1077
- result = run_task(ollama, settings, task, timeout, log, keep, run.usage, shared, retry)
1078
- else:
1079
- with console.status(Elapsed(f" {task.id:<13} {task.title}")):
1128
+ pruned = compacted = 0 # in the conversations of the earlier attempts (--session)
1129
+ for attempt in range(1, attempts + 1):
1130
+ if attempts > 1:
1131
+ console.print(f" [dim]Attempt {attempt} of {attempts}[/]")
1132
+ if shared is not None: # with --session, each attempt is a conversation of its own
1133
+ pruned, compacted = pruned + shared.pruned, compacted + shared.compacted
1134
+ shared = None
1135
+ for task in tasks:
1136
+ log = console if verbose else Console(file=io.StringIO(), width=120, force_terminal=False)
1137
+ if session and shared is None:
1138
+ shared = Agent(ollama, settings, Path(tempfile.gettempdir()), console=log)
1139
+ if shared is not None:
1140
+ shared.console = log
1141
+ try:
1142
+ if verbose:
1143
+ console.rule(f"{task.id}: {task.title}")
1080
1144
  result = run_task(ollama, settings, task, timeout, log, keep, run.usage, shared, retry)
1081
- except KeyboardInterrupt:
1082
- console.print(" [yellow]Stopped.[/]")
1083
- run.interrupted = True
1145
+ else:
1146
+ with console.status(Elapsed(f" {task.id:<13} {task.title}")):
1147
+ result = run_task(ollama, settings, task, timeout, log, keep, run.usage, shared, retry)
1148
+ except KeyboardInterrupt:
1149
+ console.print(" [yellow]Stopped.[/]")
1150
+ run.interrupted = True
1151
+ break
1152
+ result.attempt = attempt
1153
+ run.tasks.append(result)
1154
+ mark = "[green]✓[/]" if result.passed else "[red]✗[/]"
1155
+ console.print(
1156
+ f" {mark} {task.id:<13} {task.title:<32} {result.seconds:>5.0f}s [dim]{escape(result.detail)}[/]"
1157
+ )
1158
+ if shared is not None:
1159
+ run.pruned, run.compacted = pruned + shared.pruned, compacted + shared.compacted
1160
+ if run.interrupted:
1084
1161
  break
1085
- run.tasks.append(result)
1086
- mark = "[green]✓[/]" if result.passed else "[red]✗[/]"
1087
- console.print(
1088
- f" {mark} {task.id:<13} {task.title:<32} {result.seconds:>5.0f}s [dim]{escape(result.detail)}[/]"
1089
- )
1090
- if shared is not None:
1091
- run.pruned, run.compacted = shared.pruned, shared.compacted
1092
1162
  if run.memory_gb is None:
1093
1163
  run.memory_gb, run.gpu_percent = memory_use(ollama, settings.model)
1094
1164
  # lcode lowers the batch size or context if the GPU runs out of memory; report what was used.
@@ -1103,21 +1173,39 @@ def duration(seconds: float) -> str:
1103
1173
  return f"{int(seconds // 60)}m {seconds % 60:02.0f}s" if seconds >= 60 else f"{seconds:.0f}s"
1104
1174
 
1105
1175
 
1176
+ def percent(share: float | None) -> str:
1177
+ return "–" if share is None else f"{share * 100:.0f}%"
1178
+
1179
+
1106
1180
  def summary_rows(runs: list[ModelRun], tasks: list[Task]) -> list[tuple[str, list[str]]]:
1107
1181
  rows = []
1108
- for task in {t.id: t for t in tasks}.values(): # with --rounds a task runs several times: one row, a mark each
1182
+ for task in {t.id: t for t in tasks}.values(): # a task that ran several times: one row, a mark each
1109
1183
  cells = []
1110
1184
  for run in runs:
1111
1185
  results = [t for t in run.tasks if t.id == task.id]
1112
1186
  marks = "".join("✓" if r.passed else "✗" for r in results)
1113
- cells.append(f"{marks} {duration(sum(r.seconds for r in results))}" if results else "")
1187
+ each = sum(r.seconds for r in results) / len(results) if results else 0.0 # one try's time, on average
1188
+ cells.append(f"{marks} {duration(each)}" if results else "")
1114
1189
  rows.append((f"{task.id}: {task.title}", cells))
1115
1190
 
1116
1191
  def cell(run: ModelRun, value: str) -> str:
1117
1192
  return "—" if run.error else value
1118
1193
 
1194
+ rows.append(
1195
+ ("Passed", [cell(r, f"{r.passed}/{len(r.tasks)}" + (" (stopped)" if r.interrupted else "")) for r in runs])
1196
+ )
1197
+ rates = [(run, run.rates()) for run in runs]
1198
+ tries = max((rate.tries for _, rate in rates), default=1)
1199
+ if tries > 1:
1200
+ rows += [
1201
+ ("pass@1", [cell(run, percent(rate.pass_at_1)) for run, rate in rates]),
1202
+ (f"pass^{tries}", [cell(run, percent(rate.pass_all)) for run, rate in rates]),
1203
+ ]
1204
+ if any(len(rate.attempts) > 1 for _, rate in rates):
1205
+ rows.append(
1206
+ ("Each attempt", [cell(run, ", ".join(f"{p}/{n}" for p, n in rate.attempts)) for run, rate in rates])
1207
+ )
1119
1208
  rows += [
1120
- ("Passed", [cell(r, f"{r.passed}/{len(r.tasks)}" + (" (stopped)" if r.interrupted else "")) for r in runs]),
1121
1209
  ("Time", [cell(r, duration(r.seconds)) for r in runs]),
1122
1210
  ("Generation", [cell(r, f"{r.generation_tps:.1f} tok/s" if r.generation_tps else "?") for r in runs]),
1123
1211
  ("Prompt reading", [cell(r, f"{r.prompt_tps:,.0f} tok/s" if r.prompt_tps else "?") for r in runs]),
lcode/cli.py CHANGED
@@ -597,18 +597,27 @@ def cmd_bench(args) -> None:
597
597
  if args.harbor:
598
598
  from lcode import harbor_bench
599
599
 
600
+ if args.attempts is None:
601
+ args.attempts = harbor_bench.ATTEMPTS
600
602
  sys.exit(harbor_bench.command(args, console))
601
603
  if args.list:
602
604
  bench.print_tasks(console)
603
605
  return
606
+ rounds = max(1, args.rounds)
604
607
  try:
605
608
  cfg = config.load()
606
609
  context = parse_context(args.context) if args.context else bench.DEFAULT_CONTEXT
607
- tasks = bench.select_tasks(args.tasks) * max(1, args.rounds)
610
+ tasks = bench.select_tasks(args.tasks) * (rounds if args.session else 1)
608
611
  except (ConfigError, ValueError) as e:
609
612
  fail(str(e))
610
613
  if args.timeout <= 0:
611
614
  fail("--timeout must be a positive number of seconds")
615
+ if args.attempts is not None and args.attempts < 1:
616
+ fail("--attempts must be at least 1")
617
+ if args.session: # an attempt is one long conversation
618
+ attempts = args.attempts or 1
619
+ else: # --rounds is what --attempts was called before 0.57
620
+ attempts = args.attempts or (rounds if rounds > 1 else bench.DEFAULT_ATTEMPTS)
612
621
  ollama = connect(cfg)
613
622
  hw = detect()
614
623
  version = check_ollama(ollama, hw)
@@ -663,8 +672,9 @@ def cmd_bench(args) -> None:
663
672
  embed_model=cfg["embed_model"] if args.code_search else "off",
664
673
  )
665
674
  run = bench.run_model(
666
- ollama, name, settings, tasks, console, args.timeout, args.keep, args.verbose, args.session, args.retry
667
- )
675
+ ollama, name, settings, tasks, console, args.timeout, args.keep, args.verbose, args.session, args.retry,
676
+ attempts,
677
+ ) # fmt: skip
668
678
  runs.append(run)
669
679
  if run.interrupted:
670
680
  break
@@ -951,7 +961,18 @@ def build_subparsers() -> dict[str, argparse.ArgumentParser]:
951
961
  choices=["dev", "held-out"],
952
962
  help="public benchmarks instead: a slice of Terminal-Bench 2.0 and SWE-bench Verified, run with Harbor",
953
963
  )
954
- p.add_argument("--attempts", type=int, default=3, help="with --harbor: attempts per task (default: 3, for pass^3)")
964
+ p.add_argument(
965
+ "--attempts",
966
+ type=int,
967
+ help="attempts per task, each in a new folder and conversation (default: 3, for pass@1 and pass^3; "
968
+ "with --session: 1)",
969
+ )
970
+ p.add_argument(
971
+ "--agent",
972
+ choices=["lcode", "claude-code", "opencode", "codex"],
973
+ default="lcode",
974
+ help="with --harbor: the agent to run, for a comparison on the same model (default: lcode)",
975
+ )
955
976
  p.add_argument(
956
977
  "--docker-bridge",
957
978
  action="store_true",
@@ -963,7 +984,11 @@ def build_subparsers() -> dict[str, argparse.ArgumentParser]:
963
984
  help="run all tasks in one conversation, to test a long session and its context management",
964
985
  )
965
986
  p.add_argument(
966
- "--rounds", type=int, default=1, help="run the tasks this many times (with --session: a longer session)"
987
+ "--rounds",
988
+ type=int,
989
+ default=1,
990
+ help="with --session: the tasks this many times in the conversation, for a longer session "
991
+ "(without --session: the same as --attempts)",
967
992
  )
968
993
  p.add_argument("--repo-map", action="store_true", help="give the model the repository map (off by default)")
969
994
  p.add_argument("--code-search", action="store_true", help="index each task's folder and offer semantic code search")
lcode/docs/bench.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Benchmarking models
2
2
 
3
3
  `lcode bench` answers the most common question about local models: *which one works best for
4
- coding on my machine?* It runs a fixed set of small coding tasks against one or more models and
5
- reports how many they solved, how fast they ran and how much memory they used.
4
+ coding on my machine?* It runs a fixed set of small coding tasks against one or more models, three
5
+ times each, and reports how many they solved, how fast they ran and how much memory they used.
6
6
 
7
7
  To compare with other agents on public benchmarks (Terminal-Bench 2.0 and SWE-bench Verified),
8
8
  see [Public benchmarks](public-benchmarks.md).
@@ -11,6 +11,7 @@ see [Public benchmarks](public-benchmarks.md).
11
11
  lcode bench # the configured model
12
12
  lcode bench qwen3.6-35b qwen3.5-9b # compare models
13
13
  lcode bench --tasks fix-bug,rename # run some of the tasks
14
+ lcode bench --attempts 1 # each task once: quicker, but within the noise
14
15
  lcode bench --json results.json # also save machine-readable results
15
16
  lcode bench --markdown # also print a table to paste into a test report
16
17
  ```
@@ -20,23 +21,43 @@ Studio: `LCODE_BACKEND=llama.cpp lcode bench`. The server keeps the model loaded
20
21
  its memory use, so those columns stay empty.
21
22
 
22
23
  ```text
23
- lcode bench · NVIDIA GeForce RTX 4080 Laptop GPU (12 GB VRAM), 31 GB RAM · Ollama 0.32.15
24
+ lcode bench · NVIDIA GeForce RTX 4080 Laptop GPU (12 GB VRAM), 31 GB RAM · Ollama 0.40.13
24
25
 
25
- lcode-qwen3.6-35b · 32K context · reasoning on · 8 tasks
26
- Loaded in 16s · 22.3 GB, 45% on the GPU · reads prompts at 855 tok/s
26
+ lcode-qwen3.6-35b · 32K context · reasoning on · 8 tasks · 3 attempts each
27
+ Loaded in 18s · 10.4 GB, 98% on the GPU · reads prompts at 905 tok/s
28
+ Attempt 1 of 3
27
29
  ✓ fix-bug Fix a bug so the tests pass 22s the tests pass
28
- ✓ find-code Answer with file:line 9s next_wait at backoff.py:13
29
- ✓ write-script Write a script from a spec 13s correct output, also on data it hadn't seen
30
- ✓ rename Rename a function across files 26s its tests and extra checks pass
30
+ ✓ find-code Answer with file:line 8s next_wait at backoff.py:13
31
+ ✓ write-script Write a script from a spec 12s correct output, also on data it hadn't seen
32
+ ✓ rename Rename a function across files 22s its tests and extra checks pass
31
33
  ✓ precise-edit One-line edit in a long file 10s changed only service_087's timeout
32
- ✓ recover Recover from failing commands 30s used --source and dropped the invalid line
33
- ✓ spec-fix Fix a function to match its spec 55s follows the whole docstring
34
- ✓ feature Add a feature across files 71s priorities work, including old todos
34
+ ✓ recover Recover from failing commands 22s used --source and dropped the invalid line
35
+ ✓ spec-fix Fix a function to match its spec 78s follows the whole docstring
36
+ ✓ feature Add a feature across files 86s priorities work, including old todos
37
+ Attempt 2 of 3
38
+ …
35
39
  ```
36
40
 
37
41
  At the end it prints a table comparing the models (see [results](#results-on-a-12-gb-laptop) below).
38
42
 
39
- A model usually takes 4 to 12 minutes; each task stops after 5 minutes (`--timeout`).
43
+ A model usually takes 4 to 12 minutes per attempt; each task stops after 5 minutes (`--timeout`).
44
+
45
+ ### Three attempts at each task
46
+
47
+ Models sample their answers, so a task near the edge of a model's ability can pass in one run and
48
+ fail in the next. One run of each task is within that noise, so `lcode bench` makes three attempts
49
+ at every task, each in a new folder and conversation: every task once, then every task again. The
50
+ summary adds:
51
+
52
+ | | |
53
+ |---|---|
54
+ | **pass@1** | The share of attempts that passed, averaged over the tasks: the chance that one attempt works |
55
+ | **pass^3** | The share of tasks that passed all three attempts: the ones you can count on |
56
+ | **Each attempt** | How many tasks passed in each attempt. The difference between the best and the worst is the spread between runs |
57
+
58
+ They're counted as in the [public benchmarks](public-benchmarks.md). `--attempts 1` runs each task
59
+ once, as `lcode bench` did before 0.57, in a third of the time; `--attempts 5` gives pass^5. In the
60
+ summary, a task's time is that of one attempt, on average, and *Time* is the total.
40
61
 
41
62
  ### More tasks and features
42
63
 
@@ -57,8 +78,8 @@ would: no questions asked, since the flag is your OK. Comparing the two shows wh
57
78
  model's advice adds to the same second chance:
58
79
 
59
80
  ```bash
60
- lcode bench --tasks runtime-bug --retry --rounds 3
61
- lcode bench --tasks runtime-bug --retry --rounds 3 --escalate ollama/qwen3.8-27b
81
+ lcode bench --tasks runtime-bug --retry --attempts 3
82
+ lcode bench --tasks runtime-bug --retry --attempts 3 --escalate ollama/qwen3.8-27b
62
83
  ```
63
84
 
64
85
  The JSON report has, for each task, `first_passed` (with `--retry`, whether the first try passed)
@@ -77,7 +98,8 @@ lcode bench --context 32k --session --rounds 3
77
98
  lcode bench --context 32k --session --rounds 3 --no-prune
78
99
  ```
79
100
 
80
- `--rounds 3` runs the tasks three times, 24 in one conversation, which fills a 32K window several
101
+ With `--session`, an attempt is one conversation, and `--attempts` is 1 unless you set it. `--rounds 3`
102
+ runs the tasks three times in it, 24 in one conversation, which fills a 32K window several
81
103
  times over. With qwen3.6-35b on a 12 GB laptop (two runs each; runs vary a lot from one to the
82
104
  next):
83
105
 
@@ -130,8 +152,8 @@ and `feature` are checked with tests the model never saw.
130
152
 
131
153
  | | |
132
154
  |---|---|
133
- | **Passed** | Tasks solved within the time limit |
134
- | **Time** | Total time for the tasks (loading the model is reported separately) |
155
+ | **Passed** | Attempts that solved their task within the time limit; with several, also pass@1, pass^3 and each attempt's ([above](#three-attempts-at-each-task)) |
156
+ | **Time** | Total time for the tasks, every attempt (loading the model is reported separately) |
135
157
  | **Generation** | Output tokens per second, across all the model's responses |
136
158
  | **Prompt reading** | Prompt tokens per second: how fast the model reads files and tool output. Measured per model with fresh 4,000-token prompts (the faster of two readings, since the first one after loading includes warm-up), because during the tasks Ollama serves most of each request from its prompt cache |
137
159
  | **Tool-call errors** | Tool calls that failed (wrong arguments, editing without reading first, unmatched edits) or that the model wrote as invalid JSON |
@@ -144,7 +166,8 @@ to measure a model without reasoning.
144
166
 
145
167
  ## Results on a 12 GB laptop
146
168
 
147
- RTX 4080 Laptop GPU (12 GB) with 31 GB of RAM, Ollama 0.32.15, 32K context, reasoning on:
169
+ RTX 4080 Laptop GPU (12 GB) with 31 GB of RAM, Ollama 0.32.15, 32K context, reasoning on, one
170
+ attempt each (lcode 0.3):
148
171
 
149
172
  | | `qwen3.6-35b` | `qwen3.5-9b` | `qwen3.5-4b` |
150
173
  |---|---|---|---|
@@ -169,8 +192,8 @@ copying `read_file`'s line numbers into a data file, ignoring negative numbers,
169
192
  of the spec, and running out of time.
170
193
 
171
194
  Models sample their answers, so a task near the edge of a model's ability can pass in one run and
172
- fail in the next (`qwen3.6-35b` scored 7/8 in an earlier run). Compare totals rather than single
173
- tasks, and run twice before drawing conclusions.
195
+ fail in the next (`qwen3.6-35b` scored 7/8 in an earlier run), which is why `lcode bench` now makes
196
+ three attempts at each task. Compare pass@1 and pass^3 rather than single tasks.
174
197
 
175
198
  ## Sharing results
176
199
 
@@ -192,10 +215,10 @@ existing fields keep their meaning until `schema` changes.
192
215
  ```json
193
216
  {
194
217
  "schema": 1,
195
- "lcode": "0.3.1",
196
- "ollama": "0.32.15",
197
- "server": "Ollama 0.32.15",
198
- "date": "2026-09-30T19:09:09+02:00",
218
+ "lcode": "0.57.0",
219
+ "ollama": "0.40.13",
220
+ "server": "Ollama 0.40.13",
221
+ "date": "2026-11-02T09:44:14+01:00",
199
222
  "hardware": {
200
223
  "os": "linux", "cpu": "13th Gen Intel(R) Core(TM) i9-13980HX", "ram_gib": 30.96,
201
224
  "gpu": "NVIDIA GeForce RTX 4080 Laptop GPU", "vram_gib": 11.99, "unified": false,
@@ -209,20 +232,22 @@ existing fields keep their meaning until `schema` changes.
209
232
  "context": 32768,
210
233
  "num_batch": null,
211
234
  "think": true,
212
- "load_seconds": 16.2,
213
- "prompt_tps": 854.6,
214
- "memory_gb": 22.3,
215
- "gpu_percent": 45,
216
- "passed": 8,
217
- "total": 8,
218
- "seconds": 237.3,
219
- "generation_tps": 71.4,
220
- "tool_errors": 0,
221
- "usage": {"requests": 56, "prompt_tokens": 221522, "prompt_ns": 73377987000,
222
- "output_tokens": 11490, "output_ns": 161017657999},
235
+ "load_seconds": 17.8,
236
+ "prompt_tps": 904.6,
237
+ "memory_gb": 10.4,
238
+ "gpu_percent": 98,
239
+ "attempts": 3,
240
+ "passed": 24,
241
+ "total": 24,
242
+ "seconds": 756.2,
243
+ "generation_tps": 72.2,
244
+ "tool_errors": 2,
245
+ "summary": {"pass_at_1": 1.0, "pass^3": 1.0, "runs": [1.0, 1.0, 1.0], "spread": 0.0},
246
+ "usage": {"requests": 184, "prompt_tokens": 1058154, "prompt_ns": 199916607993,
247
+ "output_tokens": 38683, "output_ns": 535438114998},
223
248
  "tasks": [
224
- {"id": "fix-bug", "passed": true, "seconds": 21.9, "detail": "the tests pass",
225
- "steps": 5, "tool_errors": 0, "error": null},
249
+ {"id": "fix-bug", "passed": true, "seconds": 21.5, "detail": "the tests pass",
250
+ "steps": 5, "tool_errors": 0, "error": null, "attempt": 1},
226
251
  …
227
252
  ],
228
253
  "error": null,
@@ -241,6 +266,9 @@ existing fields keep their meaning until `schema` changes.
241
266
  | `runs[].generation_tps` | Output tokens per second across the tasks; `null` if Ollama reported no timings |
242
267
  | `runs[].prompt_tps` | Prompt tokens per second for a fresh 4,000-token prompt (the faster of two readings); `null` if it couldn't be measured |
243
268
  | `runs[].usage` | Totals over the tasks as Ollama reports them. `prompt_tokens` includes tokens served from the prompt cache |
269
+ | `runs[].attempts` | Attempts at each task (`--attempts`) |
270
+ | `runs[].summary` | `pass_at_1`, `pass^3` (with the number of attempts), `runs` (each attempt's pass rate) and `spread` (the best minus the worst), counted as in the [public benchmarks](public-benchmarks.md); `null` where there's nothing to count |
271
+ | `runs[].tasks[]` | One entry per attempt at a task; `attempt` says which (1, 2, 3) |
244
272
  | `runs[].tasks[].steps` | Model responses in the task |
245
273
  | `runs[].tasks[].error` | Why the task stopped early (`timed out after 300s`, an Ollama error), otherwise `null` |
246
274
  | `runs[].error` | Why the model didn't run at all (for example, not installed), otherwise `null` |
@@ -97,6 +97,40 @@ Everything is saved in `~/.local/state/lcode/bench/<slice>-<time>/`:
97
97
  - Harbor's own results: each attempt's log, the task's test output, and lcode's trace and session.
98
98
  `uvx --from harbor harbor view <folder>` browses them.
99
99
 
100
+ ## Other agents on the same model
101
+
102
+ `--agent` runs Claude Code, OpenCode or Codex on the same tasks, with the same model, context
103
+ window and time limits, so you can compare them with lcode:
104
+
105
+ ```bash
106
+ lcode bench --harbor dev qwen3.6-35b --context 64k # lcode
107
+ lcode bench --harbor dev qwen3.6-35b --context 64k --agent claude-code
108
+ lcode bench --harbor dev qwen3.6-35b --context 64k --agent opencode
109
+ lcode bench --harbor dev qwen3.6-35b --context 64k --agent codex
110
+ ```
111
+
112
+ Harbor installs the agent in each task's container, with approvals off. lcode sets the agent up the
113
+ way `ollama launch` does, with the Ollama on your machine:
114
+
115
+ - **Claude Code** uses Ollama's Anthropic-compatible API, with the model for every tier (subagents
116
+ too) and `ollama launch claude`'s settings: no telemetry, error reports or feedback prompts. Like
117
+ `ollama launch claude`, it doesn't tell Claude Code the context window.
118
+ - **OpenCode** uses an Ollama provider on Ollama's OpenAI-compatible API. The model is marked as a
119
+ reasoning model, with the limits of its context window.
120
+ - **Codex** uses Ollama's Responses API and `ollama launch codex`'s model catalog. That catalog gives
121
+ local models no base instructions, so Codex runs without its own system prompt, as it does with
122
+ `ollama launch codex`.
123
+
124
+ These agents' APIs can't set the context window per request, and Ollama's default is small (4K on
125
+ GPUs under 24 GB), so lcode makes a copy of the model with the context set:
126
+ `lcode-qwen3.6-35b-64k` for 64K. It uses the model's files, so nothing is downloaded, and
127
+ `ollama rm lcode-qwen3.6-35b-64k` removes it. Ollama recommends at least 64K for these agents.
128
+
129
+ The time per task leaves out installing the agent, which Harbor does in every task's container: up to
130
+ three minutes for Claude Code, so its runs take longer overall. The results go to
131
+ `~/.local/state/lcode/bench/<slice>-<agent>-<time>/`, and `lcode-bench.json` adds the agent and its
132
+ version.
133
+
100
134
  ## With Harbor directly
101
135
 
102
136
  `lcode.harbor:Lcode` is an ordinary Harbor agent, so every Harbor dataset and option works:
lcode/docs/quickstart.md CHANGED
@@ -12,7 +12,7 @@ lcode
12
12
 
13
13
  ```text
14
14
  ╭──────────────────────────────────────────────╮
15
- │ lcode v0.55.0 — local coding agent │
15
+ │ lcode v0.57.0 — local coding agent │
16
16
  │ │
17
17
  │ model lcode-qwen3.6-35b │
18
18
  │ context 256K tokens │
lcode/docs/search.md CHANGED
@@ -66,7 +66,7 @@ whether it is.
66
66
 
67
67
  ## Measured
68
68
 
69
- `lcode bench qwen3.6-35b --tasks find-code,find-concept --rounds 3` on a 12 GB laptop. `find-concept`
69
+ `lcode bench qwen3.6-35b --tasks find-code,find-concept --attempts 3` on a 12 GB laptop. `find-concept`
70
70
  asks which function computes the pause before a failed upload is sent again, in a 40-file backend
71
71
  full of look-alikes (retry policies, job requeue delays, log backoff); the right function's name and
72
72
  docstring use none of the question's words.
lcode/docs/usage.md CHANGED
@@ -11,6 +11,7 @@ lcode media [install MODEL] # image and video models: what fits here, what's in
11
11
  lcode config [set|unset] # show or change settings
12
12
  lcode bench [models] # score models on small coding tasks on this machine
13
13
  lcode bench --harbor dev # public benchmarks: Terminal-Bench 2.0 and SWE-bench Verified
14
+ lcode bench --harbor dev --agent codex # the same with another agent on your model, to compare
14
15
  lcode trace [action] [N] # past requests: show one step by step, export or replay it (see Run traces)
15
16
  lcode mcp [catalog|add|list] # connect MCP servers: Jira, GitHub, AWS, databases… (see MCP servers)
16
17
  lcode acp # run inside an editor over the Agent Client Protocol (see Editors)
lcode/harbor_bench.py CHANGED
@@ -10,12 +10,16 @@ model can try overnight: Terminal-Bench 2.0 without model training and with at m
10
10
  task, and SWE-bench Verified's two common difficulties. The dev slice is for everyday checks; the
11
11
  held-out set is never used for tuning, only to confirm a change helps beyond the tasks it was
12
12
  tuned on.
13
+
14
+ Other agents run on the same slices and the same model for comparison (`--agent`): Claude Code,
15
+ OpenCode and Codex, each set up the way `ollama launch` sets it up.
13
16
  """
14
17
 
15
18
  from __future__ import annotations
16
19
 
17
20
  import datetime as dt
18
21
  import json
22
+ import os
19
23
  import shlex
20
24
  import statistics
21
25
  import subprocess
@@ -23,6 +27,8 @@ import time
23
27
  from dataclasses import asdict, dataclass, field
24
28
  from pathlib import Path
25
29
 
30
+ from lcode.ollama import OllamaError
31
+
26
32
  HARBOR = "harbor==0.25.0" # the Harbor these slices were made and checked with
27
33
  HARBOR_PYTHON = "3.13"
28
34
  AGENT = "lcode.harbor:Lcode"
@@ -67,6 +73,143 @@ LOG = "/logs/agent/lcode.txt"
67
73
  ON_PATH = 'export PATH="$HOME/.local/bin:$PATH";' # where uv puts lcode and itself
68
74
 
69
75
 
76
+ # ----------------------------------------------------------------------------- other agents on the same model
77
+
78
+ # The agents compared with lcode (#198), by Harbor's names. Each is set up the way `ollama launch` sets it up (in
79
+ # Ollama's cmd/launch), with your machine's Ollama as a task's container reaches it, approvals off (Harbor's).
80
+ OTHER_AGENTS = ("claude-code", "opencode", "codex")
81
+ OLLAMA_FROM_TASKS = f"http://host.docker.internal:{OLLAMA_PORT}" # with the host-gateway entry in the overlay
82
+ CODEX_CATALOG = "/opt/lcode-bench/codex-models.json" # in the task's container
83
+ CLAUDE_CODE_ENV = { # what `ollama launch claude` sets besides the address, the key and each tier's model (Harbor's)
84
+ "ENABLE_CLAUDEAI_MCP_SERVERS": "false",
85
+ "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
86
+ "CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off",
87
+ "DISABLE_ERROR_REPORTING": "1",
88
+ "DISABLE_FEEDBACK_COMMAND": "1",
89
+ "CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY": "1",
90
+ "CLAUDE_CODE_AUTO_MODE_SERVER": "0",
91
+ }
92
+ CODEX_LEVELS = { # Codex's reasoning efforts for Ollama's thinking values, with Ollama's descriptions
93
+ "none": "Turn thinking off",
94
+ "minimal": "Thinking effort",
95
+ "low": "Fast responses with lighter thinking",
96
+ "medium": "Balances speed and thinking depth for everyday tasks",
97
+ "high": "Greater thinking depth for complex tasks",
98
+ "xhigh": "Thinking effort",
99
+ "max": "Maximum thinking depth for the hardest tasks",
100
+ "ultra": "Thinking effort",
101
+ }
102
+
103
+
104
+ def variant_name(model: str, context: int) -> str:
105
+ """The Ollama model the other agents get: `model` with its context window set (lcode-qwen3.6-35b-64k), since
106
+ the APIs they use (OpenAI's, Anthropic's) can't set it per request and Ollama's default is small."""
107
+ from lcode.config import format_tokens
108
+
109
+ return f"{model.removesuffix(':latest')}-{format_tokens(context).lower()}"
110
+
111
+
112
+ def agent_overlay(bridge: bool, catalog: Path | None = None) -> str:
113
+ """The Docker Compose override for another agent's tasks: host.docker.internal is your machine (Docker Desktop
114
+ has it; on Linux it's added), and Codex's model catalog is in the container."""
115
+ lines = ["services:", " main:"]
116
+ if bridge:
117
+ lines.append(" network_mode: bridge")
118
+ lines += [" extra_hosts:", ' - "host.docker.internal:host-gateway"']
119
+ if catalog is not None:
120
+ lines += [" volumes:", f" - {json.dumps(f'{catalog}:{CODEX_CATALOG}:ro')}"]
121
+ return "\n".join(lines) + "\n"
122
+
123
+
124
+ def opencode_config(model: str, context: int, thinking: bool) -> dict:
125
+ """`ollama launch opencode`'s provider: Ollama's OpenAI-compatible API, and the model with the limits of the
126
+ context it runs at (a quarter of it for output, at most 8K)."""
127
+ entry: dict = {"name": model}
128
+ if thinking: # a model that can think without levels: on, or "none"
129
+ entry["reasoning"] = True
130
+ entry["variants"] = {
131
+ "none": {"reasoningEffort": "none"},
132
+ "low": {"disabled": True},
133
+ "medium": {"disabled": True},
134
+ "high": {"disabled": True},
135
+ }
136
+ entry["limit"] = {"context": context, "input": context, "output": min(8192, context // 4)}
137
+ provider = {"npm": "@ai-sdk/openai-compatible", "name": "Ollama", "options": {"baseURL": f"{OLLAMA_FROM_TASKS}/v1"}}
138
+ return {"provider": {"ollama": {**provider, "models": {model: entry}}}}
139
+
140
+
141
+ def codex_level(value: object) -> str | None:
142
+ if isinstance(value, bool):
143
+ return "high" if value else "none"
144
+ return value if isinstance(value, str) and value in CODEX_LEVELS and value != "none" else None
145
+
146
+
147
+ def codex_catalog(model: str, context: int, thinking: dict | None) -> dict:
148
+ """`ollama launch codex`'s model catalog entry, so Codex knows the model (otherwise it warns that it falls back
149
+ to defaults that "can degrade performance"). `thinking`: Ollama's, as `/api/show` gives it."""
150
+ values = list((thinking or {}).get("values") or [])
151
+ levels: list[str] = []
152
+ for value in values:
153
+ if value is True and "high" in values:
154
+ continue
155
+ level = codex_level(value)
156
+ if level is not None and level not in levels:
157
+ levels.append(level)
158
+ default = codex_level((thinking or {}).get("default"))
159
+ if default not in levels or (len(values) == 1 and False in values):
160
+ default = None
161
+ entry = {
162
+ "slug": model,
163
+ "display_name": model,
164
+ "context_window": context,
165
+ "shell_type": "default",
166
+ "visibility": "list",
167
+ "supported_in_api": True,
168
+ "priority": 0,
169
+ "truncation_policy": {"mode": "bytes", "limit": 10000},
170
+ "input_modalities": ["text"],
171
+ "base_instructions": "",
172
+ "support_verbosity": True,
173
+ "default_verbosity": "low",
174
+ "supports_parallel_tool_calls": False,
175
+ "supports_reasoning_summaries": False,
176
+ "supported_reasoning_levels": [{"effort": level, "description": CODEX_LEVELS[level]} for level in levels],
177
+ "default_reasoning_level": default,
178
+ "experimental_supported_tools": [],
179
+ }
180
+ return {"models": [entry]}
181
+
182
+
183
+ def codex_config() -> dict:
184
+ """`ollama launch codex`'s profile: Ollama's Responses API, and the model catalog."""
185
+ provider = {"name": "Ollama", "base_url": f"{OLLAMA_FROM_TASKS}/v1/", "wire_api": "responses"}
186
+ return {
187
+ "model_provider": "ollama-launch",
188
+ "model_providers": {"ollama-launch": provider},
189
+ "model_catalog_json": CODEX_CATALOG,
190
+ }
191
+
192
+
193
+ def agent_setup(agent: str, model: str, context: int, show: dict, folder: Path) -> tuple[list[str], Path | None]:
194
+ """Harbor's arguments for another agent on `model` (the Ollama model at `context`), and Codex's model catalog,
195
+ written in `folder`. `show`: Ollama's `/api/show` for the model."""
196
+ thinking = "thinking" in (show.get("capabilities") or [])
197
+ if agent == "claude-code":
198
+ return [arg for name, value in CLAUDE_CODE_ENV.items() for arg in ("--ae", f"{name}={value}")], None
199
+ if agent == "opencode":
200
+ return ["--ak", "opencode_config=" + json.dumps(opencode_config(model, context, thinking))], None
201
+ if agent == "codex":
202
+ catalog = folder / "codex-models.json"
203
+ catalog.write_text(json.dumps(codex_catalog(model, context, show.get("thinking") if thinking else None)))
204
+ return ["--ak", "config=" + json.dumps(codex_config())], catalog
205
+ raise ValueError(f"unknown agent {agent!r}")
206
+
207
+
208
+ def harbor_env() -> dict[str, str]:
209
+ """For Harbor itself: other agents reach Ollama through its `ollama/` provider, which needs a key (any)."""
210
+ return {"OLLAMA_BASE_URL": OLLAMA_FROM_TASKS, "OLLAMA_API_KEY": "ollama"}
211
+
212
+
70
213
  def find_ollama(routes: str = "/proc/net/route") -> str:
71
214
  """Shell that sets OLLAMA_HOST, unless it's set, to Ollama on your machine as a task's container sees it:
72
215
  host.docker.internal where Docker provides it (Docker Desktop), else the container's default gateway, which is
@@ -181,17 +324,22 @@ def harbor_argv(
181
324
  lcode_with: list[str] | None = None,
182
325
  wheel: Path | None = None,
183
326
  overlay: Path | None = None,
327
+ agent: str = "lcode",
328
+ agent_args: list[str] | None = None,
184
329
  ) -> list[str]:
185
- """`harbor run` for some tasks of a dataset, with uvx, and lcode next to Harbor so it can import the agent."""
330
+ """`harbor run` for some tasks of a dataset, with uvx, and lcode next to Harbor so it can import the agent.
331
+ Another `agent` (Harbor's name) gets `model` as Harbor's `ollama/` model and `agent_args` (agent_setup)."""
186
332
  argv = ["uvx", "--python", HARBOR_PYTHON, "--from", HARBOR, *(lcode_with or []), "harbor", "run"]
187
- argv += ["-d", DATASETS[dataset], "-a", AGENT, "-m", model, "-k", str(attempts), "-n", "1"]
333
+ harbor_agent, harbor_model = (AGENT, model) if agent == "lcode" else (agent, f"ollama/{model}")
334
+ argv += ["-d", DATASETS[dataset], "-a", harbor_agent, "-m", harbor_model, "-k", str(attempts), "-n", "1"]
188
335
  argv += ["-o", str(jobs), "--job-name", job_name, "-y"]
189
336
  for task in tasks:
190
337
  argv += ["-i", task, "-i", f"*/{task}"] # the name alone, or with its organization in front
191
- if context:
338
+ if context and agent == "lcode": # the others get a model with the context set (variant_name)
192
339
  argv += ["--ak", f"context={context}"]
193
340
  if wheel:
194
341
  argv += ["--ak", f"wheel={wheel}"]
342
+ argv += agent_args or []
195
343
  if overlay:
196
344
  argv += ["--extra-docker-compose", str(overlay)]
197
345
  return argv
@@ -209,6 +357,7 @@ class Trial:
209
357
  tokens_in: int | None = None # None: not known (no trace)
210
358
  tokens_out: int | None = None
211
359
  error: str = ""
360
+ version: str = "" # the agent's, in the task's container
212
361
 
213
362
 
214
363
  def seconds_between(timing: dict | None) -> float | None:
@@ -250,6 +399,7 @@ def read_trials(job: Path, dataset: str) -> list[Trial]:
250
399
  tokens_in=None if tokens_in is None else int(number(tokens_in)),
251
400
  tokens_out=None if tokens_out is None else int(number(tokens_out)),
252
401
  error=error,
402
+ version=str((result.get("agent_info") or {}).get("version") or ""),
253
403
  )
254
404
  )
255
405
  return trials
@@ -344,6 +494,32 @@ def took(seconds: float) -> str:
344
494
  return f"{hours} h {minutes} min" if hours else f"{minutes} min"
345
495
 
346
496
 
497
+ def context_variant(settings: dict, model: str, context: int, console) -> tuple[str, dict]:
498
+ """The Ollama model for another agent (variant_name), made when it's missing, and Ollama's `/api/show` for it.
499
+ Making it copies nothing: it's the same files with one more parameter."""
500
+ from rich.markup import escape
501
+
502
+ from lcode.cli import NotInstalled, resolve_model
503
+ from lcode.config import format_tokens
504
+ from lcode.ollama import Ollama
505
+
506
+ if settings.get("backend", "ollama") != "ollama":
507
+ raise OllamaError("--agent runs the other agents on Ollama's models: lcode's backend here isn't Ollama.")
508
+ ollama = Ollama(settings["ollama_host"])
509
+ try:
510
+ tag, _ = resolve_model(ollama, model)
511
+ except NotInstalled as e:
512
+ raise OllamaError(str(e)) from e
513
+ name = variant_name(tag, context)
514
+ if name not in ollama.installed_names():
515
+ ollama.create_variant(name, tag, {"num_ctx": context})
516
+ console.print(
517
+ f"Made [bold]{escape(name)}[/]: {escape(tag)} with a {format_tokens(context)} context window, for the "
518
+ f"other agents, which can't set it per request. `ollama rm {escape(name)}` removes it."
519
+ )
520
+ return name, ollama.show(name)
521
+
522
+
347
523
  def print_slice(console, name: str) -> None:
348
524
  for dataset, tasks in SLICES[name].items():
349
525
  console.print(f"[bold]{DATASETS[dataset]}[/] ({len(tasks)}): {', '.join(tasks)}")
@@ -372,6 +548,7 @@ def command(args, console) -> int:
372
548
  model = args.models[0] if args.models else settings["model"]
373
549
  # Always given: in a task's container lcode sees no GPU and would pick a context for the CPU.
374
550
  context = config.parse_context(args.context or settings.get("context") or 32768)
551
+ agent = getattr(args, "agent", None) or "lcode"
375
552
  attempts = max(1, args.attempts)
376
553
  wanted = {name.strip() for name in args.tasks.split(",")} if args.tasks else None
377
554
  picked = {
@@ -383,11 +560,25 @@ def command(args, console) -> int:
383
560
  f"[red]Not in the {args.harbor} slice: {', '.join(unknown)}[/] (lcode bench --harbor {args.harbor} --list)"
384
561
  )
385
562
  return 2
386
- jobs = config.STATE_DIR / "bench" / f"{args.harbor}-{dt.datetime.now():%Y%m%d-%H%M%S}"
563
+ ollama_model, show, agent_args, env = "", {}, None, None
564
+ if agent != "lcode": # on Ollama's model at the context, set up like `ollama launch` does
565
+ try:
566
+ ollama_model, show = context_variant(settings, model, context, console)
567
+ except OllamaError as e:
568
+ console.print(f"[red]{escape(str(e))}[/]")
569
+ return 1
570
+ named = args.harbor if agent == "lcode" else f"{args.harbor}-{agent}"
571
+ jobs = config.STATE_DIR / "bench" / f"{named}-{dt.datetime.now():%Y%m%d-%H%M%S}"
387
572
  jobs.mkdir(parents=True, exist_ok=True)
388
573
  install = update.lcode_install()
389
574
  wheel = None
390
- if install.kind == "checkout" and install.path: # this checkout, in Harbor and in the containers
575
+ if agent != "lcode":
576
+ agent_args, catalog = agent_setup(agent, ollama_model, context, show, jobs)
577
+ overlay = jobs / "overlay.yaml"
578
+ overlay.write_text(agent_overlay(bool(args.docker_bridge), catalog))
579
+ lcode_with = None
580
+ env = {**os.environ, **harbor_env()}
581
+ elif install.kind == "checkout" and install.path: # this checkout, in Harbor and in the containers
391
582
  lcode_with = ["--with-editable", str(install.path)]
392
583
  build = ["uv", "build", "--wheel", "-q", "-o", str(jobs / "wheel"), str(install.path)]
393
584
  if subprocess.run(build, capture_output=True, text=True).returncode != 0:
@@ -396,25 +587,32 @@ def command(args, console) -> int:
396
587
  wheel = next((jobs / "wheel").glob("*.whl"), None)
397
588
  else:
398
589
  lcode_with = ["--with", f"lcode-cli=={__version__}"]
399
- overlay = None
400
- if args.docker_bridge:
401
- overlay = jobs / "bridge.yaml"
402
- overlay.write_text(BRIDGE_OVERLAY)
590
+ if agent == "lcode":
591
+ overlay = None
592
+ if args.docker_bridge:
593
+ overlay = jobs / "bridge.yaml"
594
+ overlay.write_text(BRIDGE_OVERLAY)
403
595
  trials: list[Trial] = []
404
596
  started, began = dt.datetime.now().astimezone(), time.monotonic()
405
597
  for dataset, tasks in picked.items():
406
598
  if not tasks:
407
599
  continue
408
600
  argv = harbor_argv(
409
- dataset, tasks, model, jobs, dataset, attempts=attempts, context=context, lcode_with=lcode_with,
410
- wheel=wheel, overlay=overlay,
601
+ dataset, tasks, ollama_model or model, jobs, dataset, attempts=attempts, context=context,
602
+ lcode_with=lcode_with, wheel=wheel, overlay=overlay, agent=agent, agent_args=agent_args,
411
603
  ) # fmt: skip
412
604
  console.print(f"[bold]{DATASETS[dataset]}[/]: {len(tasks)} task(s), {attempts} attempt(s) each")
413
605
  console.print(f"[dim]{escape(shlex.join(argv))}[/]")
414
- subprocess.call(argv)
606
+ if env is None:
607
+ subprocess.call(argv)
608
+ else:
609
+ subprocess.call(argv, env=env)
415
610
  trials += read_trials(jobs / dataset, dataset)
416
611
  summary = summarize(trials, attempts)
417
612
  seconds = time.monotonic() - began
613
+ version = next((trial.version for trial in trials if trial.version), "")
614
+ if agent != "lcode":
615
+ console.print(f"[bold]{agent}[/] {escape(version)} on {escape(ollama_model)}")
418
616
  print_summary(console, summary)
419
617
  console.print(f"Took {took(seconds)}.")
420
618
  if any("fully subnetted" in trial.error for trial in trials):
@@ -427,7 +625,10 @@ def command(args, console) -> int:
427
625
  "lcode": __version__,
428
626
  "harbor": HARBOR,
429
627
  "slice": args.harbor,
628
+ "agent": agent,
629
+ "agent_version": version, # in the tasks' containers
430
630
  "model": model,
631
+ "ollama_model": ollama_model or None, # the other agents': the model with the context set
431
632
  "context": context,
432
633
  "attempts": attempts,
433
634
  "docker_bridge": bool(args.docker_bridge),
lcode/ollama.py CHANGED
@@ -125,6 +125,13 @@ class Ollama:
125
125
  except requests.RequestException as e:
126
126
  raise OllamaError(f"pull failed: {e}") from e
127
127
 
128
+ def create_variant(self, name: str, base: str, parameters: dict) -> None:
129
+ """Create `name`: `base` with other parameters (a context window, say). It uses `base`'s files: nothing is
130
+ downloaded or copied."""
131
+ payload = {"model": name, "from": base, "parameters": parameters, "stream": False}
132
+ if self._post("/api/create", payload, timeout=600).get("status") != "success":
133
+ raise OllamaError(f"creating {name} failed")
134
+
128
135
  def create_text_only(self, name: str, base: str) -> bool:
129
136
  """Create `name` from `base` without its vision projector. Returns False if `base` has none.
130
137
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lcode-cli
3
- Version: 0.55.0
3
+ Version: 0.57.0
4
4
  Summary: A local-first terminal coding agent powered by open-weight models on your own GPU or Mac, via Ollama.
5
5
  Project-URL: Homepage, https://nasser1941.github.io/lcode/
6
6
  Project-URL: Documentation, https://nasser1941.github.io/lcode/
@@ -182,6 +182,7 @@ lcode
182
182
  | `lcode models` / `lcode doctor` | what fits this machine / check the installation |
183
183
  | `lcode bench qwen3.6-35b qwen3.5-9b` | compare models on small coding tasks on this machine |
184
184
  | `lcode bench --harbor dev` | run lcode on a slice of Terminal-Bench 2.0 and SWE-bench Verified, with Harbor |
185
+ | `lcode bench --harbor dev --agent codex` | the same with Claude Code, OpenCode or Codex on your model, to compare |
185
186
  | `lcode trace` / `lcode trace show 1` | past requests, step by step with times and tokens; export or replay one |
186
187
  | `/undo`, `/rewind` | take back the last request's file changes, or go back further |
187
188
  | `lcode mcp catalog` / `lcode mcp add github` | ready-made MCP servers / add one |
@@ -1,6 +1,6 @@
1
1
  lcode/docs/agents.md,sha256=A1heI40IKf767li9ffAH1grLlo2RhfbmB7lHL2uhZ4g,6915
2
2
  lcode/docs/automation.md,sha256=Y57MWEVDjhOIDsnuWhzTB0K-5wlAm4nW2uOVWTAzeEM,9450
3
- lcode/docs/bench.md,sha256=4ot6vU_AKyDfj9MlMe98mFwO4l2J4fH_U5_2LxCr-PU,13109
3
+ lcode/docs/bench.md,sha256=C35gV5QZGdx0Oa6pClPxCrGuGkVXQZJsuzwOyMrEymE,15094
4
4
  lcode/docs/commands.md,sha256=PpRcOoKZXw1OQyGxEbmipEPDYAid1fLDiaarHax7ynU,5973
5
5
  lcode/docs/configuration.md,sha256=9L5mZtN9HyDQ5cXugUpUX5AXxxR1qNrwLmNMUlxGKgc,11112
6
6
  lcode/docs/editors.md,sha256=9Ztqg_nyV5UTnMlJYrJrNvzY59X0d1HdWKYrs9-tZn4,3295
@@ -14,15 +14,15 @@ lcode/docs/mcp.md,sha256=Ol3ScuP4i2KsoN9xaSEbnm86Tvoc1qnUV7zkRprWwHo,15168
14
14
  lcode/docs/memory.md,sha256=XbsNnTwRdnUEYW7_2U1GHbtK0uOjTxR-s2EujgJbR0Y,6889
15
15
  lcode/docs/models.md,sha256=d9wLOVBlMtnd8_2jQG9f0-qcEbGT6qtnwOdQSco-RD8,17121
16
16
  lcode/docs/modes.md,sha256=vNQv5K-lk6egNQNlnOHk8YeIdoAsmyaWvSu-RbQeZnQ,34039
17
- lcode/docs/public-benchmarks.md,sha256=btUn1zwc46lcmWTqbpothnJsqjHfxKt2vj_fbhhSMP4,6310
18
- lcode/docs/quickstart.md,sha256=nS8DJagdOqKXzJK0AG87EoSqqfRnx4-hCG6WVjlC5aU,3403
17
+ lcode/docs/public-benchmarks.md,sha256=n6ef_v_sBIRfS8oJj9TFL0mvOA0SRRA-MPBN_YGPho4,8267
18
+ lcode/docs/quickstart.md,sha256=-cwZAKay41isEr91cVLJmaDR94psTXFElxUCH7N8Al8,3403
19
19
  lcode/docs/sandbox.md,sha256=-_jc2I0LXKQIYCz_JOuHGaP2ehVuEqEepKqMATlFpZY,4064
20
- lcode/docs/search.md,sha256=UKYrYG_xo67-bOLU1hLgiiTh3Dy6s9LG4nuc2JTQHa8,4249
20
+ lcode/docs/search.md,sha256=1Sqkfc9NRftpcfBFG9b_D8Ns-octH399AaaSNBPHq28,4251
21
21
  lcode/docs/servers.md,sha256=0ddumHseQXx0CP0nqzgwV-493s81kdEBa6qtUYe9t6k,5718
22
22
  lcode/docs/traces.md,sha256=yY3ZT9twJeGqE-Yyo9Raynz3YqKS4uNoShBq8SPsYGI,10036
23
23
  lcode/docs/troubleshooting.md,sha256=YcwmrpR6jcxnhDqV1-E7VQKeczfEC3xuokVkejkAoLo,6292
24
- lcode/docs/usage.md,sha256=_dNyJhE6opWzozxAHW-7yDUHh1CEcYYAuUot0FxGYPI,48037
25
- lcode/__init__.py,sha256=nZIC11RlJK9Z_6eBc2C-2VT2l1f8DjO1t-cRkKLnx8U,473
24
+ lcode/docs/usage.md,sha256=6l48yg2qX9j9oD_AkFn9jjRCg8q4Mc8uBuqy_Mlj43U,48133
25
+ lcode/__init__.py,sha256=-wcCpx3C-mQwQliWiUqgs3m3iUHEKUa2E51yBRt0rys,473
26
26
  lcode/__main__.py,sha256=s5N5pryX2FAu93GGZ3FxUrIXHWGzxz66lKUoaV_h8Ws,35
27
27
  lcode/acp.py,sha256=eFNYdJNJd9tdCbF2UIj1N3UU4RnF2-pcMLA0KBYZbwE,29082
28
28
  lcode/action.py,sha256=wuT5F9EJCdEligPeytzmEi8FpahWBhXer528tpuTj_k,16711
@@ -30,13 +30,13 @@ lcode/agent.py,sha256=WWGGFXQhhKISAvqkQJZFkqLQZoh1wxVrKpQ7nA6reNE,93332
30
30
  lcode/api.py,sha256=5Lg9IhZkz75Q4G0LbTQnWpgUhJgvIj1DpE1KFMS1Fi8,19959
31
31
  lcode/assistant.py,sha256=zEj6Pt771154xokyy4Xq9cII03lrIjFnCVcc423QyEY,8032
32
32
  lcode/backends.py,sha256=343alwyDZin-bEhb5-Es4f8ek1oBQUzEvV6RFWR1VZo,21160
33
- lcode/bench.py,sha256=HxeUfy9Kv_0Rug1HAlDLyHYfYd9dw2bMgbXsvUy9nd4,43096
33
+ lcode/bench.py,sha256=Z7OtZi0L9KjRc-ohAfHE66N2Cs3aqkw1GAvbRdyzr6o,47236
34
34
  lcode/bench_backend.py,sha256=X2fo-zRX92Xp3KMxSsFlWioc2vRupBTtowj5kLME8mw,14287
35
35
  lcode/bench_runtime.py,sha256=EjzNgIvUkdbT8cbSy1TpmlyeIk6e-ipjlDFpM7Dnqx0,6835
36
36
  lcode/catalog.py,sha256=pZ1azX9OH2r4JE2c6E5OfwywpgS39-W2oXzoCHJhmtM,4141
37
37
  lcode/checkpoints.py,sha256=eqPtmPe44-aweWqc2H21ROogwzIt3NpvcUobsaCHoGY,18354
38
38
  lcode/checks.py,sha256=haYYIPhadKavGYEhh8YWAaWrPMcfzrpT2i6638f4xjQ,12933
39
- lcode/cli.py,sha256=O6M6J-yWxLUIQjCeSzldoDdnziMpRYpZn0J9wmtpgQs,54327
39
+ lcode/cli.py,sha256=EqgK7mevyyshcUcRzlcxvxZI9H3RPnJh5IlJAGwfNyQ,55261
40
40
  lcode/clipboard.py,sha256=nTSdJyCXPdtjH947RjvB3QvRqnL5HZsS9KB8EkC42cc,5138
41
41
  lcode/cloud.py,sha256=q5Dl5GuqWvKzBCIso-eh6yomvEOsnQ0LW8ZgaAGwBxc,2131
42
42
  lcode/codesearch.py,sha256=Io8leN1nb_Y-Dvlm9xaGtwUWYXX-ooswuznJV6dGU1s,10766
@@ -50,7 +50,7 @@ lcode/film.py,sha256=nfffI6oMWeherp8AOU_yM7-Cok0JKoQMVeuVtVHKXo0,14455
50
50
  lcode/frontmatter.py,sha256=Bx0n4vLPhp7ZCWx-g7xqzqNy5VoKBxyeeikh5UFB_gA,2441
51
51
  lcode/gitflow.py,sha256=6j_nnCBZXkX1qhTI7K4CyZ5D0NAZLpH96weFEo64AkQ,27913
52
52
  lcode/harbor.py,sha256=DwD40Ga5z0GP6Tu3ixXttJb7j4LIhC4vAN5VfGMcLQ0,3314
53
- lcode/harbor_bench.py,sha256=DV2B5_Bntr20CQ65zNunm_usASYdLEKbWtlgNaLFfek,20853
53
+ lcode/harbor_bench.py,sha256=wWBszA758n14LMzbEOiJ0eb_tIi6fgRFykIv6Fzy3oE,30829
54
54
  lcode/hardware.py,sha256=9j_gxSUYLAVtnSLIEL8FVU2q-jEEjHtMs2SVAax7yU8,5154
55
55
  lcode/hooks.py,sha256=K0itOiAuH4rxndJ9gne_uCrqby6oWAzFPRrfB3tCq-E,9324
56
56
  lcode/imageopts.py,sha256=qELIIdKUJT3GLv9mhnjr_TeYNhOXhTMW3tgHzpuqW-Q,9715
@@ -67,7 +67,7 @@ lcode/memory.py,sha256=uyGNn_yNdvn-ie1vnum25-VNieHyZip7lnzrcIzGNb0,24526
67
67
  lcode/models.toml,sha256=lt2G64zzo_Ryxv2ISRSNZoVD_JqCqYqsM01n8WoXGs8,4098
68
68
  lcode/modes.py,sha256=Ybn9Pe2JJjOCIsixZpg-AHvB1nUMckNEiDKGHBLFXjA,5190
69
69
  lcode/notify.py,sha256=uieDeXe7XwuVHjOk4tqVyZEW_85XWkoWQmFOWEf77oc,1538
70
- lcode/ollama.py,sha256=xFHU2XW47ANJ34-1aeSMQVj28GhqcWiFi6zASH9FiYY,8053
70
+ lcode/ollama.py,sha256=2-tH2ef9Paz-6916UJJN1ltxHoebTuwv6DBVQ09sEpg,8515
71
71
  lcode/permissions.py,sha256=q7CjDsc_Xrblw7t3_BbxA5LUjxFSswGs1RiJmtMi0po,12288
72
72
  lcode/planning.py,sha256=a0rjnj57qwlxqremFgfDGCNgKO-fTKWj36Hj4fBmhbg,6562
73
73
  lcode/preview.py,sha256=ATzEs6yaI1__bfo2_juWznrTDXUD4QTc_aQMPRCytgA,6253
@@ -119,8 +119,8 @@ lcode/workflows/wan21-vace.json,sha256=vJsiRvLCXCjKIibOO0SGM3fT6bedAGxF8N2sN2vcP
119
119
  lcode/workflows/wan22-fun-inp-5b.json,sha256=4HbKEezik8MHvxTMP6PjQUPQPfCeSu10U9FrC-DHKYw,3327
120
120
  lcode/workflows/wan22-ti2v-5b.json,sha256=RcTehoC2pNizzlb7Ed3keJ56DiE7V5lhXmsvR2Y0smQ,3371
121
121
  lcode/workflows/z-image-turbo-t2i.json,sha256=sHsL7xnnuULOuWGYlQrDl4jOTySdAmb2T82c_cChv0s,1585
122
- lcode_cli-0.55.0.dist-info/METADATA,sha256=QmuPY1V2wDb6iwy6zCj_dkCf3YakuIE02F_tjSxnZ0I,14142
123
- lcode_cli-0.55.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
124
- lcode_cli-0.55.0.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
125
- lcode_cli-0.55.0.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
126
- lcode_cli-0.55.0.dist-info/RECORD,,
122
+ lcode_cli-0.57.0.dist-info/METADATA,sha256=GC8ZFRAkldIxueidyTgBwUleax29PHeKrczH13t4FDQ,14260
123
+ lcode_cli-0.57.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
124
+ lcode_cli-0.57.0.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
125
+ lcode_cli-0.57.0.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
126
+ lcode_cli-0.57.0.dist-info/RECORD,,