Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/axiomcode/skills/axiomcode/scripts/ax_fresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions tests/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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')
Expand Down
Loading