openai/codex · critical
collaboration mode default template must parse: {err}
Error message
collaboration mode default template must parse: {err} What it means
A process-aborting panic raised from a LazyLock the first time the embedded default collaboration-mode prompt template is parsed. The template is the compile-time constant codex_collaboration_mode_templates::DEFAULT, so a parse failure means the shipped template text itself is malformed -- a broken crate-level invariant, not something user input or runtime state can trigger. It fires on the first code path that touches COLLABORATION_MODE_DEFAULT_TEMPLATE, i.e. builtin_collaboration_mode_presets()/default_mode_instructions() in codex-rs/models-manager/src/collaboration_mode_presets.rs.
Source
Thrown at codex-rs/models-manager/src/collaboration_mode_presets.rs:13
use codex_collaboration_mode_templates::DEFAULT as COLLABORATION_MODE_DEFAULT;
use codex_collaboration_mode_templates::PLAN as COLLABORATION_MODE_PLAN;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::TUI_VISIBLE_COLLABORATION_MODES;
use codex_protocol::openai_models::ReasoningEffort;
use codex_utils_template::Template;
use std::sync::LazyLock;
const KNOWN_MODE_NAMES_TEMPLATE_KEY: &str = "KNOWN_MODE_NAMES";
static COLLABORATION_MODE_DEFAULT_TEMPLATE: LazyLock<Template> = LazyLock::new(|| {
Template::parse(COLLABORATION_MODE_DEFAULT)
.unwrap_or_else(|err| panic!("collaboration mode default template must parse: {err}"))
});
pub fn builtin_collaboration_mode_presets() -> Vec<CollaborationModeMask> {
vec![plan_preset(), default_preset()]
}
fn plan_preset() -> CollaborationModeMask {
CollaborationModeMask {
name: ModeKind::Plan.display_name().to_string(),
mode: Some(ModeKind::Plan),
model: None,
reasoning_effort: Some(Some(ReasoningEffort::Medium)),
developer_instructions: Some(Some(COLLABORATION_MODE_PLAN.to_string())),
}
}
fn default_preset() -> CollaborationModeMask {
CollaborationModeMask {View on GitHub (pinned to 339751715c)
Solutions
- Revert or fix the malformed syntax in codex-collaboration-mode-templates::DEFAULT until Template::parse succeeds -- the panic message embeds the parser error showing what failed.
- Run the crate's existing preset tests (collaboration_mode_presets_tests.rs) which exercise parse+render of the default template before the panic can reach users.
- If it appeared after a dependency bump, check codex-utils-template's changelog for grammar changes and migrate the template text.
Example fix
// before: template edited with an unbalanced placeholder, parse fails at first use
// const DEFAULT: &str = "... {{KNOWN_MODE_NAMES ..."; // never closed
// after: well-formed placeholder, guarded by a render test
// const DEFAULT: &str = "... {{KNOWN_MODE_NAMES}} ...";
#[test]
fn default_template_parses_and_renders() {
let template = Template::parse(COLLABORATION_MODE_DEFAULT).expect("must parse");
template
.render([(KNOWN_MODE_NAMES_TEMPLATE_KEY, "Plan and Default")])
.expect("must render");
} Defensive patterns
Strategy: validation
Validate before calling
// CI guard: fail at test time, not at first user request
#[test]
fn default_template_parses_and_renders() {
let template = Template::parse(COLLABORATION_MODE_DEFAULT).expect("must parse");
template
.render([(KNOWN_MODE_NAMES_TEMPLATE_KEY, "Plan and Default")])
.expect("must render");
} Try / catch
Not catchable as an io::Error: this is a panic inside a LazyLock. Only std::panic::catch_unwind at a thread boundary could intercept it; treat the message as a broken build invariant and fix the template instead of handling it.
Prevention
- Run the models-manager preset tests after every edit to the DEFAULT/PLAN template constants.
- Keep placeholder names in template text synchronized with the KNOWN_MODE_NAMES_TEMPLATE_KEY constant.
- Never assemble the default template from runtime input; it is a static invariant by design.
When it happens
Trigger: Editing the DEFAULT template constant and introducing invalid template syntax (unbalanced or malformed placeholder delimiters), then building any binary that renders the builtin collaboration-mode presets. Template::parse returns Err and the unwrap_or_else panics with the parser error appended to the message.
Common situations: Prompt-template editing sessions where delimiters get unbalanced; a codex-utils-template upgrade that changes the template grammar; renaming a placeholder without updating its paired key constant.
Related errors
- collaboration mode default template must render: {err}
- plugin cache root should be absolute: {err}
- pid-managed app-server shutdown is unsupported on this platf
- pid-managed updater shutdown is unsupported on this platform
- failed to read start time for pid-managed app server {pid}
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/3fe2017549b4605a.
Report an issue: GitHub.