Get early access

The hyper-observable programming language

BAML is a programming language with built-in telemetry. Replace 10+ separate tools with one toolchain that helps agents test, trace, query data, build alerts, and more.

No single stack has ever gone past deploy.

Language
C
TypeScript
Go
Rust
BAMLBuildTestReleaseTraceMetricsAlertsMoredeploy
Improve

Until now.

Used by engineers at

  • Stitch Fix
  • Feather
  • SAP
  • AMD
  • EY
  • Akamai
  • Vetcove

Hyperobservability is observability that is always on, by default, for everything.

BAML's toolchain helps agents at compile time, and after deployment. The runtime records your program as it runs and sends it to Boundary Cloud, or stores it locally in SQLite if you don't use the cloud. There's no SDK to install and no collector to run.

Observability

More work, less data.

support.ts11 lines
const tracer = trace.getTracer("support");
const replies = meter.createCounter("replies");
const latency = meter.createHistogram("reply_ms");
async function draftReply(ticket) {
return tracer.startActiveSpan("draftReply", async (span) => {
const start = performance.now();
try {
span.setAttribute("ticket.id", ticket.id);
const label = await classify(ticket);
if (label === "Spam") return "";
const reply = await writeReply(ticket, label);
replies.add(1, { status: "ok" });
logger.info("drafted", { traceId: span.spanContext().traceId });
return reply;
} catch (err) {
span.recordException(err);
span.setStatus({ code: SpanStatusCode.ERROR });
replies.add(1, { status: "error" });
throw err;
} finally {
latency.record(performance.now() - start);
span.end();
}
});
}
what you get
draftReply1842.0ms
http.post auto611.4ms
http.post auto1227.2ms
exceptionerror
repliescounter
reply_mshistogram
draftedlog

Hyperobservability

No work, more data.

support.baml7 lines
function draft_reply(ticket: Ticket) -> string {
let label = classify(ticket);
match (label) {
Label.Spam => "",
_ => write_reply(ticket, label),
}
}
what you get
draft_reply1842.0ms
classify612.3ms
classify.render_prompt0.3ms
classify.build_request0.1ms
ai.Client.invoke611.2ms
POST api.openai.com/v1/chat/completions610.8ms
connection200
dataevent
endevent
classify.parse0.4ms
write_reply1228.6ms
write_reply.render_prompt0.4ms
write_reply.build_request0.1ms
ai.Client.invoke1227.4ms
POST api.openai.com/v1/chat/completions1227.0ms
connection200
dataevent
dataevent
endevent
write_reply.parse0.5ms
garbage collector6.1ms
collection_levelmajor
reclaimed_slots1,204
live_slots3,817
live_payload_bytes96 KB

Make decisions faster, with less CI time.

BAML enables you to observe everything at a fraction of the cost, allowing you to have more complete information.

Observability

Time to a decisionstill waiting, day 1

# supportday 1

Monday, November 2

Vaibhav6:12 PM

@claude the support agent refunded a customer twice. How?

ClaudeAPP6:13 PM

The LLM trace shows one issue_refund tool call. Inside the tool, nothing is traced.

ClaudeAPP6:14 PM

I'll add tracing inside the tool.

Tuesday, November 3

ClaudeAPP9:21 AM

Opened a PR to trace refunds.

acme/support-agent#1287 Trace issue_refund and its retriesOpen+52−23 files

ClaudeAPP10:40 AM

Merged. Waiting for another double refund ⏳

Friday, November 6

Vaibhav2:05 PM

Finance found two more 😬

ClaudeAPP2:09 PM

Checked the traces: no new double refunds since Tuesday. Finance's two must be older, from before we traced. Still waiting ⏳

Tuesday, November 10

ClaudeAPP9:40 AM

Caught one. Inside issue_refund, POST /refunds took 31s. The client retried at 30s.

Vaibhav9:45 AM

How many customers did it hit before this?

ClaudeAPP9:46 AM

Can't tell. We weren't recording then. Finance would have to dig through the payment records.

Vaibhav9:52 AM

Make refunds idempotent, and ask finance who else got two 👍

Decision

ClaudeAPP12:20 PM

Fix is through CI and deployed. Finance is still working on the list.

Message #support

Hyperobservability

Time to a decision3 minutes

# supportday 1

Monday, November 2

Vaibhav6:12 PM

@claude the support agent refunded a customer twice. How?

ClaudeAPP6:13 PM

The model called the issue_refund tool once. The AI part is fine.

ClaudeAPP6:13 PM

