From 7a0cdbcd790eddb3627d2b0ffda84f1c9e02847a Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Tue, 18 Aug 2026 02:05:18 -0700 Subject: [PATCH] fix(tests): pin workspace snapshot in plugin-prompt-sections byte-stability test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_real_aiagent_builds_section_once_and_keeps_it_out_of_static_prefix builds the system prompt twice and asserts byte equality, but the prompt embeds build_coding_workspace_block() — live git status/log output. A git call failing between the two builds (xdist contention in CI) makes the Branch/Recent-commits lines differ and fails the test on unrelated PRs (first seen on #89027's run: diff showed only '- Branch: (detached HEAD)' and recent-commit lines). Mechanism reproduced locally: with coding posture on and cwd inside the checkout, failing git calls on the second build only => first != rebuilt; with the snapshot pinned, identical git failure => byte-equal. The real block's byte-stability is coding_context's own contract; this test is about plugin sections. --- tests/agent/test_plugin_prompt_sections.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/agent/test_plugin_prompt_sections.py b/tests/agent/test_plugin_prompt_sections.py index ff4aea8925..d27e59b6fc 100644 --- a/tests/agent/test_plugin_prompt_sections.py +++ b/tests/agent/test_plugin_prompt_sections.py @@ -42,6 +42,16 @@ def _install_test_section(manager: PluginManager, content) -> None: def test_real_aiagent_builds_section_once_and_keeps_it_out_of_static_prefix(monkeypatch): + # Pin the workspace snapshot: build_coding_workspace_block shells out to + # live `git status`/`git log` on every build, and a git call failing or + # timing out under xdist contention makes the two builds differ in the + # Branch/Recent-commits lines — a flake unrelated to what this test + # asserts (plugin sections). Byte-stability of the REAL workspace block + # is coding_context's contract, covered by its own tests. + monkeypatch.setattr( + "agent.coding_context.build_coding_workspace_block", + lambda cwd=None: "Workspace (snapshot at session start):\n- Root: /pinned", + ) calls = [] def section(session_info):