From 2ce35f163e588eab7e31c20d9c6f257141a1bfe5 Mon Sep 17 00:00:00 2001 From: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com> Date: Thu, 27 Aug 2026 01:26:06 -0700 Subject: [PATCH] fix(agents): add idempotency discipline to git-ops (context-truncation thrash) Production eval evidence (5 runs, fast-tier model, enable_long_context=false) showed git-ops re-running `git clone --branch main --single-branch ` up to 8x and `git ls-remote --symref ` up to 7x within a single session (one run: 30 bash calls, only 14 unique). This is the signature of context truncation losing the memory that discovery/setup work already completed, inflating 'fast' sessions to 809-1168s. Adds a compact 'Idempotency Discipline' checklist positioned right after the existing Git Safety Protocol section (near the top of operational guidance, before the command references) so it survives truncation: check disk/remote state before cloning, run remote-discovery commands at most once per remote per session, and treat an about-to-repeat command as a signal to check repo state instead of re-running it. Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com> --- agents/git-ops.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agents/git-ops.md b/agents/git-ops.md index ab529e1a..e564c222 100644 --- a/agents/git-ops.md +++ b/agents/git-ops.md @@ -121,6 +121,16 @@ Good callers will provide semantic context in their delegation message. Use ever - Check authorship before amending - Quote paths with spaces +## Idempotency Discipline + +Disk and repo state are the source of truth — not your memory of what you already ran. + +**Before ANY clone:** check whether the target directory already exists with the right remote (`git -C remote get-url origin`). If it matches, `git -C fetch` instead of re-cloning. Never clone the same URL twice in one session. + +**Remote-discovery commands run at most once per remote per session.** `git ls-remote`, default-branch lookups, and similar discovery calls are one-shot — write the result into your working notes immediately and reuse it. Don't re-derive it. + +**About to repeat a command you believe you already ran? Stop.** Check the filesystem/repo state first. Repeated identical commands are the signature of lost context, not a reason to run them again. + ## Common Git Commands ### Status & Information