BoundaryML/baml · error · EngineError
Function call with ID {call_id} not found
Error message
Function call with ID {call_id} not found What it means
`EngineError::FunctionCallNotFound` is raised when the engine is asked about a function call whose `CallId` it does not track. Call IDs are engine-scoped handles; an unknown ID means the call was never registered, already completed and was reaped, or belongs to a different engine instance.
Source
Thrown at baml_language/crates/bex_engine/src/lib.rs:801
.active_calls
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
map.remove(&self.call_id);
let no_active_calls = map.values().all(|call| call.pending);
drop(map);
if no_active_calls {
self.engine.lifecycle_changed.notify_waiters();
}
}
}
/// Errors that can occur during engine execution.
#[derive(Debug, PartialEq, Error, Clone)]
pub enum EngineError {
#[error("BAML engine is shutting down")]
ShuttingDown,
#[error("Function call with ID {call_id} not found")]
FunctionCallNotFound { call_id: CallId },
#[error("Future with ID {future_id} not found")]
FutureNotFound { future_id: FutureId },
#[error("Function not found: {name}")]
FunctionNotFound { name: String },
/// Function exists, but its `FunctionKind` is not invokable as an
/// engine entry point. Only bytecode functions can be called via
/// [`BexEngine::call_function`] / [`BexEngine::call_function_bound_args`]:
/// native (`$rust_function`) entries would re-enter the VM through
/// `YieldToCall` with no bytecode frame to return to. Sysops + builtins
/// reach their natives from inside a calling bytecode body.
#[error("Function `{name}` is not invokable as an entry point (kind: {kind})")]
NotInvokableAsEntry { name: String, kind: String },
#[error("VM internal error: {0}")]View on GitHub (pinned to bd85ce9dee)
Solutions
- Use only `CallId`s returned by this engine instance in this session.
- Check that the call has not already completed and been cleaned up.
- Re-issue the call to obtain a fresh ID instead of reusing a stale one.
Example fix
// before
let result = engine.call_result(stale_call_id).await?;
// after
let call_id = engine.call_function("f", args).await?;
let result = engine.call_result(call_id).await?; Defensive patterns
Strategy: try-catch
Validate before calling
// track CallIds only from the live engine instance; drop after completion
Try / catch
// rust
match engine.call_result(call_id).await {
Err(EngineError::FunctionCallNotFound { .. }) => /* re-issue the call */,
other => other?,
} Prevention
- Never persist CallIds across engine restarts
- Await each call once; treat IDs as single-use
- Scope call tracking to the engine instance that issued the ID
When it happens
Trigger: Looking up, awaiting, or cancelling a call with a fabricated, expired, or foreign `CallId` via the engine's call-tracking APIs.
Common situations: Persisting a call ID across engine restarts; awaiting a call after it completed and its record was dropped; mixing IDs between two engine instances in tests.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- BAML engine is shutting down
- Function not found: {name}
- engine is not current with the latest sources; wait for the
- LSP client sent exit before completing shutdown
- Future with ID {future_id} not found
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/c6230c2dccc42078.
Report an issue: GitHub.