Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .agent/harness/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def _call_minimax(system, user, *, temperature, max_tokens, model):
r = c.chat.completions.create(
model=model,
temperature=temperature,
max_completion_tokens=max_tokens,
messages=[{"role": "system", "content": system},
{"role": "user", "content": user}],
)
Expand Down
19 changes: 16 additions & 3 deletions .agent/tools/test_learn_episodic_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ def _load_learn(base_dir):
"""Load .agent/tools/learn.py with BASE/CANDIDATES pointed at base_dir.

Sibling modules (text.word_set, cluster.pattern_id) are stubbed so the
test needs no part of the harness beyond learn.py itself.
test needs no part of the harness beyond learn.py itself. The stubs are
process-wide (sys.modules), so any previous entry for "text"/"cluster"
is saved and restored (or removed, if there was none) once exec_module
finishes -- otherwise a later test or import in the same process would
silently pick up these throwaway stand-ins instead of the real modules.
"""
previous_modules = {}
for name, attrs in [
("text", {"word_set": lambda *a, **k: set()}),
("cluster", {"pattern_id": lambda claim, cond: "testcid" + str(abs(hash((claim, tuple(cond)))))[:6]}),
]:
previous_modules[name] = sys.modules.pop(name, None)
m = types.ModuleType(name)
for k, v in attrs.items():
setattr(m, k, v)
Expand All @@ -38,7 +44,14 @@ def _load_learn(base_dir):
module_path = Path(__file__).with_name("learn.py")
spec = importlib.util.spec_from_file_location("learn_under_test", module_path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
try:
spec.loader.exec_module(mod)
finally:
for name, previous in previous_modules.items():
if previous is None:
sys.modules.pop(name, None)
else:
sys.modules[name] = previous
mod.BASE = base_dir
mod.CANDIDATES = os.path.join(base_dir, "memory", "candidates")
os.makedirs(mod.CANDIDATES, exist_ok=True)
Expand Down Expand Up @@ -68,7 +81,7 @@ def test_stage_writes_one_episodic_mirror(self):
def test_evidence_id_resolves_to_the_mirror(self):
mod = _load_learn(self.tmp)
cid, path = mod.stage("Serialize timestamps in UTC", ["timestamps", "utc"])
candidate = json.loads(Path(path).read_text())
candidate = json.loads(Path(path).read_text(encoding="utf-8"))
evidence_ts = candidate["evidence_ids"][0]
matching = [e for e in _episodic(self.tmp) if e["timestamp"] == evidence_ts]
self.assertEqual(len(matching), 1)
Expand Down
1 change: 1 addition & 0 deletions tests/test_llm_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_call_model_openai_wire_global(self):
wire, kwargs = rec.calls[0]
self.assertEqual(wire, "openai")
self.assertEqual(kwargs["model"], "MiniMax-M3")
self.assertEqual(kwargs["max_completion_tokens"], 4096)

def test_call_model_anthropic_wire_cn(self):
os.environ["AGENT_PROVIDER"] = "minimax"
Expand Down