BoundaryML/baml · error
Could not find retry policy with name
Error message
Could not find retry policy with name: {} What it means
BAML looks up a retry policy by name in the compiled IR when resolving a client's retry configuration. If no retry policy with the given name exists in any loaded BAML source file, the lookup fails with this error. This is a name-resolution failure: the policy referenced by the client (or requested by the caller) was never declared in the .baml files.
Solutions
- Check the retry policy name for typos against the `retry_policy` blocks in your .baml files
- Define the missing `retry_policy <Name> { ... }` block in your BAML sources
- If the client references a policy, update its `retry_policy` field to an existing policy name
- Verify you're loading the correct baml_src directory containing the file with the policy
Example fix
// before
client GPT4 {
provider openai
retry_policy ProdRetrey // typo
}
// after
client GPT4 {
provider openai
retry_policy ProdRetry
}
retry_policy ProdRetry {
max_retries 3
} Defensive patterns
Strategy: validation
Validate before calling
import { parse } from '@baml-lang/core';
const policyNames = new Set([...src.matchAll(/retry_policy\s+(\w+)/g)].map((m) => m[1]));
if (!policyNames.has('ProdRetry')) throw new Error('retry_policy ProdRetry is not defined in .baml sources'); Try / catch
try {
const policy = runtime.getRetryPolicy('ProdRetry');
} catch (e) {
if (/Could not find retry policy/i.test(e.message)) {
console.error('Declare retry_policy ProdRetry { ... } in your .baml files or fix the name');
}
throw e;
} Prevention
- Define all retry policies in one shared .baml file and reference by exact name
- Grep your .baml sources for retry_policy names when renaming/deleting one
- Run `baml-cli dev` so diagnostics surface unknown references before runtime
- Keep clients and their retry policies in the same loaded baml_src
When it happens
Trigger: Calling get_retry_policy / the policy lookup inserter with a policy_name that doesn't match any `retry_policy <Name> { ... }` block in the loaded BAML sources (e.g. a client config referencing `retry_policy MissingPolicy`).
Common situations: Typo in the retry policy name in a client block; renaming/deleting a retry_policy in the .baml files without updating clients; loading the wrong baml_src directory that doesn't contain the file defining the policy.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Class not found
- Configuration error
- Enum not found
- Failed to initialize BAML runtime
- function ` ` not found
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/02aa09b8e86bb23a.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/lib.rs:1992
}
}
pub(crate) fn get_retry_policy_impl(
&self,
policy_name: &str,
_ctx: &RuntimeContext,
) -> Result<CallablePolicy> {
#[cfg(target_arch = "wasm32")]
let mut retry_policies = self.retry_policies.lock().unwrap();
#[cfg(not(target_arch = "wasm32"))]
let retry_policies = &self.retry_policies;
let inserter = || {
self.ir()
.walk_retry_policies()
.find(|walker| walker.name() == policy_name)
.ok_or_else(|| {
anyhow::anyhow!("Could not find retry policy with name: {}", policy_name)
})
.map(CallablePolicy::from)
};
#[cfg(target_arch = "wasm32")]
{
if let Some(policy_ref) = retry_policies.get(policy_name) {
return Ok(policy_ref.clone());
}
let new_policy = inserter()?;
retry_policies.insert(policy_name.into(), new_policy.clone());
Ok(new_policy)
}
#[cfg(not(target_arch = "wasm32"))]
{
let policy_ref = retry_policies
.entry(policy_name.into())View on GitHub (pinned to bd85ce9dee)