Files
Yuan Tang 03b6ee51f5 feat(scheduled): auto-attach cost_budget policy on fire (#4791)
* feat(scheduled): auto-attach cost_budget policy on fire

Add an optional `max_cost_usd` field to scheduled tasks. When set, the
fire path attaches a `cost_budget` policy to each spawned session,
capping cumulative LLM spend at the configured limit. This prevents
runaway token spend from unattended scheduled runs.

The attachment is non-fatal: if the policy store is unavailable or the
create fails, the session proceeds uncapped (an uncapped session is
better than a dead run).

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>

* fix: chain migration after current alembic head

Point the max_cost_usd migration's down_revision to the actual current
head (d5e9f1a2b3c4) instead of z9a2b3c4d5e6, which already had another
child — creating a branch that broke alembic's single-head requirement.

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>

* fix: SQLite-safe downgrade and update column set test

Use batch_alter_table in migration downgrade for SQLite compatibility.
Add max_cost_usd to the expected column set in migration tests.

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>

* fix: chain migration after merged main head za2b3c4d5e6f

Repoint down_revision from d5e9f1a2b3c4 to za2b3c4d5e6f so the
migration chains after the task_summary migration that landed on
main, avoiding a dual-head conflict.

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>

---------

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
2026-08-21 16:22:23 -04:00
..
2026-06-13 00:37:34 +00:00
2026-06-13 00:37:34 +00:00
2026-06-13 00:37:34 +00:00
2026-06-13 00:37:34 +00:00
2026-06-13 00:37:34 +00:00