BoundaryML/baml · warning

Could not update runtime: {e}

Error message

Could not update runtime: {e}

What it means

In Session::update_text_document, after applying document changes the server rebuilds the BAML runtime; any failure during that rebuild is wrapped as 'Could not update runtime'. The document still updates, but diagnostics/runtime state cannot be refreshed.

Source

Thrown at engine/language_server/src/session.rs:424

                if project.lock().baml_project.files.contains_key(doc_key) {
                    project
                        .lock()
                        .baml_project
                        .unsaved_files
                        .insert(doc_key.clone(), text_document);
                    let _elapsed = start_time.elapsed();

                    {
                        let default_flags = vec!["beta".to_string()];
                        project.lock().update_runtime(
                            notifier.clone(),
                            self.baml_settings
                                .feature_flags
                                .as_ref()
                                .unwrap_or(&default_flags),
                        )
                    }
                    .map_err(|e| anyhow::anyhow!("Could not update runtime: {e}"))?;
                    let _elapsed = start_time.elapsed();
                }
                Ok::<(), anyhow::Error>(())
            })?;
        Ok(())
    }

    /// De-registers a document, specified by its key.
    /// Calling this multiple times for the same document is a logic error.
    pub(crate) fn close_document(&self, key: &DocumentKey) -> anyhow::Result<()> {
        let mut index = self.index.lock();
        index.close_document(key)?;
        Ok(())
    }

    /// Returns a reference to the index.
    pub fn index(&self) -> &Arc<Mutex<index::Index>> {
        &self.index

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Read the inner error to locate the failing BAML construct
  2. Complete or fix the in-progress edit so sources compile
  3. Ensure referenced functions/clients/generators exist and are valid
  4. Ignore transient occurrences while typing if the server recovers on the next change; otherwise restart the server

Example fix

// before: mid-edit referencing missing client
client MyClient undefined
// after: define the client first
client MyClient { provider openai options { model gpt-4o } }
Defensive patterns

Strategy: try-catch

Validate before calling

// lint baml text client-side before didChange
const diags = await bamlLinter.check(newText); // only notify if no fatal errors

Try / catch

try { await sendDidChange(uri, changes); } catch (e) { if (String(e).includes('Could not update runtime')) { /* expected during editing; rely on next change */ } else throw e; }

Prevention

When it happens

Trigger: didChange introduces BAML sources that fail to compile into a runtime (syntax errors, unknown functions/clients, invalid config), so runtime construction returns Err.

Common situations: Mid-edit transient states (half-typed function while typing); referencing a client/model not defined yet; deleting a definition still referenced elsewhere; invalid generator or provider configuration in baml files.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/b539ce50066f82a8. Report an issue: GitHub.