Inside the tool, POST /refunds took 31s. The client retried at 30s, and both went through.

ClaudeAPP6:14 PM

Same thing hit 23 customers since October 3. $4,180 in all.

Vaibhav6:15 PM

Make refunds idempotent, then email those 23 👍

Decision

ClaudeAPP8:40 PM

Fix is through CI and deployed. Emailed all 23 customers.

Message #support

Mon 2Tue 3Wed 4Thu 5Fri 6Sat 7Sun 8Mon 9Tue 10Wed 11Thu 12
Observability

Asked

Inside the tool isn’t traced

Tracing merged

Now wait for a repeat

Finance finds 2 more

From before the tracing

Caught one

Decided: make refunds idempotent

Fix shipped after CI, 12:20 PM

Customers not emailed

Hyperobservability

Answered in 3 minutes

Decided: make refunds idempotent

Fix shipped after CI, 8:40 PM

All 23 customers emailed

Mon 2

Drag across the timeline to move through the days.

Turn your traces to a queryable data-lake, with zero setup.

Query your program traces and profiles to generate any custom dashboard using baml query, or create alerts with baml alerts to keep track of critical metrics.

  • High token usage

    Over threshold

    41.2Minput tokens this week

    write_reply used 3.2× the tokens it used last week.

    • write_reply41.2M
    • classify12.8M
    • route3.1M
    SELECT span_name,
           sum(total_usage[0]['input_tokens']) AS tokens
    FROM spans
    GROUP BY span_name
    ORDER BY tokens DESC
  • Security issue detected

    Alert firing

    2calls to an unlisted host

    An agent tool sent data to a host that is not on your list.

    support_agenthttp.getpastebin.com
    span_idstart_timeurl7f3a91c2Mon 6:13 PMpastebin.com/raw/9xk2b21c04deMon 6:14 PMpastebin.com/raw/9xk2
    SELECT span_id, start_time, input_args['url'] AS url
    FROM spans
    WHERE span_name = 'http.get'
      AND input_args['url'] NOT LIKE 'https://acme.com/%'
  • Worst latencies

    Report

    31.2sslowest call this week

    The five slowest calls, each with the input that caused it.

    • issue_refund{ order: 8841, amount: 182 }

      31.2s

    • write_reply{ ticket: "Charged twice and…" }

      12.9s

    • classify{ ticket: "Wrong plan on invoice" }

      9.4s

    • route{ label: Billing }

      7.7s

    • lookup_customer{ email: "j@acme.com" }

      6.1s

    SELECT span_name, duration, input_args
    FROM spans
    ORDER BY duration DESC
    LIMIT 5
  • Also on the board: Errors by function, Model output drifting, Tool called twice.

No person could read this much data. Agents can, and they need to.

A query answers the question you thought to ask. An agent can read everything else.

One run. You can read this.

1 run, 200 spans

Timeouts0

Bad tool calls0

Retry loops0

GC spikes0

We made observability cheap, fast, and multimodal.

Because we own the language and the BAML runtime, we're able to make optimizations to telemetry that no other language can.

Cheap

4.6×less storage for agent traces

OpenTelemetry

Storage

16 TB

Calls recorded

80%of errors lost to sampling

Boundary

Storage

3.5 TB

Calls recorded

0%of errors lost to sampling

Fast

32 nsto observe a function

  • Boundary32 ns · baseline

  • OTel + Rust186 ns · 5.8× slower

  • OTel + TypeScript702 ns · 22× slower

  • OTel + Python9,288 ns · 290× slower

Measured on Apple M2 Max, 64 GB.

Multimodal

One storefor traces and files

  • Every kind of data

    Images, audio, video, PDFs, large strings and bytes.

  • Recursive deduping

    Runtime and cloud collaborate to minimize duplicated data.

  • Keeps your types

    Classes and enums stored with their definitions.

  • Redaction

    Keep PII data private. Withhold a value, and the trace records why.

Runs locally or in the cloud.

We didn't want to build a programming language.

But we wanted to build the most efficient vertically integrated toolchain, so we built BAML with:

  • A virtual machine that runs anywhere.
  • A profiler on every function, at barely any cost.
  • A compiler that knows about your errors in production.
  • A data lake for profiles, spans, logs, traces, and blobs.

BAML, the hyperobservable language.Boundary Cloud, the hyperobservable stack.

BAML is designed like the languages you already trust.

  • 9.5k stars
  • Open source, Apache 2.0
  • Free to use
  • No internet required
  • TypeScript-like syntax
  • Rust-like correctness
  • Go-like concurrency
  • C#-like reflection
  • Python, well, you know, Python.
