#4814·baml

Nightly anonymous spawn closure fails on captured bigint; named worker succeeds

Author: BenSpexCreated Sep 10, 2026Updated Sep 10, 2026

0.18.1-nightly.20260909.a compiles an anonymous spawned closure that reads a captured bigint field, but execution fails with expected string, got bigint. The same calculation in a named function called from the spawn succeeds.

Linux x86_64. No model, credentials, SDK, files, or network calls needed.

Minimal repro.baml:

baml
class Config { page_budget_ms: bigint }
function broken(config: Config) -> bigint {
    let pending = spawn { config.page_budget_ms + 1n };
    await pending
}
function worker(config: Config) -> bigint { config.page_budget_ms + 1n }
function working(config: Config) -> bigint {
    let pending = spawn { worker(config) };
    await pending
}
function main() -> bigint { broken(Config { page_budget_ms: 10n }) }
bash
baml toolchain install 0.18.1-nightly.20260909.a
BAML_VERSION=0.18.1-nightly.20260909.a baml run --file repro.baml --output-format json

Expected "11". Actual:

VM internal error: type error: expected string, got bigint

Change main to call working and it succeeds. Ordinary non-spawn map closures over the same config also succeed. Hoisting the bigint field to a local before the anonymous spawn did not help. We additionally reproduced this with TaskGroup.new(2) and nested ready.map(page -> spawn { ... }).

This is distinct from #4813: the failing expression here uses only addition, with no bigint field assignment or subtraction. Our application workaround moves page routing/deadline logic into a named RunRoutedPage function and spawns only that call; all 28 application tests then pass. This affects ordinary bounded-concurrency deadline accounting in a pure-BAML workflow.