coding-agents: deepen holds the per-bank lease up to 15 min while it waits for other sessions' operations
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, python, typescript
Research direction
Read hindsight-integrations/coding-agents/src/deepen.ts around the settle loop, drain, deepen_done, and lease release; then check src/core/hindsight.ts for activeOperations(). Trace how client.opIds and the heartbeat are used before changing the order. Done means a run with no enqueued operations records its own duration and releases the lease promptly, while settle waiting for work it started still works; the issue includes a local patch result to compare against.
Written by the indexing model from the issue text.
Description
Bug Description
deepen (coding-agents integration) ends each run with a settle loop. The loop polls every operation on the bank, not only the operations that this run enqueued. The run holds the per-bank lease and writes no deepen_done row until the loop ends, for up to 15 minutes.
On a bank that several agent sessions share, an operation from another session is active most of the time: a session retain, a consolidation, or a page refresh. So a run that has nothing to do still holds the lease for 15 minutes, and each session start in that time logs another run holds the lease and does nothing.
Code, at d8d03e044ce172437dfa99079791947adc7781b4 (package version 0.9.1). The loop is the same in 0.8.0:
- The loop:
src/deepen.tsL298-L311. It runs afterclient.drain(client.opIds, "extraction")at L296, beforedeepen_doneat L317, and beforereleaseLease(lease)at L327. - What it counts:
activeOperations()insrc/core/hindsight.tsL922-L934. It counts each non-terminal row ofGET /operationsfor the bank, from any client. - The lease:
acquireLeaseatsrc/deepen.tsL110, the heartbeat at L115, the skip line at L121.
Steps to Reproduce
- Point two agent sessions at the same repo bank.
- In session A, do something that leaves a server operation active on the bank for some minutes. A session retain followed by a consolidation is enough.
- While that operation is active, start session B in the same repo. Its session-start hook starts
deepen. - Read the plugin log and
diag.jsonl.
A direct reproduction without two sessions: run node dist/deepen.js --repo <path> against a bank that has one pending or processing operation that this run did not start.
Expected Behavior
- A run that enqueued nothing ends in seconds and frees the lease.
deepen_done.msreports the time of this run's own work.- A run waits only for work it started, or waits for the bank after it frees the lease.
Actual Behavior
- The run logs
[deepen] waiting for N server-side op(s) to settleeach 5 seconds for up to 15 minutes, thenstill active at settle timeout. deepen_doneis written after the loop, somsreports the wait.- The lease is held for the whole loop. Each other run for that bank on the machine exits with
another run holds the lease. - When the host stops the agent session during the loop, the engine dies with it and writes no end row. On Linux with systemd, a
detachedchild stays in the cgroup of the session scope. The scope stop kills it.
Measured on one Linux workstation with 0.8.0, 2026-12-01 08:00 UTC to 2026-12-03 20:20 UTC, two repo banks, several concurrent agent sessions:
| Measure | Count |
|---|---|
deepen_started rows |
114 |
deepen_done rows |
98 |
deepen_done rows with ms at or above 60 s |
22 |
of those, ms from 901 s to 934 s (the 15-minute deadline) |
17 |
| of the 22, runs that enqueued nothing and reached the loop in 0.8 s to 5.7 s | 17 |
deepen_started rows with no end row (session scope stopped during the loop) |
16 |
another run holds the lease lines |
40 |
waiting for N server-side op(s) to settle lines |
3,785 of 4,673 plugin log lines |
The median deepen_done.ms in that period is 2.1 s. The work is fast. The wait is the cost.
Why the loop exists, as I read it
syncStatus().synced in src/core/status.ts L120-L123 needs zero active operations. The loop lets a foreground caller (the installer's conversation import, the e2e harness, the benchmark) read "the process ended" as "the bank is quiet". That is a good property for those callers. This report does not ask to remove it.
The lease has a different job: it keeps a second run from the same work on the same bank. That job ends when this run's own operations end, which is what drain waits for.
Proposed change
Keep the loop. Move the lease and the end row out of it:
- Write
deepen_doneafterdrain, before the loop, somsis the time of the run's own work. - Skip the loop when
client.opIdsis empty. That run changed nothing on the server. - When the run did enqueue work, stop the heartbeat timer and call
releaseLease(lease)before the loop. Stop the timer first: the heartbeat callsprocess.exit(0)when the lease file is gone. - Log the wait line when the count changes, not each 5 seconds.
Sketch, in place of L298-L311 and after the deepen_done block:
if (client.opIds.length) {
clearInterval(heartbeat);
releaseLease(lease);
const settleDeadline = Date.now() + 15 * 60 * 1000;
let logged: number | undefined;
for (;;) {
const active = await client.activeOperations().catch(() => 0);
if (active === 0) break;
if (Date.now() > settleDeadline) {
log(`[deepen] ${active} server-side op(s) still active at settle timeout: proceeding`);
break;
}
if (active !== logged) log(`[deepen] lease released; waiting for ${active} server-side op(s) to settle`);
logged = active;
await new Promise((r) => setTimeout(r, 5000));
}
}
A foreground caller that needs the quiet bank after a run with no new work can poll syncStatus() itself. If you prefer to keep the wait for those callers in every case, a flag such as --wait-settle for the foreground paths gives the same result, with the lease still released first.
I run this change as a local patch on the 0.8.0 bundle. After it, a run that started while two operations of another session were active wrote deepen_done with ms 2376, the lease folder was gone at exit, and the two operations were still active.
Version
0.8.0 (measured). The loop is unchanged at d8d03e044ce172437dfa99079791947adc7781b4 (0.9.1).
- Dominant language
- Python
- Stars
- 45.2k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vectorize-io/hindsight
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineOpencore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vectorize-io/hindsight#7240 · 1 comment ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
vectorize-io/hindsight#7231 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
vectorize-io/hindsight#7228 · 1 comment ·
All issues in vectorize-io/hindsight
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day