1// An agent is an AI function with tools.
2function support_agent(ticket: string) -> Answer | FollowUp {The return type is a union. The model either answers or asks a question, and you get back whichever it picked, typed.
3 client: anthropic.Client.new(model = "claude-sonnet-5-5")
4 tools: [lookup_customer, search_tickets]Tools are plain BAML functions. The model calls them until it can answer, and their /// docs tell it what each one does.
5 prompt: `
6 Answer this ticket, or ask one question.
7 Look up the customer first.
8 ${ticket}
9 `
10}
11
12class Answer {
13 reply: string,
14}
15
16class FollowUp {
17 question: string,
18}
19
20// Tools are plain functions. Their docs tell the model what they do.
21/// Look up a customer's plan and billing status.
22function lookup_customer(email: string) -> string {
23 `${email}: pro plan, paid through March`
24}
25
26/// Search past tickets for ones like this one.
27function search_tickets(query: string) -> string[] {
28 ["Charged twice", "Wrong plan on invoice"]
29}

Built for agents.

function chess_candidates(position: ChessPosition) -> ChessCandidate[] { while (from < 64) { let piece = board[from]; if (chess_color(piece, position.white)) { let kind = piece.to_lower_case(); if (kind == "p") { chess_pawn_candidates(position, from, candidates); } else { for (let direction in directions) { if ((kind != "b" || diagonal) && (kind != "r" || !diagonal)) { while (chess_inside(x, y)) {Cognitive complexity50Beforefunction candidates(self, from: int) -> ChessPly[] { let piece = self.board[from] ?? return []; match (piece.kind) { ChessKind.Pawn => self.pawn_moves(from), ChessKind.Knight => CHESS_KNIGHT_STEPS.flat_map(…), ChessKind.Bishop => CHESS_DIAGONALS.flat_map(…), ChessKind.Rook => CHESS_STRAIGHTS.flat_map(…), ChessKind.Queen => CHESS_RAYS.flat_map(…), ChessKind.King => CHESS_RAYS.flat_map(…), }}Cognitive complexity2After

Teaching Agents to Write Maintainable Code

Read the blog →

Compiler errors built for every reader

61% less context

Claude Code

⏺ Bash(baml check)

⎿
Error: Exit code 4
main.baml:15:5-19:6 error[E0062]: non-exhaustive match on type Label; missing: Label.Refund
main.baml:23:17-23:31 error[E0007]: type `Ticket` has no member `priorty`
main.baml:28:24-28:39 error[E0001]: mismatched types
  primary: expected `string`, found `int`

Every function is a CLI

The fastest way to understand a function is to call it.
For AI functions, it's the only way.

$ baml run apply_discount -- --total 8000 --coupon SAVE20

6400

$ baml run classify_sentiment -- --text "Charged twice and nobody replied."

Negative

1 tool call

Instead of script, run, delete

LLM functions too

Try non-deterministic code

0 scratch files

No left-over slop

Code quality, on every pull request.

- uses: BoundaryML/baml-action@v1

Remove the legacy keyword router #482

✓BAML / check✓BAML / fmt✓BAML / test⚠BAML / code health
a3f91c2Simplify routing now the agent picks the team
github-actionsbotcommented on your agent's push

A feature was removed, and the code got longer: 3 functions got worse. Lines 1,240 → 1,556.

mainyour branch
Cognitive complexity: how hard a function is to follow.Readable 31%Cyclomatic complexity: how many decisions a function makes.Few branches 52%NPath complexity: how many different routes there are through a function.Few paths 22%Nesting: how deep the ifs and loops go.Flat 60%How many places a function can return or throw.Few exits 80%
worseroute_ticketcognitive 12 → 41, nesting 3 → 6
worsebuild_promptcognitive 8 → 27, NPath 16 → 240
worseescalatecognitive 5 → 19
newlegacy_router_shimcognitive 23

Coming soon

More things to look forward to.

  • In progress

    Compiled to native

    Interpret for instant builds. Compile for instant execution.

    PR #5218
  • Prototype

    Durable execution

    Pause a run on one machine and pick it up on another.

    PR #4956
  • Proposed

    Sandboxes

    Milliseconds are too slow, megabytes too big.

    BEP-063
  • Designing

    Feature flags

    Roll out experiments 100x faster than CI/CD.

  • Researching

    Formal verification

    Prove a rule holds for every input, not just the ones you tested.

Get started with Boundary

Build a feedback loop with BAML in a live walkthrough, or bring your stack to an engineering session with our team.