Bring your own Lambda (BYOL)

Use this when you already ship Lambdas with your CI/CD and want them on the instance rstreams bus (LeoCron schedules, Observe, queue IO) without adopting Studio workflow deploy.

Shared instances are not supported. Self-hosted and managed dedicated instances are.

Must I use a project, deploy, or workflow?

No — not for the function. Register the Lambda on a dedicated instance. Registration creates its bus queues. That is the runtime.

A data product is a catalog row bound to a queue that already exists on the instance. After workflow deploy or runtime queue reconciliation, the product’s deployment_bindings.queue_name is the queue handle the SDK and MCP tools use. SDK get_writer / get_reader resolve that binding automatically.

The bus is Lambdas registered on LeoCron — platform or yours. Queues exist because those bots exist. Customer BYOL is that same shape: deploy the function, register it, reconcile the catalog onto the queues registration created.

See When to use which for Studio connectors, custom code, and hybrid mixes.

Minimal register (dedicated instance; full steps below):

# Register your already-deployed Lambda on the instance bus (starts paused)
loxtep bots register \
  --instance <instance_id> \
  --name "My Worker" \
  --slug my-worker \
  --lambda-name my-company-worker

When to use which

These methods share the same instance bus. Pick per hop — hybrid is normal.

MethodUse whenWho deploys the code
BYOL (this guide)You already ship a Lambda in your CI/CD and want LeoCron, Observe, and catalog bind on its queuesYou
SDK / connector ingestA packaged connector (or SDK Event Stream) should pull or push into a source data product as a Trigger at the ingest headLoxtep workflow deploy for that hop — see Connect Data Sources
SDK / connector deliveryA packaged connector should write outbound as a Target at the delivery tail (workflow_type: "delivery")Loxtep workflow deploy for that hop — see Configuring Delivery (Event Stream / SDK)
Studio custom code (MicroVM)You want Loxtep to host and run custom logic as a graph node (generated bots / MicroVM), not a Lambda you deploy yourselfLoxtep (Studio project / workflow deploy)

Hybrid. Mix freely on one dedicated instance: connector Trigger → BYOL Lambda on custom-*-out → connector Target; or Studio custom-code next to a BYOL bot; or SDK get_reader / get_writer against a catalog product bound to any of those queues. The join point is the queue name + catalog bind, not a single project that owns every hop.

Do not retarget a BYOL bot’s source_queue / destination_queue onto Studio container queues (w-…-queue-…) to “wire” the graph. Bind each data product to the queue that hop already owns.

Prerequisites

  1. A self-hosted or managed instance (not shared).

  2. Instance connection_details.observe_api has:

    • workflow_deploy_role_arn — used when set. An empty field uses cross_account_role_arn
    • external_id
    • rstreams_secret_arn / rstreams_auth_arn (for Lambda env)
    • cross_account_role_arn — account key stored on the instance, and the role bot registration assumes when workflow_deploy_role_arn is empty

    Both role fields empty returns 500 Missing workflow_deploy_role_arn for bot registration. Record the deployment role ARN from the cross-account template. A missing external_id returns 400 Instance is missing dedicated BYOL prerequisites: connection_details.observe_api.external_id. Complete self-hosted/managed provisioning (cross-account role + external_id) first. Self-hosted create copies a workflow_deploy_role_arn already on the organization registration. The deployment role covers the call when cross_account_role_arn is on the instance. These status codes were read from the handlers and were not called live (unverified).

  3. Your user has instances:bots:write (and instances:bots:read to list / reconcile). Admins and engineers get these by default after the permission seed migration.

  4. The Lambda lives in the same AWS account and region as the instance bus.

Steps

1. Deploy your function

Deploy with your normal pipeline. A minimal Node handler that loops event batches is in the platform repo under docs/custom-lambda-bot/template/.

2. Wire bus secrets on the Lambda

From the CLI:

loxtep instances stream-config <instance_id>

Set on the function:

Env varSource
RSTREAMS_CONFIG_SECRETResources secret (rstreams_secret_arn)
LEOAUTH_CONFIG_SECRETAuth secret (rstreams_auth_arn)

3. Register with Loxtep

Use the CLI:

loxtep bots register \
  --instance <instance_id> \
  --name "My Worker" \
  --slug my-worker \
  --lambda-name my-company-worker

Or call MCP loxtep_workspace with this payload:

{
  "operation": "register_custom_bot",
  "instance_id": "<uuid>",
  "name": "My Worker",
  "slug": "my-worker",
  "lambda_name": "my-company-worker",
  "paused": true
}

Registration defaults to paused. LeoCron paused is the runtime source of truth after the first create—unpause in Observe when ready.

Bot id: w-{org4}-{inst4}-custom-{slug}. Default queues:

RoleName
Source{bot_id}-in
Destination (publish){bot_id}-out
Errors{bot_id}-errors

