Skip to content

fix/agents: count adopted executors in the book the journal records - #309

Open
lgrawet wants to merge 2 commits into
hummingbot:mainfrom
lgrawet:fix/book-counts-adopted-executors
Open

lgrawet wants to merge 2 commits into
hummingbot:mainfrom
lgrawet:fix/book-counts-adopted-executors

Conversation

@lgrawet

@lgrawet lgrawet commented Nov 2, 2026 •

Copy link
Copy Markdown

A restarted session adopts the executors a dead session of its strategy left RUNNING (CORR-726): _adopt_running_executors feeds them into the tick's snapshot, the stop gate allows them, and the risk gate counts their exposure. Three other reads still used only the provider's rows, which are fetched under this session's own controller_id — so they reported a book smaller than the one the gate protects:

  • the journal snapshot recorded open=<provider only>;
  • the journal summary (what the agent reads back) showed the same short count;
  • the canvas nudge was told the short count too.

_book_totals() is now the one place the provider rows and the adopted rows are summed, and the gate, the snapshot, the summary and the prompt all read it.

The snapshot's exposure deliberately stays the provider's own. It is the denominator of get_drawdown_pct_checked, which divides the provider's PnL — a figure that excludes adopted executors — so counting adopted size there would dilute the percentage (a $100 loss on $1,000 of own positions against $9,000 adopted would read 1% instead of 10%) and configured pause/shutdown limits could stop firing. The book exposure still feeds the risk gate, where it is only compared against limits and never divided by a session-scoped PnL.

Tests: three cases in tests/test_executor_adoption.py pin the arithmetic (_book_totals ignores malformed rows), the snapshot's book count, and the scoped exposure. Full file: 40 passed. Full suite: 8050 passed; the 6 failures present are identical on a clean upstream/main and unrelated (conversation listing, host load, timing probes).

A restarted session adopts the executors a dead session of its strategy left
RUNNING (CORR-726), and the risk gate counts them — but the snapshot line and
the canvas nudge still read the provider's session-scoped rows, so they
reported a book smaller than the one the gate protects.

`_book_totals` is now the one place the provider rows and the adopted rows are
summed; the gate, the snapshot and the prompt all read it.
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous loss-limit issue is fixed.

Summary

Counts adopted executors alongside this session's own executors through _book_totals.

  • Restarted sessions now show adopted executors in their book counts.

Reviews (2) · Last reviewed commit: "fix(agents): keep drawdown's exposure in..." · Reviewed by Greptile

Comment thread condor/agents/engine.py Resolved
The snapshot's exposure is the denominator of a drawdown over the provider's
PnL, which excludes adopted executors. Counting their size there diluted the
percentage — a $100 loss on $1,000 of own positions against $9,000 adopted read
1% instead of 10% — so pause and shutdown limits could stop firing. The book
exposure still feeds the risk gate; the snapshot records the book's open
count, and its exposure stays paired with the PnL it divides.

The journal summary reads the same book count, so the two lines agree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant