eval: gobang as a Track B native agent

gobang, the Aji-native harness, joins Codex, Claude Code and OpenCode in
ajieval native. Like them it is an agent product: its runs are never
evidence for H4. Model ids choose the provider: claude-* the Anthropic
API, any other GLM via z.ai, fixture:PATH a scenario without network
(self-tests).

gobang reaches the model over its API, so the key's variable is passed
into the sandbox environment; NativeAgent.env supplies it, its value
never enters the run record, and a missing key stops the run before
anything is created. Tool processes run in gobang's own networkless
bubblewrap sandbox, so no shell wrapper is used. The transcript is
gobang's journal: usage, tool calls and the model come from its events,
the repair metrics from its toolchain tools (aji_check, aji_run,
run_tests with aji's exit codes), and its documentation tools count as
reads of /docs files.

Checked end to end on dev-echo (aji_source) with a fixture model: the
dev evaluator accepts the solution, the workspace holds only the
solution, and the first-check and first-test metrics are exact. With a
fake key the run reaches z.ai from the sandbox and ends INFRA_FAILED
(auth) without the key in any file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
devandClaude Opus 5.5 committed 2026-10-08 15:00:36 +03:00
1 parent 762c5abe7b
commit 0e98638bc6
4 files changed
+246 -2

No files matched your search

+66
View File
@@ -257,6 +257,72 @@ class NativeTest(unittest.TestCase):
oc = native.AGENTS["opencode"].configure(home, "p/m", None)[".config/opencode/opencode.json"]
self.assertFalse(oc["tools"]["webfetch"] or oc["tools"]["task"])
def test_gobang_adapter(self):
"""gobang: configuration by model id, the key only in the
environment, and the facts and toolchain commands of its journal."""
from ajieval import context, native
g = native.AGENTS["gobang"]
home = tempfile.mkdtemp()
cfg = g.configure(home, "glm-5.3-flash", "high")[".config/gobang/gobang.toml"]
self.assertIn('provider = "openai"', cfg)
self.assertIn('key_env = "ZAI_API_KEY"', cfg)
self.assertIn('mode = "required"', cfg)
self.assertIn('docs = "/docs"', cfg)
self.assertIn('reasoning_effort = "high"', cfg)
self.assertIn('key_env = "ANTHROPIC_API_KEY"', g.configure(home, "claude-opus-5-5", None)[".config/gobang/gobang.toml"])
scenario = os.path.join(home, "s.jsonl")
open(scenario, "w").write("{}\n")
self.assertIn('provider = "fixture"', g.configure(home, "fixture:" + scenario, None)[".config/gobang/gobang.toml"])
self.assertTrue(os.path.exists(os.path.join(home, ".config", "gobang", "scenario.jsonl")))
self.assertEqual(g.env("fixture:" + scenario), {})
old = os.environ.pop("ZAI_API_KEY", None)
try:
with self.assertRaises(SystemExit):
g.env("glm-5.3-flash")
os.environ["ZAI_API_KEY"] = "zk-test"
self.assertEqual(g.env("glm-5.3-flash"), {"ZAI_API_KEY": "zk-test"})
self.assertNotIn("zk-test", json.dumps(g.configure(home, "glm-5.3-flash", None)))
finally:
os.environ.pop("ZAI_API_KEY", None)
if old is not None:
os.environ["ZAI_API_KEY"] = old
argv = g.argv("m", None, "PROMPT")
self.assertEqual(argv[:3], ["gobang", "run", "--json-events"])
self.assertEqual(argv[-2:], ["--task", "PROMPT"])
self.assertFalse(g.netless_shell)
def ev(seq, t, data):
return json.dumps({"v": 1, "session": "g", "seq": seq, "ts": "", "state": "S", "type": t, "data": data})
# gobang writes compact JSON, as aji does.
check_rejected = json.dumps({"ok": True, "outcome": "rejected", "groups": [{"code": "E3101", "severity": "error"}]}, separators=(",", ":"))
lines = [
ev(1, "SESSION_CREATED", {"prompt_sha256": "sha256:p"}),
ev(2, "CONFIG_RESOLVED", {"test_command_argv": ["sh test.sh"]}),
ev(3, "MODEL_RESPONDED", {"response": {"model_reported": "glm-5.3-flash", "finish_reason": "tool_use", "usage": {"input": 1000, "output": 50, "cache_read": 600}}}),
ev(4, "TOOL_REQUESTED", {"call_id": "c1", "tool": "aji_check", "arguments": "{}"}),
ev(5, "TOOL_COMPLETED", {"call_id": "c1", "tool": "aji_check", "output": check_rejected}),
ev(6, "TOOL_REQUESTED", {"call_id": "c2", "tool": "docs_read", "arguments": "{\"section\":\"QUICK.md#1-skeleton\"}"}),
ev(7, "TOOL_COMPLETED", {"call_id": "c2", "tool": "docs_read", "output": json.dumps({"ok": True, "text": "3\tEvery function lists its effects.\n"})}),
ev(8, "TOOL_REQUESTED", {"call_id": "c3", "tool": "run_tests", "arguments": "{}"}),
ev(9, "TOOL_COMPLETED", {"call_id": "c3", "tool": "run_tests", "output": json.dumps({"ok": True, "passed": 0, "failed": 1, "errors": 0})}),
ev(10, "MODEL_RESPONDED", {"response": {"finish_reason": "stop", "usage": {"input": 1200, "output": 10, "cache_read": 1000}}}),
ev(11, "SESSION_FINISHED", {"state": "FAILED", "reason": "verification_failed"}),
]
tr = os.path.join(home, "transcript.jsonl")
open(tr, "w").write("\n".join(lines) + "\n")
facts = g.parse(tr)
self.assertEqual(facts["tool_calls"], 3)
self.assertEqual(facts["model"], "glm-5.3-flash")
self.assertEqual(facts["gobang_state"], "FAILED")
self.assertEqual(native.normalize_usage(facts["usage"]), {"input": 2200, "output": 60, "cached_input": 1600})
cmds = native.command_events("gobang", tr)
self.assertEqual([(c, code) for c, code, _ in cmds], [("aji check", 1), ("aji run; sh test.sh", 1)])
prof = {"diagnostic_pattern": '"severity":"error"', "classify": {"check": ["aji check"], "test": ["aji run"]}}
m = native.cycles(prof, "sh test.sh", cmds)
self.assertEqual((m["first_check_accepted"], m["first_public_test_passed"], m["failed_verifier_cycles"], m["failed_test_cycles"]), (False, False, 1, 1))
events = context.tool_events_native("gobang", tr)
self.assertIn(("/docs/QUICK.md", "3\tEvery function lists its effects.\n"), events)
def test_usage_normalization(self):
from ajieval import native
self.assertEqual(native.normalize_usage({"input_tokens": 100, "cached_input_tokens": 60, "output_tokens": 5}), {"input": 100, "output": 5, "cached_input": 60})