Leave these defaults unless you have a deliberate reason to override them.

4. Attach IAM

The register response includes iam_policy (LeoBot-equivalent). Attach it to the Lambda execution role (or use the platform LeoBotPolicy pattern). Loxtep also adds a cron-processor lambda:InvokeFunction permission on your function.

5. Bind a data product to a queue you already have

The catalog follows the queue. It does not retarget your Lambda onto a Studio workflow hop. Bind the publish stream: {bot_id}-out.

Option A — Runtime queue reconciliation

Requires system:admin, data_products:admin, or instances:update. Admin UI: /admin/runtime-queue-reconciliation.

  1. Dry-run first with MCP loxtep_observe:
{
  "operation": "reconcile_runtime_queues",
  "instance_id": "<uuid>",
  "dry_run": true
}
  1. Review orphan_runtime / proposed_runtime_stubs. The live reconciler compares every botmon queue to catalog queue bindings (deployment_bindings.queue_name on each data product). It does not drop -in or -errors names; treat those stubs as not the product and keep the product on -out.
  2. Run with "dry_run": false when ready. Default stub mode is auto_stub: orphan queues become draft products with binding_source: reconciled_from_runtime and a catalog queue binding set.
  3. Stub insert needs an active project (and domain). The runner uses an existing deployment or a DB-only placeholder deployment/workflow. It does not deploy your Lambda and does not write a Studio graph. If the org has no active project, stub insert is skipped.
  4. List stubs with MCP loxtep_build (stubs carry the synthetic_system tag):
{
  "operation": "list_data_products",
  "tags": "synthetic_system"
}

Option B — Studio workflow deploy

If the product is created through a Studio project deploy, the deployment orchestrator sets deployment_bindings.queue_name (usually the workflow output queue). No manual queue field on the data product is required.

After the product is bound (reconciliation or deploy), SDK data_products.get_writer / get_reader resolve the bound queue. Pass bot_id as the custom bot id when the checkpoint should be that bot.

6. Unpause and verify

  1. In Observe, find bot id w-{org4}-{inst4}-custom-{slug} and unpause.
  2. Optionally reconcile CLI drift against LeoCron:
loxtep bots reconcile --instance <instance_id>

The same check is available from MCP loxtep_workspace:

{
  "operation": "reconcile_custom_bots",
  "instance_id": "<uuid>"
}

Do and don't

Do

  • Deploy the Lambda in the same AWS account and region as the instance bus.
  • Register paused, attach the returned iam_policy, set RSTREAMS_CONFIG_SECRET and LEOAUTH_CONFIG_SECRET from stream-config.
  • Leave the default custom-* queues; bind the data product to {bot_id}-out.
  • Loop every event in a batch; write flat business objects; flush streams once per invoke.
  • Dry-run reconciliation before stubbing; pass the custom bot_id into SDK reader/writer when checkpointing as that bot.
  • Unpause in Observe (LeoCron paused is runtime source of truth after create).
  • Deregister only when you want the cron row archived — your Lambda stays.

Don't

  • Use a shared instance, a Lambda ARN in another account, or register a Loxtep *-rtime / platform microservice function name.
  • Treat package.json paused as live status, or expect deregister to delete the function or the data product.
  • Take only payload[0], call endStreamAsync per event, or hand-build correlation_id.
  • Point this bot’s source_queue / destination_queue at a Studio container queue (w-…-queue-…-ingested and the rest) to “join” a graph. Catalog binding follows the queue your bot already owns.
  • Promote -in or -errors stubs as the product; the live reconciler does not drop them.

Day-2 operations

ActionCLIMCP loxtep_workspace operation
Listloxtep bots list --instance …list_custom_bots
Getloxtep bots get --instance … --bot-id …get_custom_bot
Update / rename Lambdaloxtep bots update …update_custom_bot
Deregisterloxtep bots deregister …deregister_custom_bot

Deregister archives the LeoCron row and removes the cron-invoke Sid. Your Lambda code is never deleted.

On Lambda rename, Loxtep re-grants invoke on the new function and removes the Sid from the previous one.

Custom bots and project bots share the Observe namespace w-{org4}-{inst4} and are tagged custom-lambda and byol. Instance and workflow deploys do not replace the customer function.

What this is not

  • Zip upload / Loxtep-owned deploy of your code into the account
  • Cross-account Lambda ARN invoke from a different account than the bus
  • Replacing connector ingest/delivery or Studio custom-code MicroVM — those remain available; see When to use which

Related

  • Instance provisioning: Instance Provisioning
  • Connector ingest: Connect Data Sources
  • Connector / SDK delivery: Configuring Delivery
  • Runtime queue → catalog link (operators): docs/operations/runtime-queue-link-queue-workflow.md
  • Engineering ADR: docs/ADR/0011-custom-lambda-bot-registration.md
  • Handler template + CLI contract: docs/custom-lambda-bot/