From 80fade81124e1ba7def9a3ad82aae092432e83b9 Mon Sep 17 00:00:00 2001 From: swapnil <78632212+swapnilpaliwal-sd@users.noreply.github.com> Date: Fri, 9 Oct 2026 14:17:22 -0700 Subject: [PATCH] refresh: batch every 5 edits, not 3, where a rebuild is slow On a repository whose last rebuild took 20 s or more, edits now count toward a rebuild until the fifth (AXIOMCODE_REFRESH_BATCH default 3 -> 5). Queries still answer from the last good graph meanwhile, marking rows from edited files, and the end of a turn, a prompt, session start, the timer and every query still refresh at once. tests/refresh.py: the slow-repo batch check now makes four edits and a shell command (no rebuild), then the fifth (rebuild). Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com> --- plugins/axiomcode/skills/axiomcode/scripts/ax_fresh.py | 6 +++--- tests/refresh.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/axiomcode/skills/axiomcode/scripts/ax_fresh.py b/plugins/axiomcode/skills/axiomcode/scripts/ax_fresh.py index ffcd4976..e895d32f 100644 --- a/plugins/axiomcode/skills/axiomcode/scripts/ax_fresh.py +++ b/plugins/axiomcode/skills/axiomcode/scripts/ax_fresh.py @@ -35,7 +35,7 @@ Environment: AXIOMCODE_NO_REFRESH=1 turns every trigger off (a query verb's --no-refresh, and the MCP tools' refresh=false, set it for that one query: a read-only answer from the graph as it is, still saying which edits it predates); AXIOMCODE_REFRESH_DEBOUNCE (seconds, default 2) -is the quiet window; AXIOMCODE_REFRESH_BATCH (default 3; 1 = off) is how many edits a rebuild waits for once the last build +is the quiet window; AXIOMCODE_REFRESH_BATCH (default 5; 1 = off) is how many edits a rebuild waits for once the last build took AXIOMCODE_REFRESH_BATCH_ABOVE seconds (default 20); AXIOMCODE_REFRESH_MAX (default 2, 0 = no cap) is how many background rebuilds run at once on the machine, the rest queued; AXIOMCODE_FRESH_WAIT (seconds, default 0) is the most a query whose answer touches an edited file waits for a refresh expected to finish within it, AXIOMCODE_FRESH=1 (--fresh) makes it wait for the refresh whatever it @@ -940,13 +940,13 @@ def running_line(repo, s): return started_line(repo, s, running=True) # a repository whose build takes 5 s that keeps the graph current for free, but where it takes a minute (1,300 Java # files: 48-73 s cold, and 50-88 s again after a one- or two-file edit, since the solve is whole-program) an agent # editing every few seconds kept a rebuild running back to back. So once the last build took AXIOMCODE_REFRESH_BATCH_ABOVE -# seconds (default 20), an edit tool only counts, and the AXIOMCODE_REFRESH_BATCH-th edit (default 3; 1 = off) starts the +# seconds (default 20), an edit tool only counts, and the AXIOMCODE_REFRESH_BATCH-th edit (default 5; 1 = off) starts the # rebuild; a shell command waits for the next edit or checkpoint. The end of a turn, a prompt, a session start, the # timer and every query still refresh at once, so the graph is current whenever the agent stops or asks. EDIT_TOOLS = ('Edit', 'Write', 'MultiEdit', 'NotebookEdit') def batch_size(): - try: return max(1, int(os.environ.get('AXIOMCODE_REFRESH_BATCH') or 3)) + try: return max(1, int(os.environ.get('AXIOMCODE_REFRESH_BATCH') or 5)) except ValueError: return 3 def batching(repo): diff --git a/tests/refresh.py b/tests/refresh.py index 7cc32dcc..2a02b7c6 100644 --- a/tests/refresh.py +++ b/tests/refresh.py @@ -274,8 +274,8 @@ def watch(): check(rebuilds() > n0, f'{lang}: the refresher it started rebuilt the graph') # ── edits batched where a rebuild is slow ─────────────────────────────────────────────────────────── - # BATCH_ABOVE=0 takes this graph's build for a slow one: two edits and a shell command start nothing, the - # third edit does, and the end of a turn rebuilds after a single edit. The control is the check above: the + # BATCH_ABOVE=0 takes this graph's build for a slow one: four edits and a shell command start nothing, the + # fifth edit does, and the end of a turn rebuilds after a single edit. The control is the check above: the # same hook on the same graph with the default threshold rebuilt after one edit slow = dict(env, AXIOMCODE_REFRESH_BATCH_ABOVE='0') def hook(event, tool=None): @@ -288,12 +288,12 @@ def settle(n, secs): # the rebuild count on time.sleep(0.2) return rebuilds() n0 = rebuilds() - for _ in range(2): + for _ in range(4): open(f, 'a').write('\n'); hook('PostToolUse', 'Edit') hook('PostToolUse', 'Bash') - check(settle(n0, 4) == n0, f'{lang}: where a rebuild is slow, two edits and a shell command start no rebuild') + check(settle(n0, 4) == n0, f'{lang}: where a rebuild is slow, four edits and a shell command start no rebuild') open(f, 'a').write('\n'); hook('PostToolUse', 'Edit') - check(settle(n0, 600) > n0, f'{lang}: the third edit starts it') + check(settle(n0, 600) > n0, f'{lang}: the fifth edit starts it') n0 = rebuilds() open(f, 'a').write('\n'); hook('PostToolUse', 'Edit') check(settle(n0, 4) == n0, f'{lang}: the batch starts over after that rebuild')