fix: detect agy dialogs and mid-turn work, treat background work as idle for agy and grok (#4959)

refs #3871
refs #3530
refs #4735
refs #3419
This commit is contained in:
Can Celik
2026-10-05 18:56:03 +03:00
committed by GitHub
parent b06480673b
commit fabcab108f
6 changed files with 157 additions and 83 deletions
+4 -10
View File
@@ -53,16 +53,10 @@ MAX_MATCHERS_PER_GATE = 32
MAX_TOTAL_MATCHERS = 1024
MAX_MATCHER_CHARS = 512
# Keep engine-2 clients on the OSC-capable manifest until an engine-3 release
# can consume top_non_empty_lines. Remove this entry when the distribution
# publishes the bundled Grok manifest.
STAGED_PUBLISHED_MANIFESTS = {
"grok": (
"2026.09.18.2",
"2026.09.18.1",
"0f31b111144900b02f303577d27587f72d58d8c505185a682bd7887f822316ee",
),
}
# Keep older-engine clients on a published manifest until a release with the
# bundled manifest's engine ships. Maps agent id to (bundled version, published
# version, published sha256). Remove an entry once the bundled manifest ships.
STAGED_PUBLISHED_MANIFESTS: dict[str, tuple[str, str, str]] = {}
UNPUBLISHED_BUNDLED_MANIFESTS: dict[str, tuple[str, str]] = {}
+26 -15
View File
@@ -29,18 +29,27 @@ path = "{path}"
'''
def staged_grok_dirs(root: Path) -> tuple[Path, Path]:
STAGED_BUNDLED_MANIFEST = manifest("codex", "2026.06.10.2").replace(
"min_engine_version = 1", "min_engine_version = 2"
)
STAGED_PUBLISHED_MANIFEST = manifest("codex", "2026.06.10.1")
STAGED_TEST_EXCEPTION = {
"codex": (
"2026.06.10.2",
"2026.06.10.1",
hashlib.sha256(STAGED_PUBLISHED_MANIFEST.encode()).hexdigest(),
),
}
def staged_manifest_dirs(root: Path) -> tuple[Path, Path]:
bundled = root / "bundled"
published = root / "published"
bundled.mkdir()
published.mkdir()
(bundled / "grok.toml").write_bytes(
(check.DEFAULT_BUNDLED_DIR / "grok.toml").read_bytes()
)
(published / "grok.toml").write_bytes(
(check.DEFAULT_PUBLISHED_DIR / "grok.toml").read_bytes()
)
(published / "index.toml").write_text(catalog("grok", "grok.toml"))
(bundled / "codex.toml").write_text(STAGED_BUNDLED_MANIFEST, encoding="utf-8", newline="\n")
(published / "codex.toml").write_text(STAGED_PUBLISHED_MANIFEST, encoding="utf-8", newline="\n")
(published / "index.toml").write_text(catalog())
return bundled, published
@@ -94,22 +103,24 @@ class AgentDetectionManifestCheckTests(unittest.TestCase):
with self.assertRaisesRegex(check.CheckError, "lower than bundled"):
check.validate_catalog(website, bundled_manifests, engine_version=1)
@patch.dict(check.STAGED_PUBLISHED_MANIFESTS, STAGED_TEST_EXCEPTION, clear=True)
def test_allows_explicitly_staged_published_manifest(self):
with tempfile.TemporaryDirectory() as tmp:
bundled, website = staged_grok_dirs(Path(tmp))
bundled, website = staged_manifest_dirs(Path(tmp))
bundled_manifests = check.load_manifest_dir(bundled, engine_version=3)
check.validate_catalog(website, bundled_manifests, engine_version=3)
bundled_manifests = check.load_manifest_dir(bundled, engine_version=2)
check.validate_catalog(website, bundled_manifests, engine_version=2)
@patch.dict(check.STAGED_PUBLISHED_MANIFESTS, STAGED_TEST_EXCEPTION, clear=True)
def test_rejects_mutated_staged_published_manifest(self):
with tempfile.TemporaryDirectory() as tmp:
bundled, website = staged_grok_dirs(Path(tmp))
with (website / "grok.toml").open("a") as manifest_file:
bundled, website = staged_manifest_dirs(Path(tmp))
with (website / "codex.toml").open("a") as manifest_file:
manifest_file.write("\n# unexpected mutation\n")
bundled_manifests = check.load_manifest_dir(bundled, engine_version=3)
bundled_manifests = check.load_manifest_dir(bundled, engine_version=2)
with self.assertRaisesRegex(check.CheckError, "lower than bundled"):
check.validate_catalog(website, bundled_manifests, engine_version=3)
check.validate_catalog(website, bundled_manifests, engine_version=2)
def test_rejects_unlisted_published_manifest_lag_for_new_engine(self):
with tempfile.TemporaryDirectory() as tmp: