bernardocastro.dev
Bernardo Castro

Bernardo Castro

AI systems engineer · voice agents and the infrastructure they run on

I design and build real-time voice agents and the systems under them. At Pinecall, as founding engineer, I built and run an open-source voice runtime on LiveKit: every call recorded in an auditable log and evaluated the moment it ends, on a fleet of workers that grows with the calls and drains back to zero machines.

Eighteen years shipping production software, with LLMs in production since 2022, first tested in 2021, and deep learning before that. I also lead Axion, Cloudacio's own agentic platform, and own the platform behind 2.5M+ healthcare encounters a year at ServiceHub.

Alicante, Spain · open to senior roles and contract work · English, español

A call, replayed

This is a call my agent took in production, played back from its own log in the window you get when you talk to it. The caller is a test persona, a model speaking out loud, so nobody's words are shown; the agent's side is the record itself: what it heard, the tools it ran, how long each reply took, the price, and the judges' verdicts at the hang-up.

ready · talk · 00:00
replay

connected. Say hello.

00:00 / 01:26
production · voice · replayed from the call's own log

Runtime

Pinecall's runtime is three planes, and each one grows on its own. The same image runs two ways: on a Kubernetes cluster, provisioned by Terraform and deployed by Helm, where the fleet follows the calls, or whole on one server, set up with one command. Either way, entirely as code.

  1. Control

    Stateless gateways: logs, keys, routes, quotas, the roster of workers. Any gateway serves any request of any call.

    Grows with requests, never with calls.

  2. Media

    LiveKit, SIP and WebRTC, one per environment, so a sandbox call never shares a machine with a production one.

    Grows by environment and region.

  3. Workers

    The conversations: the ears, the model and the voice. A fleet per environment, sized by the calls in progress.

    Grows with calls, down to zero machines.

A worker dies. The call goes on.

The gateway hears every worker every five seconds and chooses who takes each call. When a worker dies mid-call, the gateway hands the call to another worker, which tells the caller once and picks up where the agent left off.

1.5 s
a worker's command stream cut this long is a worker gone: the gateway does not wait LiveKit's 20 s
0.4 s
later, another worker asks for the call and is handed its whole history
3.7–4.6 s
from the cut to the second worker's first word: the same call, the same log
Who picks the worker for each call
w2 up

0 answered0 handed on0 lost or silent

The gateway hears every worker every 5 s and offers each call to one by name. When w2 dies, the calls it held go on in other workers, with their history, and no new call goes to it.

Capacity follows the calls.

The gateway computes how many workers the live calls need, and KEDA holds the fleet at that number. Up is at once; down is one worker every five minutes, each draining its calls before it goes, until the pool is empty.

32
calls on one scaled worker, alone on an 8-vCPU node at ~60 %
60 / 45 %
the gateway asks for one more worker above the first, lets one go below the second
0
nodes left in the workers pool at night, each worker drained of its calls before it went
busy 0%target 60%0 calls

One worker, 32 seats. Calls start to arrive.

Measured, not estimated.

  • 2,000concurrent calls on six gateways, every log read back: 0 wrong
  • 1,200live calls with a gateway machine killed: 0 refused, 0 billed twice
  • 16 / 16calls kept through a release of a new image, none drained
terraform$ make tf-plan CLUSTER=productionNo changes. the cluster and its node pools, fully as code

Measured on GKE, provisioned with Terraform and deployed with Helm · Oct–Nov 2026

A call, end to end

Every call goes through six stages, most of them in under a second. Each has its own failure modes, and each writes an entry to the call's log.

A phone call reaches the runtime from the carrier over SIP, and a browser call over WebRTC. Both end up in the same place: a LiveKit room, which carries the audio both ways.

where it breaksAnyone on the internet can knock on a phone port, and some do it all day, looking for free calls.

how it holdsThe phone port only answers the carrier's own addresses. Everyone else gets no reply at all.

on the logcall.ringingweb · bernardo

The gateway picks a worker, one of the programs that hold conversations, and it joins the room for this call. It loads the agent's voice, model and words for the world the call belongs to.

where it breaksA machine dies mid-call, or every seat is taken at the busiest minute.

how it holdsA worker that dies mid-call hands the call on: within seconds another worker reads its history, tells the caller once, and picks up where it left off. Only when every seat is taken does the caller hear one sentence and get a call back.

on the logcall.startedworker joined · sandbox

Speech recognition writes down what the caller says, and a turn detector decides when they have actually finished, not just paused for breath.

where it breaksIt answers too early and cuts the caller off, or a "mhm" makes the agent stop mid-sentence.

how it holdsTurn rules per language: a few words to interrupt, and backchannels like "mhm" and "vale" are let through.

on the logturn.user"Thursday would be great."

The model reads a prompt rendered from the call's state and decides what to do. When it needs a fact or an action, it calls a tool, and the tool runs in the business's own code, not in ours.

where it breaksIt invents a time that does not exist, books something nobody agreed to, or goes quiet for twenty seconds.

how it holdsOnly tools change anything. A model silent for 12 seconds is cut, and the caller hears "one moment".

on the logtool.callfreeSlots(Thursday)45 ms

The reply is spoken as it is written, word by word, so the caller hears the start of it before the model has finished thinking.

where it breaksThe agent talks over the caller, or every reply arrives a beat too late to feel like a conversation.

how it holdsWhen the caller speaks, the agent stops. Every turn records its time to first audio, so a slow day shows up as a number.

on the logturn.agent"How about one of these…"ttft 518 ms

The call ends and its record is closed: every model priced, what the agent learned remembered, and the call graded by judges.

where it breaksNobody listens to the calls, so a bad one is only found when a customer complains.

how it holdsEvery call is judged as it hangs up: by code where a rule can decide, by a model only where it cannot. The record cannot be edited afterwards.

on the logcall.scoreconsent · grounded · promises3/3 held · $0.028

Open source

The tools I use in production work, released as open source. Install them and read the code before we talk.

  • pinecallVoice runtime

    The server side of voice AI: gateways, worker fleets, the call log, evaluation and memory in one runtime on LiveKit.

    $ uv tool install "pinecall-runtime[voice]"
  • taskopsAgent teams

    A shared work board for teams of coding agents, over MCP. The server enforces review: no agent approves its own work.

    $ uv tool install taskops-cli
  • mypryAgent debugging

    A runtime debugger for AI agents: breakpoints, stepping and eval across Node.js and the browser in one session.

    $ npm i -g mypry
  • vibesmellCode quality

    Finds the cross-file code smells linters miss, across a whole Python package or TypeScript project.

    $ uvx --from vibesmell vibesmell score
  • shipwayDeploys

    Deploys an app to any server over SSH from a short YAML file: build, rsync, restart, health check. No Docker.

    $ npm i -g shipway
  • diskscanDisk usage

    A parallel macOS disk scanner, in Rust, that lists the folders you can actually delete, in one HTML report with a treemap. It never deletes anything itself.

    $ cargo install --git https://github.com/bernatch22/diskscan
  • Everything on GitHubThe rest of what I have published, and the history of each of these.

Experience

  1. Pinecall

    2025 – now

    Founding Engineer · engine and infrastructure · open source, Apache-2.0

    • Founding engineer of an open-source voice AI platform: a Python runtime on LiveKit for phone, SIP, WhatsApp and the browser, with an append-only call log, multi-tenancy, memory, automated evaluation of every call, and SDKs in TypeScript, Python and Ruby.
    • Architected the runtime as three planes that scale independently: stateless gateways where any gateway serves any request of any call, a media plane per environment that keeps test traffic off production machines, and worker fleets sized by live calls.
    • Built demand-driven autoscaling: the gateway computes the workers the live calls need and KEDA holds each fleet at that number; scale-down drains each worker before removing it, down to zero nodes. A worker that fails mid-call hands the call to another worker with its full history, and releases never interrupt a live call.
    • Capacity is measured, not estimated: 2,000 concurrent calls on six gateways with every call accounted for, and a gateway machine killed under 1,200 live calls with none refused and none billed twice. Deployment is code, on Google Cloud or AWS: Terraform provisions a Kubernetes cluster and Helm deploys the runtime, or one command sets the whole runtime up on a single server.

    python · typescript · livekit · postgres · redis · docker · kubernetes · keda · helm · terraform · gke · eks · aws

  2. ServiceHub

    Sep 2025 – now

    AI engineer through Cloudacio · platform migration and security remediation

    • Own the legacy platform behind a healthcare-interpreting business handling 2.5M+ encounters a year: three applications fed by live HL7 interfaces from hospital systems, guarded by a Playwright suite of 57 end-to-end checks I built.
    • Led the production migration from PHP 7.4 and 8.1 to PHP 8.4 in response to a CERT-EU remote-code-execution advisory: four servers, about 40 Windows services and 20 live HL7 listeners moved one at a time. Rehearsed on a mirror environment, shipped with checksum-guarded deploys and one-command rollback; responses identical before and after.
    • Remediated an external penetration test of 25 findings; the independent retest confirmed both Criticals and four of the six Highs closed. Two fixes were in VB6 COM+ components written in 2000: restored an unfinished build server, rebuilt the DLLs from source, verified the build byte for byte against production, and shipped the fix.

    php 8.4 · iis · hl7 · sql server · classic asp · vb6 · com+ · playwright

  3. Cloudacio

    May 2026 – now

    Lead engineer · Axion, agentic platform · New York

    • Architected and built Axion end to end, Cloudacio's own agentic platform: autonomous Claude agents that run a research and decision desk around the clock, in production, through an MCP control plane with isolated multi-tenant workspaces.
    • Rules live in code, not prompts: hypotheses are pre-registered before any test, limits are enforced by the platform, a result counts only once validated forward in time, and every decision leaves a complete audit trail.
    • First domain: live crypto-derivatives markets, on proprietary 24/7 data capture into a 6B+ row point-in-time ClickHouse store.

    python · claude · mcp · clickhouse · fastapi · gcp

  4. DigitalBGA

    Sep 2020 – Mar 2025

    Software architect · AI team lead

    • At DigitalBGA, twice recognized on the Inc. 5000 list of fastest-growing private companies, I spearheaded the development of critical systems. I led the team responsible for developing and launching a voice agent using Twilio to handle missed calls.
    • Led the development of a comprehensive e-app system, featuring a form builder, PDF editor for field mapping, and an electronic signature system. The platform has successfully processed over 4,000 e-apps with major carriers, including Mutual of Omaha.
    • Maintain and enhance applications across multiple technologies, including Ruby, PHP, React, and Python.

    ruby · php · react · python · twilio

  5. Crisalix

    2017 – 2019

    Full-stack · 3D medical imaging · Barcelona

    • Worked side by side with the machine learning team on deep learning models, including transformers.
    • Developed the public API from the ground up.
    • Created an image editor with advanced comparison tools.
    • Designed and implemented the subscription plans manager, and built the KPI dashboard.
    • Wrote a JavaScript library that streamlined the Rails views across the company's applications.
    • Integrated Sebbin and Motiva implants.
    • Led the team that won the company's first hackathon, with a mobile app that turns a selfie into a 3D model.

    ruby · js

  6. Earlier roles

    2008 – 2020

    Full-stack · US and EU clients · since age 17

    • Remote consulting, 2012 – 2020: CallAction (my first in-depth work with Twilio), PUSHTech, Teamitup (New York), Tarmac, Dawson, SoFetch.
    • Cubox, Montevideo, 2010 – 2011: Rails development for US startups, with TDD and pair programming, at a studio founded by an early Twitter engineer.
    • Webinteligente (now Dugson), 2009: PHP applications, including a CMS for PLUNA, Uruguay's national airline, delivered at age 18.
    • deConsultas, 2008: hired full-time at 17 to build a B2B travel platform from scratch.

    ruby · php · js