BAML 0.26.0
Tuples, hot swapping with baml run --hot, a redesigned CLI, concurrency tools in baml.sync, @json and @trace.redact attributes, a new parser and formatter, and programs that run nearly twice as fast.
Thanks to everyone who contributed! Special thanks to harivansh-afk for making Rust-compiled packs faster, and to CanadaHonk for hot swapping. Thanks also to peblair, BenSpex and ViperJuice for the reports fixed in this release.
This release covers changes since 0.25.2. Programs run nearly twice as fast. It also has several breaking changes, so read Breaking changes before upgrading. The CLI redesign affects any script or CI job that calls baml.
To upgrade:
- Update the wrapper to 0.4.0. Older wrappers use
baml self-update; from 0.4.0 the command isbaml self update. - Update the toolchain and bridge packages together.
- Regenerate SDKs with
baml generate, and rebuild packed executables. - Run
baml ide installto refresh editor integration, andbaml agent installto refresh the bundled skill. - Run
baml fmtonce. The new formatter lays out some code differently, sobaml fmt --checkreports files formatted by 0.25.2.
Tuples
BAML now has fixed-length tuples. Write a tuple type as (int, string) and a tuple value as (1, "a"). A one-element tuple has a trailing comma: (int,) and (7,).
class Span {
range: (int, int),
label: string,
}
function pair() -> (int, string) {
(1, "a")
}
function width(s: Span) -> int {
s.range.1 - s.range.0
}
function describe(t: (int, string)) -> string {
match (t) {
(0, _) => "zero",
(_, let label) => label,
}
}
function main() -> string {
let (let n, let s) = pair();
let single: (int,) = (7,);
let nested = ((1, "inner"), true);
let w = width(Span { range: (3, 10), label: "x" });
`${n} ${s} ${nested.0.1} ${single.0} ${w} ${describe((2, "two"))}`
}
- Read a slot with
t.0,t?.0ort.0.1. - Destructure a tuple in
let,const,matchandforpatterns. - Slots are immutable.
t.0 = 5is an error; build a new tuple instead. - Tuples are invariant. A
(int, string)is not a(int?, string). A fresh literal takes its type from context. - JSON encodes a tuple as an array.
baml.json.decodeand model-output parsing accept[1, "a"]and require the exact length. - Every SDK supports tuples. Python uses
typing.Tuple[int, str]and TypeScript uses[number, string]. Rust and Swift use native tuples. Go and Java use generated named types. - Reflection adds
reflect.TupleandType.as_tuple(). - The editor grammars highlight tuples. This covers VS Code, GitHub, Shiki, Sublime, KDE, highlight.js and tree-sitter. The installed agent skill documents them.
Two related changes can break existing code. See Call function-valued fields with parentheses and Array search uses ==.
Hot swap with baml run --hot
baml run --hot watches your project. Each saved edit swaps into the running program without a restart. Calls already in progress finish on the old code, and new calls use the new code.
function greeting() -> string {
"hello v1"
}
function main() -> int {
let i = 0;
while (i < 16) {
baml.io.println(greeting());
baml.sys.sleep(baml.time.Duration.from_seconds(1));
i += 1;
}
0
}
$ baml run --hot main
Watching 1 file (each save swaps into the running program)
hello v1
hello v1
Swapped greeting (100ms)
hello v2
Rejected save needs a restart (120ms)
- `extra` is new, and a swap cannot add declarations
Failed save does not compile (67ms)
mismatched types: expected `string`, found `int`
Swapped greeting (185ms)
hello v3
- Edits that swap: function bodies, prompts, defaults, clients and
$tracehooks. - Edits that need a restart: added or deleted declarations, and changes to
constvalues, types or signatures. - After a rejected save or one that doesn't compile, the program keeps running the last good code.
- It works for project runs and single-file runs. Without
--hot,baml runbehaves as before.
(#5634)
Features
Guard shared state with baml.sync.atomic
baml.sync.atomic(key, fn) runs fn while holding a class instance. Tasks that update the same object take turns instead of overwriting each other's writes.
class Account {
balance: int,
function deposit(self, amount: int) -> void {
baml.sync.atomic(self, () -> void {
self.balance += amount;
})
}
}
// Opposite-direction transfers take turns instead of deadlocking.
function transfer(from: Account, to: Account, amount: int) -> bool {
baml.sync.atomic([from, to], () -> bool {
if (from.balance < amount) {
return false;
}
from.deposit(-amount);
to.deposit(amount);
true
})
}
- A task that already holds a key can enter it again, so guarded methods can call each other.
- A list of keys is held all at once. Two blocks that list the same objects in opposite orders don't deadlock.
- Keys must be class instances. The type checker rejects strings, numbers and other values.
atomiconly excludes otheratomicblocks on the same key. Plain reads and writes still go through. Every exit releases the key, but writes are not rolled back.- A spawned child doesn't share its parent's hold.
In our test, 100 tasks each did a read, a sleep and a write on one counter. Without atomic, the counter ended at 1. With it, the counter ended at 100.
(#5661)
See where a hung program is stuck
When a program hangs, BAML now shows where every task is stuck and names any deadlock. You see this report on the first Ctrl-C of baml run and when a baml test times out. A second Ctrl-C still exits immediately. The warning about background tasks left running at shutdown includes the same report.
interrupted: 3 tasks still running:
task 1 (called from the host), awaiting task 2
File "baml_src/main.baml", line 30, in user.main
task 2 (spawned in user.main), waiting for a key held by task 3
File "baml_src/main.baml", line 10, in user.cross
task 3 (spawned in user.main), waiting for a key held by task 2
File "baml_src/main.baml", line 10, in user.cross
deadlock: task 2 waits for a key held by task 3, which waits for a key held by task 2
Future.stack_trace() returns a running task's current stack, or null once the task has settled. A program can use it to report a stuck task and cancel it:
let x = spawn { slow_job() };
baml.sys.sleep(baml.time.Duration.from_milliseconds(300));
if let trace: baml.errors.StackTrace = x.stack_trace() {
baml.io.println("still running after 300ms:\n" + trace.to_string());
let _ = x.cancel();
}
(#5662)
Keep secrets out of recordings with @trace.redact
Mark a class field with @trace.redact, or a whole class with @@trace.redact, to keep its values out of telemetry. The recording stores a marker in place of the value. The program still reads, prints and serializes the value as usual.
class Account {
name: string,
api_key: string @trace.redact,
}
class Credentials {
token: string,
@@trace.redact
}
A recorded call then looks like this:
"account": { "$class": "user.Account", "name": "visible", "api_key": { "$redacted": "declared" } },
"creds": { "$redacted": "declared" }
Redaction applies everywhere a value is recorded: function inputs and outputs, thrown errors, and log.* data. Classes built with reflect.Class.builder(...).fields_from(...) keep the redaction on the fields they copy.
Recordings now use snapshot format 6. BAML 0.25.0 and later can read it.
(#5564)
Shape a class's JSON with @json attributes
Four attributes now set a class's JSON shape, so you don't need to hand-write to_json or from_json:
@json.rename("key")on a field or enum variant.@json.flattenon amap<string, json>field. It collects the keys no other field takes.@json.fallbackon amap<string, json>field. It marks the union member used when no tag matches.@@json.omit_nullson a class.
class UseDefault {
type: "use-default",
}
class ByoVpc {
type: "byo-vpc",
vpcId: string @json.rename("vpc_id"),
subnets: string[]? @json.rename("subnet_ids"),
@@json.omit_nulls
}
class Other {
type: "UNKNOWN",
raw: map<string, json> @json.fallback,
}
class Config {
id: string,
extra: map<string, json> @json.flatten,
}
type Network = UseDefault | ByoVpc | Other
function demo() -> string {
let n = baml.json.decode<Network>(`{"type": "byo-vpc", "vpc_id": "v-1"}`);
let o = baml.json.decode<Network>(`{"type": "custom", "x": 1}`);
let c = baml.json.decode<Config>(`{"id": "a", "region": "us", "tier": 2}`);
baml.json.stringify(n) + " | " + baml.json.stringify(o) + " | " + baml.json.stringify(c)
}
// {"type":"byo-vpc","vpc_id":"v-1"} | {"type":"custom","x":1} | {"id":"a","region":"us","tier":2}
baml.jsonand the Rust SDK's generatedserdecode follow the same rules.@aliasstill names the field for the model. Model-output parsing accepts both the alias and the@json.renamekey.- Invalid uses are compile errors. Examples:
@jsonon a class that defines its ownto_json,flattenon a non-map field, and two fields with the same JSON key. - The Rust SDK's generated
serdecode now checks literal fields such astype: "byo-vpc". It used to accept any string, so Rust code may now reject payloads it used to accept. - Model-output parsing (
baml.sap) ignoresflattenandfallback.
(#5563)
A new formatter
baml fmt and format-on-save use a new layout engine. When something doesn't fit, it breaks one item per line with a trailing comma. Short lambdas and blocks stay on one line. It formats every construct, including some the old formatter printed verbatim or failed on.
let names = invoice.items
- .map((i: LineItem) -> string throws never {
- i.name
- })
- .filter((n: string) -> bool throws never {
- n.length() > 0
- });
+ .map((i: LineItem) -> string throws never { i.name })
+ .filter((n: string) -> bool throws never { n.length() > 0 });
- let xs = [first_name, last_name, full, "a long literal string to push this list past the width"];
+ let xs = [
+ first_name,
+ last_name,
+ full,
+ "a long literal string to push this list past the width",
+ ];
The formatter checks its own output. The output could parse differently from the input, or lose, move or duplicate a comment. In those cases it reports an error and leaves the file alone.
Action required: run baml fmt once after upgrading. Until then, baml fmt --check reports files that 0.25.2 formatted.
(#5723)
A new parser with far fewer cascading errors
The compiler, formatter and editor now share one parser and syntax tree. After a syntax error, the parser recovers at the next sensible point instead of reporting every token that follows. One file with two malformed signatures went from 15 errors to 4.
Lexing, parsing and lowering are 6–8x faster than before. That figure is for the syntax layer only. It is not an end-to-end baml check or editor latency number.
Some errors that used to be reported after parsing are now parse errors. These are reported as invalid syntax, and the label gives the specific reason.
This parser also checks where doc and header comments go. See Doc and header comments must be in valid positions.
(#5589)
Recordings carry app, BAML and environment details
Every program's trace context now includes baml.ctx.baml_version. If baml.toml sets [package].version, it also includes baml.ctx.app_version. Both appear on recorded spans, locally and in Boundary Cloud. Programs can read them even with telemetry off.
[package]
name = "my-app"
version = "2.0.0"
function main() -> string {
let ctx = trace.current_context();
let app = ctx.metadata.get("baml.ctx.app_version") ?? "unset";
let baml = ctx.metadata.get("baml.ctx.baml_version") ?? "unset";
"app " + app.to_string() + ", baml " + baml.to_string()
}
Use .get(...). Without [package].version there is no app_version key, and metadata["baml.ctx.app_version"] panics.
[package] also accepts organization and registry, which 0.25.2 warned about.
Recordings uploaded to Boundary Cloud also carry these environment details:
| Key | Value |
|---|---|
baml.ctx.os, baml.ctx.os_version, baml.ctx.os_distro | Operating system, its version, and the Linux distribution |
baml.ctx.architecture | CPU architecture of the BAML binary |
baml.ctx.is_ci | Whether CI is set to a true value |
baml.ctx.agent_harness | The AI coding agent that launched BAML, if any |
BAML doesn't collect hostnames, usernames, paths, command arguments or credentials. agent_harness holds the value of AI_AGENT as you set it, up to 128 bytes. Don't put paths or secrets in that variable. Turning recording off with BAML_TELEMETRY=off removes all of these details. Local recordings are unchanged.
Read media content in recording queries
Recording queries still show image, audio, PDF and video values as a small descriptor without their content. A path ending in ['base64'] on a media value now returns its recorded content as base64 text:
SELECT input_args['photo']['base64'] AS photo_b64
FROM spans WHERE span_name = 'user.Describe'
Media that only names a URL or file, and media whose content wasn't recorded, read as missing.
(#5608)
Long context and custom headers for typesafeai.Client
typesafeai.Client.new takes two new options:
client Jev = typesafeai.Client.new(
model = "jev-1.14.0",
long_context = true,
headers = { "x-proxy-auth": "secret" },
);
long_context = truesends TypeSafe's long-context header. It raises Jev's limits from 64k tokens per request and 32k per question to 262k.headersadds request headers. BAML lower-cases them and applies them last, so they override the defaults. If you setauthorizationhere, BAML doesn't resolveapi_key.
(#5475)
Editor highlighting
client Name = ...declarations are now colored in VS Code, Shiki and GitHub.- Word operators show as keywords in most themes:
spawn,await,with,throws,as,is,inandextends. Their scope changed fromkeyword.operator.*tokeyword.operator.expression.*, so update custom themes keyed on the old scope. - tree-sitter now parses client values, backtick
prompt:strings andExtract@spec(...)without errors. - A match guard no longer breaks highlighting for the rest of the file. Nested parentheses in parameter types no longer end the parameter list early.
Updated agent skill
baml agent install installs a baml-core skill with two new style rules. Agents should write x is A | B | C instead of chains of ==, and should not write wrapper functions that only forward their arguments.
function is_staff(user: User) -> bool {
user.kind is UserKind.Admin | UserKind.Moderator | UserKind.Helper
}
(#5724)
Trade collector time for a smaller heap
Two settings now control when the garbage collector runs. Lower them where memory is tight, such as AWS Lambda or small containers, and BAML uses less memory at the cost of more collector time. Nothing changes if you don't set them.
| Setting | What it controls | Default |
|---|---|---|
growth | How much the heap may grow between collections, as a multiple of the data that survived the last one | 4 |
min_growth | The least the heap may grow between collections, and before the first one | 32MiB |
Set them with environment variables for baml run, baml test, the playground and the native SDKs:
BAML_GC_GROWTH=2 BAML_GC_MIN_GROWTH=8MiB baml run main
Or bake them into a packed program in baml.toml:
[pack.gc]
growth = 2.5
min_growth = "8MiB"
- Environment variables override the values baked in by
baml pack. Each setting resolves on its own. - A packed program can rename the variables it reads with
[pack.env_var_names]. - The WASM SDK always uses the defaults.
- An invalid value stops startup, or fails
baml pack, with an error that names the setting. Examples:growthbelow0.25,min_growthbelow1MiB, or a decimal unit such asMB. - These settings are not a hard memory limit.
Across 9 allocation-heavy workloads, growth = 2 with min_growth = 2MiB cut peak memory by 41% and cost 4.5% more CPU. min_growth = 2MiB alone cut peak memory by 27% for 0.8% more CPU. Those are geometric means from packed programs on an Apple M5 Max, 5 rounds each. See ENV_VARS.md for details.
(#5745)
Faster programs
BAML programs run nearly twice as fast as on 0.25.2, and use a little less memory. Nothing needs configuring.
Across our 74-workload benchmark suite, the geometric mean speedup is 1.97x with telemetry off and 1.94x at the default telemetry level. The median workload is about 1.9x faster, and more than a third of them are at least 2x faster. Peak memory is 7% lower on average.
| Workload | 0.25.2 | 0.26.0 | Speedup |
|---|---|---|---|
| Enum comparisons, 100k | 21.4 ms | 3.2 ms | 6.7x |
| Tasks sharing one array, 1 writer and 4 readers | 12.8 ms | 3.0 ms | 4.2x |
| Iterator adapter pipeline, 30k items | 20.0 ms | 4.7 ms | 4.2x |
| Iterative Fibonacci, 100k | 132.0 ms | 32.8 ms | 4.0x |
| Richards | 208.8 ms | 78.7 ms | 2.7x |
| n-body, 20k steps | 114.2 ms | 46.1 ms | 2.5x |
| Binary trees, depth 14 | 558.1 ms | 225.8 ms | 2.5x |
| Agent loop over 300 recorded conversations | 23.2 ms | 9.6 ms | 2.4x |
| Hand-written JSON parser, 25 KB document | 136.6 ms | 78.8 ms | 1.7x |
| Splitting short strings, 100k | 23.0 ms | 17.9 ms | 1.3x |
We ran scripts/speedtest with the released 0.25.2 toolchain and a release build of 0.26.0 at 1dd28347d1. The machine was an idle Apple M5 Pro on macOS 26.7.1. Each workload ran 5 times per version. The table shows median time per job, with telemetry off, excluding process startup and compilation. A repeat run of 0.25.2 matched an earlier run within 1%. These workloads measure BAML code, not model calls. A program that mostly waits on an LLM won't see the same gain.
Programs that spawn many tasks free each finished task's memory right away. Spawning and awaiting 10k tasks now peaks at 91 MB instead of 169 MB. Two small workloads go the other way, reaching about twice the peak memory: about 75 MB instead of 40 MB. One builds a string by 10,000 concatenations, and the other mixes arithmetic and array operations in a loop.
Most of the gain comes from a faster interpreter loop that runs common instruction sequences as one step. Floats no longer allocate, and null and enum comparisons are single checks. Typed JSON decoding reuses its type analysis, and string operations do less work. Tasks sharing an array contend less, and each recorded call costs less telemetry overhead. Output and float behavior are unchanged.
Two side effects:
- Map hashing now uses a per-process random key, which hardens maps against hash-flooding input. Iteration order is unchanged.
- A custom
Equalson an enum is no longer called when both sides are the same variant, soStatus.A == Status.Ais alwaystrue. Classes already behaved this way.
(#5680, #5681, #5354, #5675, #5678, #5679, #5677, #5676, #5704, #5695, #5697, #5696, #5702, #5694, #5700, #5703, #5739, #5744)
Faster baml check on large type graphs
Checking projects with large recursive class and union graphs is much faster, and diagnostics are unchanged. On a real 23k-line, 50-file project, baml check went from 158 s to 0.6 s. Some synthetic union graphs that used to take over 10 minutes now check in under 0.1 s. These are release-build wall times from before and after the change.
(#5718)
Faster Rust-compiled packs
Executables built with baml pack --rust run much faster. Method calls on local objects went from 8.75 ms to 0.20 ms per 100k calls. Interface calls are about 5x faster, n-body about 4x, and array loops about 3x. These numbers were measured on x86-64 Linux against the canary before this work, with telemetry off. The fastest call path only applies with BAML_TELEMETRY=off.
baml pack --rust is opt-in. It needs Cargo and a BAML source checkout that matches your CLI, passed with --rust-workspace. Plain baml pack, baml run, the SDKs and the playground still run bytecode. Read Compiling BAML to Rust for the background.
(#5640, #5641, #5642, #5643, #5683, #5685)
Breaking changes
The CLI is redesigned
Every command now shares one set of output and project flags. Old spellings were removed, not deprecated, so update scripts and CI jobs that call baml.
- One global
--output-format text|json|jsonlreplaces the per-command format flags.jsonlworks fortestand recordings queries. - A command's result goes to stdout. Status, logs and diagnostics go to stderr.
- Exit codes are now
0(success),1(failure) and2(invalid usage).baml runcan also exit with the code your program chose.
| 0.25.2 | 0.26.0 |
|---|---|
baml --project <dir> ... | baml --project-dir <dir> ... |
baml query --from <dir> ... | baml --project-dir <dir> query ... |
-v, -vv, --no-progress | Removed. Use -q to silence status output. |
-qq | -q (no longer repeatable) |
baml auth login|logout|status | baml cloud auth login|logout|status, or baml login / baml logout |
baml query --local "<sql>" | baml local recordings query "<sql>" |
baml query --local --schema [--table T] | baml local recordings schema [T] |
baml query "<sql>" (cloud) | baml cloud recordings query "<sql>" |
baml query --environment <env> --project <org/proj> | baml cloud --env <env> --project <org/proj> recordings query ... |
baml query --format table|json|jsonl | --output-format text|json|jsonl |
baml query --explain|--internal|--verify|--no-refresh | Removed |
baml describe --json <name> | baml describe <name> --output-format json |
baml describe <package> --export | baml describe <package> --output-format json |
baml describe --budget N | baml describe --limit N (it now limits every listing) |
baml describe --symbols | baml describe |
baml run <fn> --output-format debug | baml run <fn> (text is the default) |
baml codequality --output-format table | baml codequality |
baml generate --output-dir <dir> | baml generate --output <dir> (-o still works) |
baml ide install --output-dir <dir> | baml ide install --output <dir> (or -d) |
baml feedback ..., baml clean | Removed |
baml update, baml upgrade | baml self update (wrapper) and baml toolchain update |
baml query "<sql>" still works as a shortcut. It queries Boundary Cloud when you're logged in or BOUNDARY_API_KEY is set, and local recordings otherwise. It says on stderr which one it queried. baml run with no function now runs main if the project has one.
Exit codes changed for these cases:
| Case | 0.25.2 | 0.26.0 |
|---|---|---|
Compile error in check, run, generate or test | 4 | 1 |
baml test with failing tests | 2 | 1 |
baml test with no tests selected | 5 | 0 |
baml test cancelled | 3 | 1 |
A failed baml query | 1–5 | 1 |
Packed executables now choose their output format when they run. They print text by default. Pass --output-format json to the executable to get JSON. baml pack no longer accepts --output-format.
A CI script like this:
baml --project ./app describe root --export > surface.json
baml --project ./app query --local --format json "SELECT COUNT(*) FROM spans"
baml generate --output-dir ./sdk
baml test; [ $? -eq 2 ] && echo "tests failed"
./my-packed-app > result.json
Must be updated to look like this:
baml --project-dir ./app describe root --output-format json > surface.json
baml --project-dir ./app local recordings query --output-format json "SELECT COUNT(*) FROM spans"
baml generate --output ./sdk
baml test; [ $? -eq 1 ] && echo "tests failed" # 2 now means invalid usage
./my-packed-app --output-format json > result.json
Also note:
check,fmtandgenerateprint nothing on stdout, in any format.baml testwriteslog.*output to stderr, sobaml test --output-format jsonstays valid JSON.- A timed-out test now prints a multi-line report of where its tasks are stuck.
(#5583)
trace.span() records arguments by default
trace.span() now records a call's arguments as well as its output and error. This includes the /// baml:$trace=trace.span directive. Programs that already use trace.span() will start storing arguments in local and cloud recordings. Those arguments may include personal data. AI functions already recorded their inputs, and trace.empty_span() still records no values.
To keep a function's arguments out of recordings, code that looks like this:
/// baml:$trace=trace.span
function charge(customer: string, cents: int) -> int { cents }
Must be updated to look like this:
function quiet_span() -> trace.Options throws never {
trace.span(inputs = false)
}
/// baml:$trace=quiet_span
function charge(customer: string, cents: int) -> int { cents }
At a call site, pass $trace = trace.span(inputs = false). To hide only some values, mark them with @trace.redact. inputs = false also works on 0.25.2, so you can make this change before upgrading.
(#5606)
baml.spawn.Limit is now baml.sync.Semaphore
baml.spawn.Limit was removed with no alias. baml.sync.Semaphore has the same new(capacity), capacity(), active_count() and queued_count(). spawn with works as before.
Update every usage of
let provider = baml.spawn.Limit.new(8);
let futures = ids.map((id) -> { spawn with provider { fetch(id) } });
To look like this
let provider = baml.sync.Semaphore.new(8);
let futures = ids.map((id) -> { spawn with provider { fetch(id) } });
A semaphore can now also cap a section inside a running task. Spawns and in-task holders share one pool.
let futures = urls.map((url) -> {
spawn { provider.with(() -> string { baml.http.fetch(url).text() }) }
});
// For a hold that doesn't fit in one closure:
let permit = provider.acquire();
defer { permit.release() }
Semaphores don't re-enter. A nested with on the same semaphore takes a second slot. A custom baml.spawn.Modifier that reads or builds baml.spawn.Plan must use semaphores instead of limits.
(#5352)
Call function-valued fields with parentheses
Calling a field or tuple slot that holds a function now needs parentheses. obj.f(x) always calls a method named f.
All code that looks like this:
class Holder {
f: (x: int) -> int throws never,
}
function call_it(h: Holder) -> int {
h.f(1)
}
Must be updated to look like this:
function call_it(h: Holder) -> int {
(h.f)(1)
}
The same applies to tuple slots: (t.0)(x). The parenthesized form also works on 0.25.2.
One case changes behavior without an error. A class can have a function-typed field f and also implement an interface method f. There, obj.f(x) used to call the field and now calls the interface method. Check function-typed fields that share a name with an interface method, and write (obj.f)(x) where you mean the field.
(#5030)
Array search uses ==
includes, index_of and last_index_of now compare elements with ==. That is deep equality, and it respects custom Equals. Before, they compared lists, maps, class instances and bigints by reference. Nothing fails to compile, but results can change:
[[1]].includes([1]) // 0.25.2: false 0.26.0: true
[[1], [2]].index_of([2]) ?? -1 // 0.25.2: -1 0.26.0: 1
Check any code that relied on finding one specific instance.
(#5030)
Doc and header comments must be in valid positions
The new parser rejects comments that 0.25.2 silently accepted:
- A
///doc comment that doesn't sit directly above a declaration is an error (E0105). This includes///above a statement and a stray///at the end of a file. - A
//#header comment betweenmatchorcatcharms is an error (E0010). - A
//#header after a block's final value turns that value into a statement. A function that must return a value then reports a missing value (E0029).
All code that looks like this:
function classify(x: int) -> int {
/// pick a bucket
let bucket = x;
match (bucket) {
//# zero
0 => 1,
//## everything else
_ => 2,
}
}
Must be updated to look like this:
function classify(x: int) -> int {
// pick a bucket
let bucket = x;
match (bucket) {
// zero
0 => 1,
// everything else
_ => 2,
}
}
Move a //# header that follows a block's final value above that value, or delete it.
(#5589)
BAML_TELEMETRY=off always works, and env_var_names rejects false
BAML_TELEMETRY=off now turns off recording and cloud uploads in packed executables and generated SDKs. It works even with embedded credentials or a saved login. Before, a packed program or SDK whose publisher hadn't mapped the variable recorded at medium and couldn't be turned off. If the publisher renamed the variable, for example to ACME_TELEMETRY, the renamed variable works the same way. Already-built artifacts accept off once they run on the new runtime.
The variable now ignores case and surrounding whitespace. It accepts false, 0 and no as off, and true, 1, yes and on as the default level. With recording off, baml run and baml test no longer need a valid recording destination.
Setting false in [pack.env_var_names] or [bridge.env_var_names] is now an error. This applies to BAML_TELEMETRY, BOUNDARY_PROJECT and BOUNDARY_API_KEY. Publishers can no longer stop end users from turning recording off.
Update every usage of
[pack.env_var_names]
BAML_TELEMETRY = false
To look like this, or remove the setting to keep BAML_TELEMETRY:
[pack.env_var_names]
BAML_TELEMETRY = "ACME_TELEMETRY"
(#5536)
The Rust SDK re-exports baml_bridge
The generated Rust SDK now re-exports its runtime as baml_sdk::baml_bridge. Name bridge types through it, and you no longer need your own baml_bridge dependency pinned to the same version. Keeping a matching direct dependency still works.
The dynamic invoke API moved from the crate root into baml_sdk::experimental, matching the Python and TypeScript SDKs.
All code that looks like this:
use baml_bridge::{Error, OptionalArg};
let v = baml_sdk::invoke(target, args, types, opts).await?;
Must be updated to look like this:
use baml_sdk::baml_bridge::{Error, OptionalArg};
let v = baml_sdk::experimental::invoke(target, args, types, opts).await?;
BAML declarations at the root whose names clash with the SDK's own items are now renamed in Rust. Those names include baml_bridge, BamlOptions, trace, experimental and init. A bug where renamed declarations kept their BAML names is fixed.
(#5735)
Bug fixes
- Fixed: failed spans now record their error by default, and failed root calls and spawned futures record theirs too.
error_value['error']is queryable.http_bodies = falsekeeps every error value out. (#5605, #5607) - Fixed: stack traces now include functions called through a function value, such as agent tools run by
reflect.call_any. (#5605) - Fixed: request handlers, such as HTTP server callbacks, record their real start time and their caller's trace context. (#5605, #5606)
- Fixed: if Boundary Cloud rejects uploads, tracing now keeps working. Only the upload stops. Before,
$tracehooks stopped running andtrace.current_span_id()returnednull. (#5673) - Fixed: an HTTP response the program never reads now completes its network span with its status code. A response released unread shows
status = 'abandoned'. (#5693) - Fixed: images and other media, regexes and CSV records now compare by value with
==.baml.deep_copyof a hasher such asbaml.crypto.Sha256gives an independent copy. These objects cross SDK boundaries as opaque references. In Python they are nowBamlOpaquesubclasses instead of Pydantic models, so code that calledmodel_dump()on them must change. (#5722) - Fixed: calling an interface method on a union of classes that bind an associated type differently no longer crashes the compiler. The result type is the union of each member's result. A call whose parameter type differs per member is rejected, with a hint to narrow the union first. (#5632)
- Fixed: narrowing after a loop now accounts for
break. A variable assigned in the condition and reassigned before abreakno longer gets the wrong type.breakorcontinueoutside a loop is an error instead of a compiler crash. (#5715) - Fixed:
returnin a parameter default or a tagged template interpolation could return a value of the wrong type. It is now an error (E0180).breakorcontinuein a loop's condition is also an error (E0188); move it into the loop body. (#5715) - Fixed: a literal arm after a type test of the same type on an
unknownvalue is now reported as unreachable (E0063). Delete the dead arm. (#5655) - Fixed: a class literal that sets the same field twice is now an error (E0012). Before, the last value silently won. (#5719)
- Fixed:
0.0and-0.0in the same function no longer both take the value of whichever appears first.(0.0).to_string() + "," + (-0.0).to_string()now returns"0.0,-0.0". (#5743) - Fixed:
baml fmtoutput passesbaml fmt --checkafter a single run, includingcatcharms that return a class literal. (#5723) - Fixed: the playground's Prompt and cURL previews work again. (#5736)
- Fixed: the playground's Telemetry tab lists runs in VS Code and Cursor. A run started while the tab is open appears right away and updates when it finishes. (#5570, #5569)
- Fixed:
baml describe pythonshows that generated functions are async. Useawait f(...), or callf_sync(...)to block. (#5573) - Fixed:
baml pack --rustexecutables no longer slow down sharply in catch-heavy code with high telemetry. (#5717)
