Skip to content

Commit 4f570da

Browse files
sjarmakclaude
andcommitted
fix: lazy-import harness agents, add version-pinned SG mirrors
- Make harness agent imports (codex, cursor, gemini, copilot, openhands) lazy so the agents package works without harbor installed. This allows local scripts to use metrics/config modules without Docker. - Add 4 version-pinned SG mirrors to instance_to_mirror.json: envoy v1.30.0/v1.31.0 and terraform v1.9.0/v1.10.0 for multi-version comparison tasks (envoy-migration, terraform-arch). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fe2ae0c commit 4f570da

File tree

3 files changed

+80
-14
lines changed

3 files changed

+80
-14
lines changed

agents/__init__.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@
4141
create_example_config,
4242
)
4343

44-
from .harnesses import (
45-
CodexHarnessAgent,
46-
CopilotHarnessAgent,
47-
CursorHarnessAgent,
48-
GeminiHarnessAgent,
49-
OpenHandsHarnessAgent,
50-
)
44+
# Harness agents require the ``harbor`` package (only available inside
45+
# Docker containers). They are re-exported via __getattr__ so the rest
46+
# of this package works without harbor installed.
5147

5248
__all__ = [
5349
# Metrics extraction
@@ -78,10 +74,26 @@
7874
"parse_ablation_config",
7975
"create_example_config",
8076

81-
# Harness agents
77+
# Harness agents (lazy-imported, require harbor)
8278
"CodexHarnessAgent",
8379
"CopilotHarnessAgent",
8480
"CursorHarnessAgent",
8581
"GeminiHarnessAgent",
8682
"OpenHandsHarnessAgent",
8783
]
84+
85+
86+
_HARNESS_AGENTS = {
87+
"CodexHarnessAgent",
88+
"CopilotHarnessAgent",
89+
"CursorHarnessAgent",
90+
"GeminiHarnessAgent",
91+
"OpenHandsHarnessAgent",
92+
}
93+
94+
95+
def __getattr__(name):
96+
if name in _HARNESS_AGENTS:
97+
from . import harnesses
98+
return getattr(harnesses, name)
99+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

agents/harnesses/__init__.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
"""Harness-specific agent implementations."""
1+
"""Harness-specific agent implementations.
22
3-
from .codex import CodexHarnessAgent
4-
from .copilot import CopilotHarnessAgent
5-
from .cursor import CursorHarnessAgent
6-
from .gemini import GeminiHarnessAgent
7-
from .openhands import OpenHandsHarnessAgent
3+
These agents depend on the ``harbor`` package which is only available
4+
inside Docker containers. The imports are deferred so that the rest of
5+
the ``agents`` package can be used without harbor installed.
6+
"""
87

98
__all__ = [
109
"CodexHarnessAgent",
@@ -13,3 +12,19 @@
1312
"GeminiHarnessAgent",
1413
"OpenHandsHarnessAgent",
1514
]
15+
16+
17+
def __getattr__(name):
18+
"""Lazy-import harness agents so harbor is only required at use time."""
19+
_map = {
20+
"CodexHarnessAgent": ".codex",
21+
"CopilotHarnessAgent": ".copilot",
22+
"CursorHarnessAgent": ".cursor",
23+
"GeminiHarnessAgent": ".gemini",
24+
"OpenHandsHarnessAgent": ".openhands",
25+
}
26+
if name in _map:
27+
import importlib
28+
mod = importlib.import_module(_map[name], package=__name__)
29+
return getattr(mod, name)
30+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

configs/instance_to_mirror.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,45 @@
591591
"ccb_dependeval/multifile_editing-java-e1c422ed": "sg-benchmarks/dependeval-java-me-e1c422ed",
592592
"ccb_dependeval/multifile_editing-python-ea840a03": "sg-benchmarks/dependeval-python-me-ea840a03",
593593
"ccb_dependeval/dependency_recognition-javascript-ef7ab7e5": "sg-benchmarks/dependeval-javascript-dr-ef7ab7e5",
594+
"version_pinned": {
595+
"_note": "Version-pinned mirrors for multi-version comparison tasks (e.g. migration doc-gen). Each version has its own mirror.",
596+
"envoy": {
597+
"v1.30.0": {
598+
"repo": "envoyproxy/envoy",
599+
"mirror_name": "sg-benchmarks/envoy--50ea83e6",
600+
"commit": "50ea83e602d5da162df89fd5798301e22f5540cf",
601+
"tag": "v1.30.0",
602+
"indexed": true,
603+
"used_by": ["envoy-migration-doc-gen-001"]
604+
},
605+
"v1.31.0": {
606+
"repo": "envoyproxy/envoy",
607+
"mirror_name": "sg-benchmarks/envoy--7b8baff1",
608+
"commit": "7b8baff1758f0a584dcc3cb657b5032000bcb3d7",
609+
"tag": "v1.31.0",
610+
"indexed": true,
611+
"used_by": ["envoy-migration-doc-gen-001"]
612+
}
613+
},
614+
"terraform": {
615+
"v1.9.0": {
616+
"repo": "hashicorp/terraform",
617+
"mirror_name": "sg-benchmarks/terraform--7637a921",
618+
"commit": "7637a9216e68f2812887eaf0722f9d3f9804c45e",
619+
"tag": "v1.9.0",
620+
"indexed": true,
621+
"used_by": ["terraform-arch-doc-gen-001"]
622+
},
623+
"v1.10.0": {
624+
"repo": "hashicorp/terraform",
625+
"mirror_name": "sg-benchmarks/terraform--24236f4f",
626+
"commit": "24236f4f0bd10ada71d70868abe15f9d88099747",
627+
"tag": "v1.10.0",
628+
"indexed": true,
629+
"used_by": ["terraform-arch-doc-gen-001"]
630+
}
631+
}
632+
},
594633
"investigation": {
595634
"_note": "Investigation tasks use major public repos directly indexed on Sourcegraph. No custom mirrors needed.",
596635
"tasks": {

0 commit comments

Comments
 (0)