Repository navigation
Add run budgets and an example of Loom on AX, and drop the changelogs - #38
Merged
Merged
Conversation
An unattended agent can loop and spend without limit, and nothing told it so. Loom already records each session's model spend and when each run started, but a run had no ceiling to compare them against. run.begin now takes an optional budget_usd / budget_seconds; run.get compares them against that spend and the run's age when the run is read, and names what was exceeded in over_budget, with a mentor hint the plugins hand to the model. Loom does not run the agent, so this is a signal, not a stop. AX runs agents in sandboxes that start empty and are thrown away, and it has no memory layer. integrations/ax shows how to give its tasks Loom: a Workspace that writes the MCP config and an AGENTS.md, a Task bound to it, an SDK example that uses the budget, and the token caveats that follow from AX's API having no authentication yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This is Loom's first release, so there is no history worth keeping by hand, and three files that had to be dated in step were a gate that could only stop a release, never improve one. The GitHub Release already generates its notes from the commits since the previous tag; operator steps and the wire diff (scripts/codegen/wire_changelog.py) go into those notes instead. Removed with the files: the release workflow's changelog gate, the version checks that compared against changelog entries (test_sdk_changelogs.py, the root-changelog test, the TypeScript check-version source) and every link to them in packaging metadata and docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Running it on kind (AX 22954f6, Substrate f6a1dc72) showed the first version could not start, and that it put the token where AX's unauthenticated API prints it: - Substrate refuses an image named by tag, and AX then falls back to a default template that does not exist, so the image is pinned by digest. - The command named agent.py relative to the workspace, where it is not; the image now carries it at a fixed path. - AX's published runner image is not publicly pullable, so the README builds the runner from AX's source. - Substrate denies all egress from an actor without a policy and AX creates none, so egress-policy.yaml allows Loom and GitHub. Its Loom rule has the egress gateway inject the token from a Kubernetes Secret, so the Task carries a placeholder and the sandbox never holds the token. The README records what still fails on that cluster: the workspace git clone through the TLS-passthrough rule, and AX reporting the workspace ready when the clone failed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The clone failure was not the egress policy: Substrate turns on an actor's egress only after its wakeup probe passes, and AX probes /readyz, which waits for the clone. The README now says so, names the AX change that fixes it (tested on kind against the Substrate commit AX pins), and gives the workaround for an AX without it: clone from the agent's own command, when egress is up. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The analyzer's statement corpus keys each statement by its text, and the run-ledger SELECTs and the schema dump now carry budget_usd and budget_seconds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it ends Review found the cost budget compared against the session's whole history: a new run in a session that had already spent was over budget on its first read, and a closed run grew more expensive as the session went on. run.get now counts the session's turns between the run's start and its close, and a cost budget without a session is refused, since nothing could be counted. The over-budget hint asked the agent to wrap up and complete even when the run was already closed, and completing it again rewrote its status; it now fires only for an active run. The AX example left its run active when a step raised or the task was cancelled. It now closes the run as failed or cancelled and re-raises, and it uses a time budget only, because a sandboxed agent has no plugin recording its turns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…show budgets From the second review: - A re-sent run.begin that names no budget keeps the one the run has, like the grade columns, instead of clearing it. - A run's spend is bounded by when Loom recorded each turn (ts), not by the client-stamped turn_at, so a client clock that runs behind cannot hide a turn from the cost budget. - The over-budget hint names only the budgets the run went past, and a blank session_id no longer passes for a session. - The run tools' MCP descriptions mention budgets, and /me shows a run's budget and what it went past; its cost is now the run's, not the session's. - The release workflow generates notes on the tag push only, since a later run appends them again, and the operator steps are written in the release pull request so they are reviewed before the tag. - The AX README says which files belong to the SDK path and which to an MCP agent, and keeps the clone problem to a short known issue. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md
…se AX runs on SIGTERM Reviews three and two of #38 found that bounding a run's spend by the server's insert time dropped every turn the Stop hook posts after run.complete, which is the normal Claude Code order, and let a re-sent turn move to a later run. Splitting the session at the next run's start instead would cut off a run another one is nested in. Each turn's own time (turn_at) handles all three cases; the docs say it relies on the client clock being roughly right. - A closed run is timed from start to close on the server's clock, not by the duration_ms the client reported. - A re-sent run.begin without a session keeps the run's session as well as its budget, so a cost budget never ends up without one. - The budget check moves to server/tasks/domain/budgets.py with one BudgetKind type, and the session check reports loc ["budget_usd"]. - RunScope maps a cancellation to cancelled and takes a settable status, so the AX example uses it instead of a hand-written try/finally, and turns SIGTERM, how AX stops a task, into a cancellation. - The release workflow generates notes only when the run creates the release, so a re-run of the tag push no longer appends them again. - The shipped AX Workspace leaves spec.git commented out until google/ax#482 lands, and the docs and the mentor's money formatting are tidied. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ndow bounds A further review of #38 found three gaps: - Two runs open at once in one session see the same turns, so a second cost-budgeted run was charged the first one's spend. run.begin now refuses a cost budget while another budgeted run is open in the session, naming it; each concurrent worker takes its own session. A time budget alone still overlaps freely. - clickhouse-connect 1.0 and 1.1 bind a datetime parameter to whole seconds, so a sub-second run window could miss a turn; the floor is now 1.2, where binding keeps the milliseconds (checked against 1.1.1 and 1.2.0). - AX kills a task 10 s after SIGTERM, and the SDK's default timeout is 60 s, so the AX example's Loom calls now time out at 5 s and the run's close lands before the kill. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n be trusted Reviews four and five of #38: - The guard against two cost-budgeted runs in one session blocked the session for good after one abandoned run (only MCP runs are idle-swept), raced past concurrent begins, and could name another user's run. It is gone; the docs say runs open at once in one session share its turns, so concurrent workers with their own cost budgets need their own sessions. - The MCP tools no longer offer budget_usd: the model does not know the session id its turns are recorded under, so a cost budget there would silently never fire. budget_seconds stays. - run.get counts turns from unpriced models in unpriced_turns, and the docs say a cost budget is checked between prompts, since the plugins post turns when a prompt ends. - The session check runs after a re-sent begin's session is resolved, and cost and time read one window, from the row the run model already parsed. - cost.record_turns clamps a turn dated more than five minutes ahead. - The release step tells a missing release (404) from any other API error. - The AX example exits 143 on SIGTERM instead of a traceback, and its work() returns the statuses it can. - The Runs page shows elapsed time beside a time budget; the hint's spend is always two decimals; the migration comment is reflowed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Loom passes naive UTC datetimes as query parameters. clickhouse-connect before 1.7 binds a naive datetime as the host's local time, so on a host not in UTC every such window shifts; under Asia/Kolkata a noon run window read as 06:30 and missed its turns (checked on 1.2 through 1.6, fixed in 1.7). The floor moves from 1.2 to 1.7, which also keeps milliseconds, and the window test now runs under a non-UTC timezone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e the claim Review six of #38: - The five-minute slack let a turn dated up to five minutes ahead fall after an open run's window, so a fast client clock still hid it; a turn is now clamped to the server's now. - The "budget_usd needs a session_id" 422 was raised after run.begin had claimed the run id, and a refused begin keeps its claim, so every such request left a Keeper key behind. The check is back on the request model, so it runs before the claim; a client that re-sends a budget re-sends its session. - The AX example makes one 5 s attempt per Loom call, since retries could outlast AX's 10 s kill. - The run window helper no longer pretends started_at can be missing, the workers integration test flushes the insert queue and checks both sides, the millisecond test removes its row, the Runs page grid fits its fifth cell, and the SDK's run.begin docstring says budget_usd needs session_id. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review seven of #38: - The over-budget hint now says how far over the run is ("$2.50 of $2.00 spent", "90 s of 60 s"), to four decimals for a sub-cent budget. - elapsed_seconds cannot go negative when a run's start came from a replica whose clock is ahead. - The AX image pins clickhouse-loom>=1.0, the release with run budgets, and the README says the server must be that new too. - The AX example drops the run id it passed by hand: inside the run scope, writes already carry it. - The docs say how to raise a run's budget (re-send run.begin with a larger one) and that a turn dated in the future is stamped again if re-sent. - The budget_usd field comment and the run_cost docstring are tightened. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erver does Review eight of #38: - A SIGTERM that arrived after the work, while the run scope was closing the run, cancelled the close and left the run active. Once work() returns, SIGTERM is ignored, so the close (one 5 s attempt) lands inside AX's 10 s. - The AX README said an older server refuses the budget fields; it ignores them and lists them in ignored_args, so the run has no budget. - Both budgets are resolved together before the row is built, and each field comment's first sentence, which the reference keeps, carries its rules. - The Runs page shows a sub-cent budget to four decimals, the SyncRunScope docstring names status, and the clamp test checks a lower bound too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review nine of #38: the handler swap ran only when work() returned, so a SIGTERM during the failed or cancelled close still cancelled run.complete and left the run active. It now runs in a finally. Also from that review: the never-None guard on current_task() goes, the release step's comments sit above the steps they describe, the hint reads both budgets the same way, the integration test drops a poll the flush made redundant, and the Runs page reads over_budget once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the run Review ten of #38: - _open_run stored the session id stripped while cost.record_turns keeps it as sent, so a run begun with " s1 " never matched its own turns and a cost budget could not trip. It is stored as sent again; only the blank test strips. - The AX example installs its SIGTERM handler once the run is open, so a signal while the scope is still opening is the default exit, and the README says what that can leave behind. - Field comments say a retry that re-sends budget_usd must re-send session_id and that a begin naming no session keeps the run's; the docs say any non-zero budget replaces the old one; RunScope's outcome reads as one decision; the Runs page shows "0s elapsed"; two docs paragraphs are re-wrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ame sessions once Review eleven of #38: - runs.md told users to change a budget by re-sending run.begin, but a re-sent begin replaces the row like any retry: on a closed run it reopens it, and on an open one it drops what the body does not restate. The docs now say to set the budget in the first run.begin and only describe what a retry does to it. - "Does the run name a session" is one helper, names_session, used by the request model, the row and both run-id claims, which disagreed on a blank session. - The release lookup matches "(HTTP 404)" as scripts/release does and prints the full error before a one-line annotation. - The release docs keep a dispatch command on one line, the budget_usd comment and a RunScope docstring paragraph are tidied, the AX example says why a CancelledError means SIGTERM, and runs.md notes the month-boundary case for a re-stamped turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…naming Review twelve of #38: - The over-budget hint tells a core-toolset agent to call run.complete via loom_op, as the other hints that name an unlisted op do, and the atomic run.begin description says run.get via loom_op reports over_budget. - run.get decides "has a session" with names_session like the request, the row and the claim; the helper moves to server/core/naming.py beside SENTINEL, since claims use it too. - The Budgets docs are one short paragraph per idea plus a bulleted list of limits, the AX README says plainly how a sandboxed agent could use a cost budget, the TZ test scopes its patch with MonkeyPatch.context, and the hint's time branch names one value per line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review thirteen of #38: the MCP tool listing still offered budget_usd on run.begin (its schema comes from the request model), while MCP hides session_id from every tool, so a model could only meet the session rule by guessing an id whose turns never arrive. The field carries MCP_HIDDEN: it leaves the listing and the loom_op argument hints, and HTTP and the SDKs keep it. Its comment now opens with the session requirement, which is the sentence the generated reference keeps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…un.begin listing Review fourteen of #38: - The AX example's one 5 s attempt applies to every Loom call, not only the close, so its comment now says a transient error during the work fails the task, and how an agent that needs retries could close the run instead. - The MCP test checks loom_run_begin in the atomic and all listings that tools/list builds, rather than a private helper. - _complete decides "has a session" with names_session like the rest. - The budget_usd comment says plainly that a re-sent begin restating the budget restates the session; the migration says why budget_usd is a Float64 beside the Decimal cost it is compared with; the release docs say "paste the release notes" once, in the steps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fifteen of #38: when run.begin moves a caller off a run_id another user holds, the id it hands back is derived from the session, so a retry that drops the session lands on a new run without the budget. The field comments and runs.md now say the session and budget are kept on a re-sent begin of the same run_id, and to re-send the run_id the server answered with. budgets_exceeded takes keywords, since its four numbers are two units; the AX README says a budget stop still exits 0; the budget_usd comment is two lines. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A review of #38 found that clamping a future turn_at to the server's now gave an identical turn a new time on every delivery while its own time was still ahead: run A was charged $2, and a replay of the same usage after B opened moved the $2 to B. Determinism matters more than covering a fast client clock, so cost.record_turns stores turn_at as sent again and reports such turns in turns_dated_ahead, and an integration test replays an hour-ahead turn across two runs (it fails with the clamp back). From review sixteen: elapsed_seconds is described as start to close on the server's clock rather than a "duration", the Runs page names unpriced turns and reads "has a session" as names_session does, and the sequential-runs test sets its budgets in units of one turn's price. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d travels with its session Review seventeen of #38: the hint formatted the spend at the budget's precision, so $1.004 against a $1.00 budget read "$1.00 of $1.00 spent" in a message saying the run was over; the spend is now always four decimals. The rule checks the op before reading the result, the Retries bullet says a new budget_usd must be sent with its session_id, and the AX README no longer speaks of an older release when 1.0 is the first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review eighteen of #38: a re-sent run.begin naming a new session moved the run but kept its budget_usd, which was then measured against turns it was never set for, and an overrun vanished. The cost budget is kept only while the session is; the time budget still carries. The docs also stop saying turns_dated_ahead is how a fast clock shows: the plugins post turns without reading the answer, so only a caller that posts its own sees it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review nineteen of #38. run.get rounds cost to six places, so the hint's four missed a spend a few millionths past its budget; it now uses six, as does a sub-cent budget on the Runs page. A re-sent begin that moves sessions dropped budget_usd silently; its `next` now says so, and the docs no longer claim a budget can never be removed. turns_dated_ahead ignores 5 s of ordinary skew, so a client a few milliseconds fast is not flagged on every turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review twenty of #38. A $1.235 budget printed as $1.24 next to $1.23516 spent, and the Runs page still cut cost to four places. Both now show cost and budget to the six places they are kept at, dropping only zeros past the cents, and run.begin rounds the budget to those six places so it compares with run.get's rounded cost like for like. The dropped-budget note says how to set one again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review twenty-one of #38. A budget_usd under a millionth rounded to 0, and a re-sent begin then kept the run's old, larger budget; it is now refused, and the rounding happens on the field before the session check sees it. The Runs page spells dollars with thousands separators as the hint does, the dropped-budget note names the session to re-send with, and _usd moves up with the module's other small helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review twenty-two of #38: the rounding and the 0.000001 floor added in the last round were in the code only, so a caller could meet the 422 or read back a rounded budget with nothing in the docs to explain it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e does Review twenty-three of #38. The floor refused 0.0000006, which rounds to the smallest budget the server keeps; it now refuses only a budget that rounds to nothing. The hint said "5400 s of 3600 s" where the Runs page shows "1h 30m" and "60m 0s"; it now uses the page's spelling. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review twenty-four of #38: the cost-only case already pins its whole budget clause, so counting " of " across the hint added nothing and would fail on any rewording of the advice that follows it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#29 took migrations 028 to 030, so ours moves past them. Its CHANGELOG entries go with the file, which this branch deletes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The merge with #29 kept both parents' hash of schemas/schema.sql in tests/analyzer/shapes.txt; the merged file hashes to neither, so the corpus test failed. Writing the corpus again leaves the one current line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A turn with no turn_at, or one that did not parse, was dated now on every delivery. With run cost counted by turn_at, a replay of the same usage after the run closed moved its cost into whatever run was open next: the first run dropped back under budget and the next one was charged for nothing new. Such a turn now takes the time its message_id was first recorded with in the session, and only a message never seen before gets now. The lookup is one read on the table's key, and only when a batch has an undated turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review twenty-eight of #38. min(turn_at) read the oldest unmerged row, but run cost reads FINAL, which keeps the newest; a turn first sent undated and then re-sent with a time went back to its first run on the next undated replay, and stayed there across partitions that never merge. argMax by version reads the row FINAL sees. The tests stop leaning on an AttributeError for the lookup's fallback, cover a failed lookup, and send the replay in a new block so insert dedup can't pass the test on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed lookup Review twenty-nine of #38. "0001-01-01T00:00:00+01:00" parsed but overflowed when converted to UTC, outside any try, so cost.record_turns answered 500; the parse helper now converts and treats the overflow as unparseable. A failed time lookup logs a warning instead of passing in silence, the lookup's alias no longer shadows turn_at (a later WHERE on it would read the aggregate), and it returns plain datetimes since the column is never null. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review thirty of #38: the overflow case only proved the lookup was asked about it, not that it was stored as now; and the parse helper's docstring had the year bounds the wrong way round. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 tasks done
6 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An agent left running on its own can loop and keep spending. Loom already records each session's model spend (
loom.agent_turn_usage) and when every run started, but a run had nothing to compare those against. This adds an optional budget to a run and hasrun.getsay when the run has gone past it.It also adds an example of using Loom from AX, Google's sandboxed agent runner. AX sandboxes start empty and get thrown away, and AX has no memory of its own, so it's a good fit.
And since this is the first release, the changelogs go, along with the release gate that checked them.
Run budgets
run.begintakes two new optional fields,budget_usdandbudget_seconds(0 means no budget). They're stored as two columns onloom.agent_runs(migration031_agent_run_budgets.sql) and added toRUN_COLUMNS, so complete, grade and the idle close carry them forward like every other column.run.getnow also returns:elapsed_seconds: run start to close (or now), on the server's clock. The client'sduration_msisn't used.over_budget:["cost"],["time"], both, or empty.unpriced_turns: turns from models the price table doesn't know. They count as $0, so they can't trip a cost budget.turnsandcost_usdonrun.getnow cover only the run's own window instead of the session's whole history. Nothing new is stored for this; it's all worked out when the run is read. The comparison itself is a small pure function inserver/tasks/domain/budgets.py.How cost is counted:
turn_at. Sobudget_usdneeds asession_id, and the request model returns a 422 without one (a blank or-session counts as none).turn_athandles the Claude Code ordering, where the Stop hook posts a prompt's turns after the agent already calledrun.complete.cost.record_turnsstoresturn_atexactly as sent, so replaying a turn always lands it in the same run. I first clamped future times to now, but then a replay could move cost into a later run. Instead it returnsturns_dated_ahead(turns more than 5 s ahead of the server) so a caller posting its own turns can spot a fast clock.turn_at, or one that doesn't parse, used to get "now" on every delivery, so replaying it after the run closed moved its cost into the next run. Now it takes the time itsmessage_idalready has in that session (from the newest row, since that's the one aFINALread counts), and only a message Loom hasn't seen gets "now". This costs one extra read on the table's key, and only for batches with an undated turn. If that read fails, the turns are still recorded, dated now, and the failure is logged. A time whose offset pushes it before year 1 or past 9999 counts as no time, instead of returning a 500. One gap is left: turns are written with async inserts, so a re-send a fraction of a second after the first can still miss the stored row.budget_usdis rounded to 6 places, the same as cost. A value that would round to 0 is refused rather than silently read as "no budget".Retries: a re-sent
run.beginfor the samerun_idkeeps any session or budget it doesn't restate, and a new non-zero budget replaces the old one. If the retry moves the run to a different session, the cost budget is dropped (it was set against the old session's turns) and thenexttext says how to set it again.Mentor hint: a
run.getthat finds an active run over budget gets arun_over_budgethint, once per session, over MCP and in theX-Loom-Hintheader. It names only the budgets that were exceeded, and by how much, e.g. "$2.50 of $2.00 spent" or "1m 30s of 60s". Dollars are printed to all six places that matter, so a run just past its budget never reads as "at" it. A closed run still reportsover_budgetbut gets no hint.Other surfaces:
run.beginonly offersbudget_seconds.budget_usdis markedMCP_HIDDEN, because MCP also hidessession_idand the model doesn't know which session its turns are recorded under. HTTP and the SDKs have both.run.begintakes both fields.RunScopecloses ascancelledon a cancellation, and the block can setrun.statusfor a clean exit./meRuns page shows the budget, elapsed time against a time budget, what was exceeded, and the unpriced turn count.clickhouse-connectnow needs>=1.7. Older versions drop the milliseconds from datetime parameters (<1.2) or bind a naive datetime as host local time (<1.7), which shifts every time window on a host that isn't in UTC.docs/features/runs.mdhas a new Budgets section.Loom doesn't run the agent, so a budget is only a signal, never a stop. Cost is only known once a turn is recorded, so a run can go over by the cost of its last turn before anyone sees it.
integrations/ax
task.yaml: aWorkspaceand aTaskthat uses it. The image is pinned by digest, because Substrate refuses tags.egress-policy.yaml: AX creates no egress policy, and Substrate blocks all egress without one. The Loom rule has Substrate's egress gateway swap in theAuthorizationheader from a Kubernetes Secret. The Task itself only carries a placeholder, which matters because AX's API has no auth andax get taskprints the Task's env.agent.py: the SDK path, and what the Task actually runs. It opens a run with a time budget, checksrun.getbetween steps, and closes ascompleted,cancelledorfailed. Once the run is open, SIGTERM (how AX stops a task) becomes a cancellation and the process exits 143. During the close SIGTERM is ignored, and each Loom call gets a single 5 s attempt, so the close finishes inside AX's 10 s grace period.README.md: the in-cluster Service, the Secret and credential-provider grant, building the runner image (AX's published one isn't publicly pullable), and a known issue. On current AX the Workspace git clone runs before the sandbox has network. I filed Workspace git clones fail because egress waits on the /readyz wakeup probe google/ax#482 (they don't take external PRs yet), sospec.gitis commented out and the README says to clone from the agent's command for now.Changelogs removed
CHANGELOG.md,sdk/python/CHANGELOG.mdandsdk/typescript/CHANGELOG.md, plus the release workflow's changelog gate, the version checks that compared against them, and the links to them from packaging metadata and docs.scripts/codegen/wire_changelog.py) go in a "Release notes" section of the release PR, so they get reviewed before the tag.docs/development/release-process.mdcovers it.Testing
Unit tests cover storing and keeping the budget, retries with and without a session or budget (including a session move), the 422s, the cost window while open and after close, server-side timing, each budget tripping, the mentor rule and its formatting, unpriced, future-dated, undated and out-of-range turns, a failed time lookup,
RunScopecancellation and status, and the Runs page.Against a fresh ClickHouse 26.9 with every migration applied:
run.completeandrun.grade.loom_op→run.get),over_budgetand the hint arrived on the first call only.turn_ator one that doesn't parse (both failed before the fix: the first run's $1.60 dropped to $0 and its budget warning cleared), and when it's undated after the turn was re-sent with a time inside a later run. One more runs a millisecond-precision window with the process in Asia/Kolkata. It fails on clickhouse-connect 1.1.1 and 1.5.0 and passes on 1.9.0.agent.pyclosed the run correctly every way it can end:completednormally,failedwith the error re-raised when a step raised,cancelledpast its budget,cancelledwith exit 143 and no traceback on SIGTERM mid-step, andcompletedorfailedas appropriate when SIGTERM arrived during the close.On a kind cluster with AX
22954f6and the Substrate commit it pins (f6a1dc72):agent.pyran in the gVisor sandbox and wrote its run (with its budget) and memories to Loom through the gateway's header injection, with only the placeholder in the Task.make lint,make format-check,make typecheck,make test-unitandmake schema-checkpass. The onemake test-unitfailure,test_insert_shared_embedding_writes_a_complete_builder_row, fails on main too.Not covered: Claude Code talking to Loom over MCP from inside the sandbox (only the SDK path ran there), a cost budget on AX (nothing records a sandboxed agent's spend, which is why the example uses a time budget), and the release workflow itself (it only runs on a tag).
Merge note
The migration is
031_agent_run_budgets.sql, after main's030. Any other open PR that adds a migration needs to number it past whatever main has when it merges.