zed-industries/zed · error

Invalid template

Error message

Invalid template

What it means

Error building the system prompt in the agent thread: the SystemPromptTemplate could not be rendered (e.g. a required template placeholder is missing or the template file is malformed), so the request message construction for the LLM call cannot proceed.

Source

Thrown at crates/agent/src/thread.rs:4328

        messages
    }

    fn build_request_messages_until(
        &self,
        available_tools: Vec<SharedString>,
        end_ix: usize,
        cx: &App,
    ) -> Vec<LanguageModelRequestMessage> {
        let end_ix = end_ix.min(self.messages.len());
        log::trace!("Building request messages from {} thread messages", end_ix);

        let user_agents_md = UserAgentsMd::global(cx).and_then(|s| s.content().cloned());
        let system_prompt = SystemPromptTemplate {
            project: self.project_context.read(cx),
            available_tools,
            model_name: self.model().map(|m| m.name().0.to_string()),
            date: Local::now().format("%Y-%m-%d").to_string(),
            user_agents_md,
            sandboxing: crate::sandboxing::sandboxing_enabled_for_project(
                self.project.read(cx),
                cx,
            ),
            is_linux: cfg!(target_os = "linux"),
            is_windows: cfg!(target_os = "windows"),
        }
        .render(&self.templates)
        .context("failed to build system prompt")
        .expect("Invalid template");
        let mut messages = vec![LanguageModelRequestMessage {
            role: Role::System,
            content: vec![system_prompt.into()],
            cache: false,
            reasoning_details: None,
        }];
        self.extend_request_history_until(&mut messages, end_ix);

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Check the built-in system prompt template for missing or malformed placeholders
  2. Verify project context and available tools are populated before building the request
  3. Update the agent crate if the shipped template is out of sync with the code
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/agent/src/thread.rs:4327 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20). Data as JSON: /api/errors/bdd253cbb9cba80f. Report an issue: GitHub.