- Python 100%
traj-trees #
A small play experiment: parse coding-agent trajectories into trees with a rule-based shift-reduce pass, and see what the trees say. The motivating idea is treating a trajectory as a stream that "context holons" parse into a tree, so that subtrees can be collapsed instead of summarized.
Data: shard 0 of nebius/SWE-agent-trajectories
(6,670 SWE-agent runs, mostly a Llama-70B agent; 19% resolved). Not vendored. Fetch it with
curl -L -o shard0.parquet https://huggingface.co/datasets/nebius/SWE-agent-trajectories/resolve/main/data/train-00000-of-00012.parquet.
python3 parse.py shard0.parquet # -> trees.csv (5 s)
python3 show.py shard0.parquet <instance_id>
python3 straddle.py shard0.parquet
The tree #
Task > Phase* > Step* Step = thought (speech) + action + observation
Phase ∈ reproduce | locate | edit | verify | fix-loop(edit/verify xN) | cleanup | submit | talk
Shift: each step is labelled by its command (search_dir/open/goto → locate,
edit → edit, or reproduce if the open file is reproduce.py, rm → cleanup, and so on).
A generic run becomes reproduce before the first edit and verify after it.
Reduce: runs of the same label become a phase, and two or more edit verify rounds become a fix-loop.
The rule-based classifier is a stand-in. The point is to later swap in a small model
choosing among option labels, and compare it against these rules.
Example (networkx__networkx-7024, resolved): RLEVCS
reproduce (5) create reproduce.py / edit / python reproduce.py / ...
locate (2) search_dir "def is_k_edge_connected" / open ...
edit (1)
verify (1) python reproduce.py
cleanup (1) rm reproduce.py
submit (1)
Findings #
1. Collapsing non-speech saves most of the context. If each observation is replaced by a stub and only the thought plus the first line of each command is kept, 18% of the characters remain. Keeping one gist utterance per phase leaves 7%. Observations are about 82% of a trajectory.
2. A handful of shapes cover half the runs, and the shape predicts the outcome. There are 1,535 distinct phase signatures (F = fix-loop), and the top 15 cover 51% of runs.
| shape | n | resolved | median steps |
|---|---|---|---|
| RLEVCS | 832 | 0.43 | 12 |
| LES | 759 | 0.17 | 7 |
| LEVCS | 273 | 0.33 | 10 |
| RLFCS | 244 | 0.53 | 14 |
| LFCS | 209 | 0.38 | 16 |
| RL | 159 | 0.00 | 37 |
| LELES | 156 | 0.14 | 11 |
| LE | 131 | 0.00 | 27 |
| R | 120 | 0.01 | 52 |
| RLFE | 103 | 0.04 | 36 |
(overall resolved rate: 0.19; runs ending in S: 0.26, runs that don't: 0.03)
RLEVCS is exactly the walkthrough in SWE-agent's demonstration prompt, so the most
common "grammar" is the prompt's. Runs that edit and submit without running anything
(LES) resolve at 17%. Runs that reproduce and then iterate (RLFCS) resolve at 53%.
This is correlation only: easy issues may simply invite reproduction.
3. The natural boundaries fall inside the agent's utterances. 88% of thoughts
open by interpreting the previous observation ("The output is True, which confirms
the issue…") before planning the next action. At phase boundaries that rises to 93%.
A turn-aligned tree therefore files each interpretation under the wrong parent:
the sentence that closes the reproduce phase sits in the first step of the locate phase.
A better leaf is observation → interpretation, with the split made mid-utterance.
That makes segmentation a sentence-level job rather than a turn-level one.
(The look-back test is a crude first-sentence regex.)
Next #
- Split utterances into look-back and plan halves, and re-attach the look-back half to the previous step
- Swap the rule classifier for a small local model choosing among phase labels, and measure agreement
- Try OpenHands trajectories (different action vocabulary, no demo-shaped grammar)
Follow-up (2026-10-16): is the look-back habit about agents, or about SWE-agent? #
Question from the first pass: 88% of SWE-agent utterances open by interpreting the previous observation. Is that a property of coding agents, or of SWE-agent's prompt (which demands a DISCUSSION before every command)? Data: shards 0–1 of SWE-Gym/OpenHands-Sampled-Trajectories (4,037 OpenHands runs, function-calling; mostly GPT-4o, plus 229 Claude 3.5 Sonnet runs).
python3 lookback.py # regex rate + 40-utterance samples -> sample.json
python3 oh_boundary.py oh0.parquet,oh1.parquet gpt-4o
python3 oh_boundary.py oh0.parquet,oh1.parquet claude
oh_boundary.py labels each OpenHands step from its tool call with the same phase
vocabulary as parse.py (view → locate, str_replace/create → edit or reproduce,
execute_bash → run → reproduce/verify, finish → submit).
| corpus | turns with any speech | spoken turns opening with a look-back (regex) | hand-labelled sample (n=30–40) |
|---|---|---|---|
| SWE-agent (Llama-70B-ish, nebius) | 100% (format requires it) | 88% | 80% |
| OpenHands, GPT-4o | 46% | 89% | ~85% |
| OpenHands, Claude 3.5 Sonnet | 92% | 15–28% | 27% |
Findings:
- It depends on the model's style, not just the scaffold. GPT-4o under OpenHands (no DISCUSSION requirement) looks back just as much as SWE-agent's model when it speaks. Claude 3.5 Sonnet nearly always speaks, but narrates forward: "Let's look at the visit_tuple_type method:", "Now let's run the script again:". The reaction to the last observation is mostly implicit in the choice of the next action. So a segmenter can't assume either convention. For look-back speakers the utterance's first half belongs to the previous step. For forward narrators, speech + action + observation is already a clean leaf.
- Silence is the other boundary signal. GPT-4o is silent in 65% of within-phase steps
(chains of
viewcalls) but speaks at 61% of phase boundaries. As a boundary detector, "the agent said something" gets precision 59% and recall 61% against a 45% base rate. That's weak but real. For Claude 3.5 it's useless (speaks 94% at boundaries, 90% within). - Surprise / dataset quirk: 1,776 of 3,808 GPT-4o runs (47%) are degenerate loops, with one identical tool call (usually viewing the repo root) making up at least half of all calls. 0 of 229 Claude runs are. These are filtered out of the numbers above. They're the cheapest possible collapse target: a loop subtree is "same call ×N".
Caveat: the look-back regex is crude (it misses "I've examined…", "Due to…", "I apologize for the error…"), so the hand-labelled column is the one to trust. Its samples are small.
Follow-up 2 (2026-10-16 afternoon): an agent that labels its own phases #
Data: row groups 0 and 9 (8,192 runs, 48% resolved) of
nebius/SWE-rebench-openhands-trajectories
(Qwen3-Coder-480B under OpenHands 0.54; read by HTTP range requests with
pyarrow + fsspec, ~270 MB per row group, a few seconds each). This newer OpenHands task
prompt lists eight phases (READING, RUNNING, EXPLORATION, TEST CREATION, FIX ANALYSIS,
FIX IMPLEMENTATION, VERIFICATION, FINAL REVIEW), and the model writes a ## Phase N. header
as it enters each one. That's a free, self-reported segmentation to test the
tool-call segmenter against.
python3 declared.py data/rb0.parquet,data/rb9.parquet
python3 declared_extra.py data/rb0.parquet,data/rb9.parquet
Findings:
- The story it tells about itself is the prompt. 100% of runs declare phases, and
all but 11 declare them in strictly increasing order. 68% declare exactly
12345678, another 24% skip only FIX ANALYSIS (1234678), and there are 24 distinct declared sequences in all. The tool-derived shapes of the same runs (parse.py's reducer) come to 3,880 distinct shapes in 4,096 runs (median length 19). The declared tree is a narrative laid over the activity, not a description of it. - The fix loop hides inside "VERIFICATION". 22% of steps in declared VERIFICATION are edits. 88% of runs do at least two edit→verify rounds after declaring VERIFICATION, never going back to declare FIX IMPLEMENTATION. Runs with no such rounds resolve only 12% of the time (they're mostly abandoned or stuck runs); 2–3 rounds resolve 53%, 4+ resolve 47%.
- Declared boundaries nest inside tool boundaries. 87% of declared phase boundaries coincide with a change of tool label, but only 20% of tool-label changes are declared boundaries (base rate 10.5%). So the declared phases are a coarser level over the tool-derived ones and could sit above them in the tree. That works for 87% of boundaries, which is about the most one could hope for from a regex labeller.
- The model's own boundaries fall mid-utterance. 75% of utterances that carry a phase header have text before the header. Hand-labelling 30 of them: 21 are the ending phase's reaction or summary ("Perfect! I've successfully reproduced the error. ... ## Phase 5."), 7 are the opening "I'll help you..." preamble (task root), and 2 are forward plans. This is the first pass's "the natural leaf is observation → interpretation" claim, now checked against the agent's own labels: even an agent told to mark its phases puts the marker after it has finished reacting to the last observation.
- Look-back is a continuum across models. Qwen3-Coder speaks on 71% of non-first steps. The regex says 14% of those look back, but a hand-labelled sample of 32 gives ~45% (it opens with "Perfect!"/"Excellent!" plus a reading of the output, then plans forward). Compare SWE-agent ~80%, GPT-4o ~85%, Claude 3.5 Sonnet ~27%. The regex is now off by 3× in one direction or the other on every corpus, so a classifier (the jev-like?) is overdue for this.
Labeller bug fixed in this pass: OpenHands commands usually start with
cd /workspace/repo && ..., and oh_boundary.py labelled them by their first word
(cd → locate), so test runs counted as locating. oh_boundary_labels.py now
skips cd/export/source segments (and counts git as locate). On the SWE-Gym data
this relabels about 1,300 of 30k calls from locate to run, but the morning's headline
numbers held to the percent (GPT-4o speech-as-boundary P 59% / R 61%; Claude 94% vs 90%).
On SWE-rebench almost every command is cd-prefixed, so it mattered a lot there.
Next: a jev-like (or small-model) classifier for "does this sentence interpret the last observation?", run as a sentence splitter; and a tree builder that puts declared phases above tool phases and attaches pre-header text to the ending phase.
Follow-up 3 (2026-10-17): a second instrument for look-back #
The look-back regex had disagreed with my hand labels on every corpus, so this pass made the hand labels a file and pointed two more instruments at them.
python3 lb_sample.py 17 40 lb_items.json # 40 first sentences per corpus (+ obs tail)
python3 lb_sample.py 18 25 lb_heldout.json # held-out draw
python3 lb_classify.py Qwen/Qwen2.5-1.5B-Instruct {zero|few} > res.json # ITEMS=... for another set
python3 lb_score.py res.json
Unit: the first sentence of every non-first agent turn that has any text. Labels
(lb_items.json, lb_heldout.json, all by hand): LB = reacts to or interprets what
just happened, ACK = a bare reaction with no content ("Perfect!", "Great!", "I
apologize for the error."), F = announces the next action, X = neither (phase
headers, restating the task). ACK counts as look-back when scoring.
| corpus | hand LB+ACK (n=40) | regex v1 | v1 acc | held-out hand (n≈25) | v1 acc | v2 acc |
|---|---|---|---|---|---|---|
| SWE-agent | 82% | 82% | 100% | 96% | 100% | 100% |
| OpenHands GPT-4o | 92% | 90% | 98% | 92% | 96% | 96% |
| OpenHands Claude 3.5 Sonnet | 48% (12% bare ACK) | 22% | 75% | 52% | 88% | 88% |
| SWE-rebench Qwen3-Coder | 50% (42% bare ACK) | 16% | 66% | 57% | 65% | 87% |
Findings:
-
On first sentences, the old regex was right where I'd said it was wrong. It agrees with my labels on 100% of SWE-agent and 98% of GPT-4o first sentences. Earlier passes reported "regex 88% vs hand 80%" and "off by 3×", but those hand labels judged the whole utterance by a vaguer standard ("does it contain a reading of the output?"), so the two instruments were measuring different things. The disagreement was in the definition, not the instrument. Writing the labels down with a stated unit is what exposed that.
-
Where the regex really fails is bare acknowledgements. Qwen3-Coder opens 42% of its turns with a content-free "Perfect!"/"Excellent!"/"Great!", and v1 only knew "Great". Claude does it less (12%). Counting acks as look-back, Claude and Qwen are both about half look-back on first sentences, but almost all of Qwen's is the bare ack (8% substantive), so the reading it does comes in sentence two. That's why yesterday's whole-utterance number for Qwen (~45%) and today's substantive first-sentence number (8%) are both "right".
-
A regex I patched by looking at the data overfits, predictably. v2 adds the openers I saw (Perfect, Excellent, "We're still", "I apologize", ...): 99% on the items it was written from, 93% held out. It misses the next interjections in the tail ("Good!", "That's very strange.", "Oops", "Still getting
BYE.", "Based on ..."). -
The 1.5B jev-like ranks well but is badly calibrated, and few-shot fixes most of it. Option-letter logits, both orders averaged:
Qwen2.5-1.5B-Instruct acc @0.5 AUC order flips zero-shot 68% (= says LB to everything) 0.79 34% 6 unlike examples 84% 0.95 22% (regex v1: 85%, v2: 99% on the same items, but v2 was fitted to them.) On the held-out draw the few-shot 1.5B gets 85% at 0.5 and AUC 0.96 (v1 88%, v2 93%), so its numbers hold up out of sample; the regexes still win on accuracy. Few-shot error analysis: almost every miss is a "Let me X:" sentence called look-back, with the two option orders disagreeing (A-position bias of 0.8–0.9 vs 0.2–0.4). My examples contained "Let's ..." and "Next, I'll ..." but no "Let me", the most common forward opener in Claude and Qwen. That's the one-example-defines-the-category lesson from jev-like/anchoring.py again: the classifier learns the surface of the examples it's shown.
-
Practical: 3B in bf16 thrashed this 8 GB / 2-core sandbox (39M major page faults, killed after an hour); 1.5B bf16 costs ~3.7 s per 40-token forward even with the shared prompt prefix KV-cached (
lb_classify.pydoes this), and fp32 1.5B gets OOM-killed. So the jev-like is ~15 min per 160 items × 2 orders here.
Takeaway for the segmenter: a regex is a fine first-sentence look-back detector for models that open with a reading (SWE-agent, GPT-4o). For ack-first speakers (Qwen, Claude) the unit needs to be "first sentence with content", or the ack has to count as its own look-back leaf. The jev-like is worth keeping as the second instrument that flags where a regex has gone stale, not as a replacement for it.
Follow-up 4 (2026-10-17 afternoon): a three-level tree, and collapse without a summarizer #
tree.py builds Task > DeclaredPhase > ToolPhase > Leaf for the SWE-rebench Qwen3-Coder
runs (row group 0, 4,096 runs), using the two placement rules from earlier passes: text
before a ## Phase N header is the ending phase's closing reaction, and a turn's
opening look-back sentences (regex v2, acks included) attach to the previous leaf. Then it
asks the Holanarchy question directly: how small does the context get if each finished
subtree is collapsed to words the agent itself already wrote, with no summarizer?
python3 tree.py data/rb0.parquet # closing-reaction stats -> closing_sample.json
python3 tree.py --running data/rb0.parquet # mean context size over every step
python3 tree.py data/rb0.parquet <instance_id> # render one tree
Mean context size over all 263k steps (as seen just before each action), as a share of the full transcript so far:
| policy | aggregate | median run |
|---|---|---|
| drop every observation but the latest | 13.9% | 13.8% |
| finished declared phases → stub + closing reaction (current phase in full) | 24.0% | 22.2% |
| ...+ one action stub line per step of each finished phase | 25.8% | 24.1% |
| ...and keep only the last 3 observations in the current phase | 12.8% | 13.2% |
| ...and keep only the latest observation | 8.9% | 8.8% |
Findings:
- Observations come first, the tree second. On its own, collapsing finished phases does worse than the dumb policy of dropping old tool output, because the current phase is often long (VERIFICATION averages dozens of steps) and its observations dominate. Once observations are gone, though, 8.6 of the remaining 13.9 points are plans and actions from finished phases, and collapsing those to closing reaction + one action stub per step cuts the context by another third (13.9% → 8.9%). So a tree buys about a 1.6× saving over observation-dropping, not the 5× the observation drop gives. Both are free in the sense that matters here: nothing is generated, every surviving character was written by the agent or its tools.
- 71% of finished phases end with a closing reaction, and it's small. Median 211 characters against a median phase body of 12k (1.6%).
- About two thirds of closing reactions are usable gists, and which ones depends on the
prompt. Hand-labelled 30 (
closing_sample.json): 19 good (says what the phase established: "I've reproduced the issue: with middleware, the mounted app's exception becomes a 500..."), 7 partial ("Great! The tests are running successfully."), 4 empty ("Perfect!", "Perfect! 🎉"). Phases 1 (READING) and 5 (FIX ANALYSIS) were 11/11 good, because the task prompt asks for a written analysis there, and the model writes it as one long utterance just before the next header, so the "closing" is the phase's content. RUN-TESTS and VERIFY closings are mostly partial or empty. Those are exactly the phases whose result lives in an observation (a test summary), so for them the collapse target should be the tail of the last observation, not the agent's words. - Small thing seen while rendering: some closings are forward plans ("Now let me look at the main date_time provider implementation:") written just before the header, meaning the model announced the next action, then remembered to declare the phase. Pre-header text isn't always look-back, so a classifier is still needed on it.
Next: for observation-result phases (run-tests, verify), use the last observation's tail
(pytest's summary line) as the gist and re-measure; a jev-like pass over closings to grade
gist / partial / empty, scored against closing_sample.json.
Follow-up 5 (2026-10-24 early morning): run phases collapse to the tool's tail, not the agent's words #
Follow-up 4 ended with RUN-TESTS and VERIFY closings that say "Great! The tests are
running successfully." and nothing else. gist_tail.py takes the last executed step of
each finished declared phase and pulls a result line out of its observation, with no model:
drop OpenHands' trailer lines (keeping the exit code), collapse pytest's terminal-width
===== rules (the summary sits in the middle of a 400-column rule, so a naive
last-N-characters tail is pure =), then take the last pytest / unittest / exception
summary line, else the last two non-empty lines.
python3 gist_tail.py data/rb0.parquet # table below, tail_sample.json, overclaim_sample.json
Row group 0 (4,096 runs), finished declared phases:
| phase ended | n | last step executed something | structured result line | piped through head/grep | gist chars | obs chars | closing states a count |
|---|---|---|---|---|---|---|---|
| 2 run-tests | 4098 | 99% | 58% (49% pytest) | 16% | 67 | 10,560 | 0% |
| 7 verify | 3802 | 100% | 39% (34% pytest) | 2% | 76 | 4,935 | 3% |
Findings:
- The tool's tail is the better gist for run phases, at a third of the closing's size.
Hand-labelled 40 run-tests/verify phases (
tail_sample.json, fieldhand): 28 good ("=== 1 failed, 5 passed, 12 warnings in 6.49s ===", "FAILED (failures=2)"), 3 partial, 9 weak. The weak ones are 4 runs piped through| head -20(the summary is cut off by the agent's own command), 4 smoke checks whose whole output is "X imported successfully", and 1 tool whose exit code is its result (pyupgrade exits 1 when it rewrote a file). Closings almost never carry the number (0–3% mention a count). - In VERIFY, the tail is often the agent's own voice anyway. 61% of final verify runs end without a test-runner summary, mostly ad-hoc scripts whose last lines are verdicts the agent wrote into the script ("🎉 ALL EDGE CASE TESTS HANDLED CORRECTLY!"). So "result in an observation" is only half true there: the observation is agent speech with a delay, and it is as self-congratulatory as the closing.
- Closings rarely contradict the last run, but when they do, closing-only collapse hides
it. A crude detector (closing claims success, no hedge words; tail shows failures or a
non-zero exit) flags 2% of run-tests and 3% of verify success claims. Of 30 flagged
phases checked by hand (
overclaim_sample.json), 6 are real: "the environment is working" overno tests ran ... file not foundor an MPI abort, "the timeout suggests it's working", a fix declared done while its last check died with a TypeError. The rest were honest (non-zero exit is the tool's normal answer, interrupted runs, failures the closing acknowledges). The detector also misses some: "Both integration tests pass" overFAILED (failures=2)was in the random sample, not the flagged one. So roughly one success claim in a hundred is contradicted by the phase's own last output. - Exit codes agree with pytest's summary 99% of the time (23 of 2,868 all-passed summaries came with a non-zero exit, likely plugins such as coverage thresholds), so the exit code is a cheap second witness, not a replacement for the line.
Takeaway for the collapse policy: keep both the closing and the tool's result line for any
finished phase that ended by running something. It costs ~70 characters, and it makes the
agent's self-report checkable against a line it didn't write, the same way the
backlinks-source monitor's polls counter makes "I saw nothing" checkable. A tree node
that collapses a subtree should carry a mechanical witness next to the words.
Follow-up 6 (2026-10-24 afternoon): whose voice is the witness? #
Follow-up 5 ended by proposing a mechanical witness line next to every closing. But in VERIFY
the last run is usually a script the agent wrote, printing verdicts the agent wrote. So two
model-free checks on each witness line, and then the one piece of ground truth the dataset
gives for free (resolved: did the hidden tests pass).
provenance.py cuts the witness line into literal fragments (at numbers, quoted values,
paths, the | that joins two tail lines) and calls it authored when at least half its
characters are fragments found verbatim in text the agent wrote earlier in the run (commands,
created files, edits). pytest / unittest summaries are the control group.
python3 provenance.py data/rb0.parquet data/rb4.parquet # row group 4 fetched fresh as a holdout
| phase ended | witness kind | n (rg 0) | authored rg 0 | authored rg 4 |
|---|---|---|---|---|
| run-tests | pytest / unittest | 2199 | 0% | 0% |
| run-tests | raw (other output) | 1726 | 39% | 40% |
| verify | pytest / unittest | 1377 | 1% | 1% |
| verify | raw | 2323 | 66% | 64% |
Each run's final executed step vs resolved (both row groups, 8,192 runs, base 48%):
| final witness says | n | resolved |
|---|---|---|
| pytest summary, all passed | 3,589 | 53% (rest 45%) |
| agent-authored line, "pass" | 1,943 | 49% (rest 48%) |
| of those, from a script that has no failure branch at all | 429 | 45% |
| anything saying fail | 518 | 40% |
| run ended on an executed step (no closing turn) | 367 | 20% |
Findings:
- Provenance is mechanically checkable. The control group behaves (pytest/unittest lines
0–1% authored), the VERIFY raw share (65%) matches follow-up 5's hand estimate (61%), and
30/30 spot-checked authored lines are agent verdicts except 3
pytest --versionlines (the fragment "pytest " is in the command). It under-counts f-strings with quoted values, so 65% is a floor. My first version said 5%: two tail lines joined by|made every fragment span a line break. The control group would not have caught that; the cross-check with yesterday's hand count did. - An authored "pass" carries no information about the task (49.4% vs 48.1%). A pytest pass carries a little (+7.5 points). Witnesses certify the agent's own picture of the task, not the hidden tests. Failures are more informative than passes, and the strongest single signal here is structural: runs that stop on an executed step without a closing turn resolve 20%.
- 11% of authored VERIFY "pass" lines come from documents with no failure branch at all
(no FAIL / ❌ / False / assert / raise / exit 1 anywhere in the script): the only way
they could have testified otherwise is by crashing. In RUN-TESTS it's 97%, nearly all
print('Import successful')-style smoke checks, where the crash is the test.
Takeaway for the collapse policy: the witness line needs a provenance tag. A tool line (pytest, exit code, traceback) is a second voice; an authored line is the closing again with a delay, and should be collapsed with the speech, not trusted as evidence. Neither kind is evidence about whether the work is right, only about whether the summary is faithful to what happened, which is the job a collapsed subtree has.
Follow-up 7 (2026-10-25 afternoon): the witness inside the collapse, and a veto reflex #
Follow-ups 5 and 6 proposed a policy without measuring it: a finished phase that ended by
running something collapses to stub + closing + one action stub per step + a witness
line (the last run's result line), tagged with its provenance. witness.py re-runs the
running-context measurement from follow-up 4 with that witness in place, and adds one
reflex on top:
veto: if the closing claims success and the witness says fail, don't collapse that phase (keep its plans, actions and reactions; observations are still dropped).
The point of trying a veto rather than an alarm is that its action is conservative: a false fire costs a few kilobytes of context, not a wrong decision.
python3 witness.py data/rb0.parquet # v2 verdicts -> veto_sample.json
python3 witness.py --v1 data/rb0.parquet # follow-up 6's verdict regex -> veto_sample_v1.json
python3 witness.py data/rb4.parquet # holdout row group
Mean context over every step (rg 0: 263k steps of 4,096 runs; rg 4 holdout in brackets):
| policy | aggregate | median run |
|---|---|---|
| C0: old headline (collapse + latest observation only) | 8.87% [8.91%] | 8.77% |
| W: + tagged witness per finished run-tests / verify phase | 8.95% [9.00%] | 8.86% |
Wt: witness kept only when its provenance is tool |
8.94% [8.98%] | 8.85% |
| V: W + veto on closing / tool-witness contradiction | 8.96% [9.01%] | 8.87% |
Findings:
- The witness is nearly free. 7,868 witnessed phases, mean 84 characters with tag, +0.08 points of context. Dropping authored witnesses (follow-up 6's suggestion) saves only 0.01 points, so the argument for dropping them is about what they mean, not size.
- The veto fires on ~1% of witnessed phases (2% of runs) and costs another 0.01 points (median 0.5k chars to keep a run-tests phase open, 3k for verify).
- But its precision is poor, ~15–20%. Hand-labelled 30 fires per verdict version
(
handfield): v1 4 real / 3 ambiguous / 17 false alarms / 6 honest; v2 4 / 3 / 12 / 11. The real ones are the follow-up 5 kind: "the configuration is correct" overModuleNotFoundError, "the environment works" over a^C ... ERROR, a "final comprehensive test" announced right after0/2 tests passed. "Honest" means the closing already acknowledges the failure in words my claim regex doesn't parse ("That's fine, Django tests need proper setup"). - The false alarms have three shapes, and only one is a regex problem. (a) Expected- failure checks ("correctly failed", "Exception caught:"), patched in v2. (b) Test ids containing "fail" and exit codes non-zero over an all-passed summary, patched in v2. (c) Tools whose output is their result: linters, formatters, vulnerability scanners, pyupgrade, where exit 1 / a list of findings means "it worked". That one needs to know the command's convention, which is per-tool knowledge, a lookup table or a jev-like question ("did this tool run succeed by its own conventions?"), not a better regex.
- The veto says nothing about
resolved(rg 0: 50% of runs with a tool veto vs 48.5% base; rg 4: 39% vs 48%, n=67, so noise in both directions). Same lesson as follow-up 6: these checks are about whether the summary is faithful, not whether the work is right.
Takeaway: a reflex can be sloppy when its action is cheap and safe. At ~1% firing and a few kilobytes per fire, a 15%-precision veto that only declines to forget costs less than one missed "environment works" over a crash. The same detector as an alarm (wake a human, or the agent) would be noise. So precision requirements belong to the reflex's action, not to its detector, and when a detector is weak the action should be the kind that only keeps more evidence.
Follow-up 8 (2026-10-26 early morning): a jev-like as the witness judge #
Follow-up 7 left the veto's false alarms as a convention question ("did this tool succeed
by its own conventions?"), so this pass asks a small model. judge_extract.py re-reads
row groups 0 and 4 and recovers the command and last 25 output lines behind each
hand-labelled veto candidate (48 unique items across the two samples: 5 real,
14 honest, 24 false alarms, 5 ambiguous). judge.py asks Qwen2.5 Instruct (1.5B and 3B,
bf16 on CPU, digit-softmax expected value 0–9, six synthetic few-shot examples written for
this script, two example orders, prefix KV cache) one of two questions:
- tool: by this command's own conventions, did the run fail? (closing not shown)
- veto: does the output contradict what the agent's closing claims?
python3 fetch_rg.py 0 4 # HTTP range read -> data/rb{0,4}.parquet
python3 judge_extract.py data/rb0.parquet data/rb4.parquet # -> judge_items.json
python3 judge.py <Qwen2.5-3B-Instruct dir> tool veto # -> judge_q3b_{tool,veto}.json
python3 judge_score.py judge_q*.json
| AUC | fires at 4.5 (of 43 non-ambiguous) | real kept | precision | |
|---|---|---|---|---|
| regex alone (every item here fired) | – | 43 | 5/5 | 12% |
| 1.5B veto | 0.76 | 17 | 4/5 | 24% |
| 3B tool | 0.69 | 26 | 5/5 | 19% |
| 3B veto | 0.72 | 21 | 5/5 | 24% |
(AUC is real vs everything else; 5 positives, so every number here is soft.)
- As a second stage behind the regex, 3B halves the fires and keeps every real one. At the pre-chosen midpoint it clears 17/24 false alarms and 10/14 honest closings. It runs only where the regex fired (~1% of witnessed phases) at ~4 s a call on two CPU cores, so the cascade is cheap. Order sensitivity is small (mean |Δ| 0.4–0.8, 1–4 side flips of 48); 3B is bimodal (mostly 0.0 or 9.0), as before.
- The convention question is the wrong question. Asked "did this tool fail?" without the closing, 3B calls every linter, formatter, scanner and pyupgrade run a failure (9.0), exactly the false alarms it was meant to fix. With the closing, some of those clear. "Did a linter fail?" has no answer apart from what the agent was trying to do; the contradiction question carries that intent along.
- What survives is token-level. The seven false alarms still at 7–9 under 3B veto are
629 passedwith a non-zero exit, a deliberately failing doctest fixture, the scanner table, two linters and a formatter: the model reacts to "FAIL"/"error"/exit codes, not to the tool's convention. 1.5B misses one real case (aTypeErrorprinted through a logger with exit 0). - "Honest" is the hard class, for me as well as the model. "Good, there are passing
tests. Now let's move to exploration" over
3 failed, 28 passedis labelled real; "Good! Most tests pass. Now let's move to Phase 3" overFAILED (failures=1, errors=3)is honest. The difference is the one word "most", and the model scores both high. Most honest items are RUNNING-phase environment checks, where the failures are a baseline the agent didn't cause.
Takeaway: a 3B jev-like works as a filter, not as an oracle. It takes the veto from ~12% to ~24% precision without losing a real contradiction, which is enough for an action that only declines to forget. Per-tool convention knowledge didn't appear at this size. The cheaper way to get it is a lookup by command name (linters/formatters/scanners: findings are results), with the jev-like asked only the contradiction question.
Follow-up 9 (2026-10-29 afternoon): is a "good" closing fair to its phase? #
The collapse keeps a finished phase's closing reaction in place of the phase. Follow-up 4 graded closings on form (gist / partial / empty). This one asks about fidelity: do the closing's claims follow from what the phase's tools actually showed? It's the same question as the one a condensed log leaves open, since a summary is a fresh authored claim and nothing checks that it's fair to what it replaced.
python3 fid/dump.py && python3 fid/ground.py # where each closing's specifics come from
python3 fid/score.py # labels + lexical overreach flag (tuning set)
python3 fid/heldout.py # 20 fresh closings from phases that ran something
Hand labels over the 30 closings in closing_sample.json (fid/labels.json) plus a
held-out 20 (fid/heldout_labels.json). S = the claims follow from this phase's
observations; O = overreach, meaning a qualifier or explanation the evidence doesn't
reach; C = contradicted; R = restates the task (one-step analysis phases); N = no claim.
| sample | S | O | C | R | N | ? |
|---|---|---|---|---|---|---|
| closing_sample (30) | 11 | 4 | 0 | 11 | 4 | – |
| held-out (20) | 10 | 5 | 0 | – | 2 | 3 |
Findings:
- The nouns are fine. 156 checkable specifics (backticked names, quoted strings, numbers, dotted identifiers) in the 19 "good" closings: 97% appear verbatim or piecewise somewhere in the run. Only 16% come from this phase's tool output, though; 31% are the agent's own words from inside the phase and 50% come from the task or earlier phases. So a grounding check on specifics passes almost everything and catches nothing.
- About a third of the closings that claim something about their own evidence
overreach (9 of 30), and none contradict it. The failure is never a wrong fact.
It's an extra word: "one unrelated test failure" (never opened, twice), "this
confirms the root cause" (the run showed nondeterminism, not its cause), "the gap in
positions is expected" (explaining away a
?its own test printed), "tests stop at 12.0, which confirms 13.1 support is missing", "completely resolved" from one printed dict, "As expected, the test fails ... this confirms my changes work", and "I know exactly where the bug is" right after failing to reproduce it. - Overreach comes from a small vocabulary, but which vocabulary shifts between samples. A word flag tuned on the first 30 (unrelated / expected / root cause / because / means / due to) got 4/4 there and 0 false alarms once "should" was dropped, since "should" marks forward plans. Held out, it caught 2 of 5 at 2/3 precision. Adding certainty words (completely / exactly / confirms that / indeed) after seeing the held-out set catches 5/5 at 5/8, but that isn't held out any more. It's a cheap pre-filter for a judge, not a judge.
- 11 of the 19 "good" closings in the original sample are phase 1/5 problem statements. Their fidelity is to the task prompt, not to any work, so "good gist" mostly measured "restated the issue well".
So what: to make a collapsed closing safe to keep, check its verdict words, not its nouns. Keep the specifics, keep the tool witness line from follow-up 7 for the facts, and treat explanatory and certainty qualifiers ("unrelated", "expected", "confirms", "completely") as authored claims that need a witness or get dropped. A summarizer of a log has the same problem: what goes wrong is the adjective, not the noun.
Follow-up 10 (2026-10-30 early morning): the implicit /sense questions agents already ask #
Holanarchy's /sense idea gives the top-level agent a generic "ask a plain question" tool
and logs every question, so the log can decide which questions should become automatic
senses (standing holons). Before any /sense exists, agents already ask such questions
whenever they probe without acting: search, open, ls, rerun the reproducer, run the tests.
sense.py mines those probes from shard 0 (6,669 SWE-agent runs, mostly one Llama-70B agent).
sense_more.py handles the follow-ups.
Each probe gets an intent (where-symbol, where-file, read-file, repro, tests, run)
and its literal question (command plus scope). When the same question is asked again, the
repeat is labelled by two facts: did an act (edit/create/rm) happen in between, and did the
answer change? (Bash's line N: counter is normalized out, since it made a broken command
look like nondeterminism.)
| repeat | act between? | answer changed? | reads as |
|---|---|---|---|
| monitor | yes | yes | tracking state: a reflex candidate |
| unaffected | yes | no | the act didn't move it (for the reproducer, "my fix did nothing") |
| reask | no | no | already known |
| drift | no | yes | nondeterminism / outside state (2%, once normalized) |
python3 sense.py shard0.parquet # 7 s
python3 sense_more.py shard0.parquet
1. Re-asks are loops, not forgetting. 97% of all same-question/same-answer re-asks
sit in the 8% of runs with three or more of them. Those runs resolve 3% of the time
(21% for runs with none) and have a median of 51 steps (14 for runs with none).
A "you already asked this and nothing changed" sense would fire on them at a median of
25% of the way into the run. It needs no model: it reads the /sense log itself.
That gives a clean answer to "should this question become automatic, or is it asked
often because something keeps breaking?" Look at the repeat signature, not the
frequency. Monitor repeats (an act came between, and the answer moved) are what to
automate. Reask repeats point at a stuck agent, and the right response is to escalate,
not to grow a holon.
2. In healthy runs, the senses worth automating are the act-triggered execution questions. Leaving out the looping runs, 61% of probes are asked only once. The "where" and "read" questions get asked once 78–92% of the time. They are parametric, so they are tools, not senses. Repeats belong almost entirely to running things: reproducer probes are 47% monitor and 29% unaffected, and tests are 45% monitor. A standing reflex of "rerun the reproducer after each burst of edits" would have been consulted before the agent's next edit 92% of the time, and it would have pre-empted 92% of the agent's own reruns.
3. A heavy head and a long tail. Two literal questions, python reproduce.py and
ls -F, are each asked in at least 20% of runs and make up 14% of all probe calls.
Only 14 literal questions reach 1% of runs. Meanwhile 39% of probe calls are literal
questions that occur in just one run. A promotion process would see a few constant
questions that get promoted almost immediately, then a tail it should leave alone.
4. A third of runs rephrase. 34% of runs follow a failed search (No matches,
Usage:, not found) with the same intent in new words. That is the asking failing
while the question stays fine. Absorbing it is exactly the job of a /sense subagent
that sits between a plain-language question and query syntax. It also means the log
should group by intent, not by literal text, or one question will look like five.
Caveats: one agent scaffold and mostly one model. "Act" means an edit-like command, so a probe that writes files (a reproducer that creates output) counts as read-only. The reflex precision assumes the agent would want the result at the moment it fires.
Follow-up 11 (2026-10-30 afternoon): a toy /sense log that promotes and escalates #
Follow-up 10 labelled repeats after the fact. sense_log.py replays the 6,669 runs in
order, the way a /sense log would see them, and lets two rules act as it goes:
- promote: a question becomes a standing sense. It is re-evaluated after every burst of acts and its answer is placed in context.
- escalate: at the Nth reask (same question, nothing done in between, same answer), hand the run up.
The cross-run log keeps repeat signatures per template (a question with paths, strings
and numbers abstracted away; every reproducer is repro|<script>). It learns only from runs
earlier in the replay, and scoring uses the second half (3,335 runs). Promotion policies:
first-mon promotes a question within a run after its first monitor repeat. first-rep
promotes after any repeat (frequency). xrun-sig promotes at the first ask if the template's
past repeats are at least 50% monitor (at least 20 repeats over at least 20 runs).
xrun-freq picks the same number of templates by past repeat count instead. all
promotes everything. Served means a repeat the original agent would have been spared:
fresh if a post-act evaluation was waiting, shown if nothing had changed since the agent last looked.
Precision is the share of evaluations the agent then actually asked for.
python3 sense_log.py shard0.parquet # 5 s -> sense_log_out.json
| policy | evaluations | precision | repeats served (fresh + shown) | evals per served |
|---|---|---|---|---|
| first-mon | 10,825 | 0.58 | 28% + 2% | 1.6 |
| first-rep | 17,307 | 0.52 | 41% + 37% | 1.0 |
| xrun-sig | 13,330 | 0.62 | 37% + 1% | 1.6 |
| xrun-freq | 31,291 | 0.31 | 44% + 9% | 2.7 |
| all | 82,279 | 0.15 | 54% + 42% | 3.9 |
1. Signature beats frequency at the same budget. With the same number of promoted
templates, choosing by monitor share gives twice the precision of choosing by repeat count
(0.62 vs 0.31) at 43% of the evaluations. Frequency picks the "where"/"read" templates
(search_dir <s>, open <p>, find_file <s>), which are repeated a lot but rarely move
after an act.
2. The extra "served" from frequency is the loop being fed. The policies that promote on raw
repeats show far more shown service (37% for first-rep, 9% for xrun-freq, 1% for
xrun-sig). These are reasks answered by a standing view. They are concentrated in the
looping runs (the share of service landing in resolved runs is lowest for first-rep, 8%).
A standing view of a question an agent keeps reasking makes the loop cheaper, not shorter.
That is the escalation rule's job.
3. Four senses do all the work, and the log finds them quickly. At the end the signature
rule has promoted four templates: python <script> (after 107 runs), the reproducer
(after 130), pytest <path> (after 1,828: this agent rarely runs pytest) and
python -m unittest (after 4,495). Requiring the templates to come from at least 20 runs
removes a tail of one-run oddities (pyupgrade, cekit build) at no cost, because those
templates almost never fire. Cross-run memory buys about 9 points of service over first-mon,
which needs no memory at all, because it can promote at the first ask instead of waiting
for a repeat.
4. Escalation is cheap and nearly safe. Over all runs:
| escalate at reask # | runs escalated | resolved if escalated | resolved runs caught | unresolved steps saved | fires at (median) |
|---|---|---|---|---|---|
| 1 | 15.8% | 6.2% | 5.1% | 26% | 36% of run |
| 3 | 7.6% | 3.1% | 1.3% | 18% | 43% |
| 8 | 4.9% | 2.2% | 0.6% | 14% | 42% |
At the 3rd reask the log flags about 1 in 13 runs. Those resolve 3% of the time, and stopping them would give back 18% of all steps spent on unresolved runs, at the cost of 1.3% of the successes (escalation means a human or supervisor looks, so even those need not be lost).
So the shape for /sense is two outputs from one log: monitor-heavy templates become standing
senses, and reask streaks become an escalation. Neither needs a model. Caveats: the agent
is replayed unchanged, so a real agent shown a standing value would ask less, and precision
undercounts. "Evaluation" assumes the sense can rerun the probe for free, but the
reproducer and tests are the expensive probes. Template abstraction is regex-crude.
One scaffold, mostly one model.
Follow-up 12 (2026-10-31 early morning): /sense in a different scaffold #
Follow-ups 10–11 found four senses and a loop detector in SWE-agent runs. Is that a fact
about agents or about that scaffold? sense_oh.py maps the 4,096 SWE-rebench OpenHands runs
(Qwen3-Coder, bash + str_replace_editor, 49% resolved) into the same vocabulary and reuses
the labelling, XRun, replay and escalation code unchanged. "Repro" here means running a
script the agent itself created in this run. One gotcha: OpenHands commands are multi-line
(python -c "<20 lines>"), so keying a question on its first line, as sense.py did, made
13.8% of repeats look like drift. Keyed on the whole command, drift is 1.4%. Output
normalization (timings, addresses, the [Current working directory: …] footer) barely matters.
python3 sense_oh.py data/rb0.parquet # -> sense_oh_out.json (40 s)
python3 sense_oh_more.py data/rb0.parquet # intent-level vs key-level repro reflex
1. The loops are gone, so escalation has nothing to do. Re-asks are 0.2% of probes, and only 5 runs (0.1%) have three or more, compared with 8% of SWE-agent runs. Escalating at the 3rd re-ask flags 0.1% of runs. In the runs that do repeat a question, 72% of repeats are monitor (the agent acted and the answer moved) and 25% unaffected. So the escalate output was a fact about that model and scaffold, not about agents.
2. The reproducer splinters. An OpenHands run writes 5.2 scripts of its own on average
(reproduce_issue.py, comprehensive_test.py, final_verification.py,
test_edge_cases.py…), and 64% of them are run exactly once. Of the "rerun the latest
script after each edit burst" firings, the agent's next repro ask is that same script only
28.5% of the time. 59% of the time it writes and runs a new one. At the intent level the
reflex is nearly perfect: some own script runs after 98.7% of edit bursts, and the reflex
pre-empts 91% of reruns (SWE-agent: 92%/92%). The question stays the same, but its text is
regenerated every time.
3. So the key-level log stops working. With the same rules, cross-run signature
promotion drops from 0.62 precision to 0.04, and signature and frequency now agree
(0.039 vs 0.034). The promoted template repro|<script> makes every fresh script standing
at its first ask, and then most of them are never asked again. Without loops to tell
apart, signature and frequency pick the same things.
4. A third output: constant once-per-run questions. view /workspace (83% of runs),
README.md (47%), python -m pytest --version (36%) and pwd (34%) are each asked about
once per run, in nearly every run. These are neither monitors nor loops. They are facts to
preload at the start. (SWE-agent's ls -F was the same kind of question, in its 14% of probes.)
So for /sense, the four SWE-agent senses were partly scaffold. What carries over is
narrower: the log has to group by intent, which is "run my current check after I change
something", whatever the check is called today. A standing sense for that intent is a slot
the agent refills with its newest script, not a fixed command. Escalation only earns its
keep where the model loops. Caveats: one model per dataset, so the model and the scaffold are
confounded. "Own script" is a filename heuristic. Agents still aren't shown the standing
value in the replay.
Follow-up 13: the intent slot, and which comparison says it's stale (slot.py) #
Follow-up 12 proposed that a standing sense should be a slot ("my current check") that reruns the newest own script after each edit, because the scripts kept being reinvented. The open objection: if the agent writes a new script, the slot is answering a stale question. Whether that matters depends on what "same answer" means, so this compares three comparisons on the same 4,096 SWE-rebench OpenHands runs: output hash (what sense.py's monitor and drift labels use), a verdict read from the output's own words (good / bad / silent: crash, ✓/❌, "ALL TESTS PASSED", "issue reproduced"), and polarity (the verdict, with "reproduced" read as the script doing its job while the code is bad).
python3 slot.py data/rb0.parquet # -> slot_out_v2.json (~2 min)
OLD_EDIT=1 python3 slot.py data/rb0.parquet # follow-up 12's definition of "edit"
V1=1 python3 slot.py data/rb0.parquet # verdict extractor before hand-labelling
The verdict extractor was hand-checked on 40 random checks (35/40 right; the misses were
negations like "Bug not reproduced - working correctly", a late "✅ FIXED", a segfault with
no traceback), patched, then checked on 20 fresh ones: 18/20, and both misses were the same
real ambiguity, "❌ Could not reproduce the issue", where the agent marks its script as
failed while saying nothing bad about the code. Samples in slot_verdict_sample.json,
slot_verdict_heldout.json.
1. Half of follow-up 12's splintering was the definition of "edit". Follow-up 12 counted
any editor write as an edit, including writing the new test script. Then "after an edit,
the next check is a new script" is half tautology: the edit was the new script. Counting
only source edits (str_replace/insert/undo on files that aren't own scripts, plus sed -i),
the first check after an edit burst is the slot's script 60% of the time, another
script 38%, nothing 2.5%. With the old definition the same code gives 30% / 69%,
reproducing follow-up 12's 28% / 59%.
2. Hash says the answer moved 2.3× as often as the verdict does. When the slot's script
is rerun after a source edit, its normalized output differs from its pre-edit output 84% of
the time. Its verdict changed 36% of the time (bad → good 28%). The rest are printed values,
counts and timings moving under a steady verdict. For a /sense log, "the answer changed" by
hash mostly means "the agent printed something different", so monitor-vs-unaffected labels
built on hashes over-count monitors.
3. The slot and the new script ask different questions. In 3,726 post-edit windows where the agent ran both the slot's script and a different own script with no edit in between (same code), their verdicts agree 49%, against 38% expected from the marginals: κ = 0.18. Their hashes agree 0.05% (2 windows). Disagreements run slightly toward the new script finding trouble (slot good / new bad 14%, slot bad / new good 10%). So the reinvented scripts aren't rephrasings of one question. They're new questions under one intent, and a slot that reruns the old script would be a regression check, not a substitute for the new one.
4. Moving goalposts is rare and weakly bad. When the slot's script last said bad, the agent switches to new scripts in 17% of the following windows. In 10.8% it gets a good verdict from a new script and never runs the old one again in the run. Those runs resolve 41%, against 48% for all windows after a bad verdict (n = 367, windows not independent, so weak).
So there were three comparisons and each one lied differently. "Edit" defined too broadly made a
steady habit look like splintering. Hash equality made printed noise look like changed state.
And "same intent" (follow-up 12's fix) hid that the questions under it really do differ. For
/sense: key a standing sense by intent to know when to sense (after a source edit, 98%),
but the value worth keeping is the verdict per script. A small table of each own script's
last verdict, rerun on edit, works as a regression panel, alongside whatever new question the
agent asks. Caveats: verdicts are regex-read (~90% on held-out), "own script" is a filename
heuristic, and one model.