zed-industries/zed · error
Cannot format prompt for {:?}
Error message
Cannot format prompt for {:?} What it means
format_prompt_for_example matches on the requested PredictionProvider to pick a prompt formatter. Teacher/TeacherNonBatching, TeacherJumps/TeacherJumpsNonBatching, and Zeta2 have formatting paths; every other variant (the client-side inference providers) has no prompt format defined, so the `_` arm panics with the provider value. It is an explicit unsupported-provider assertion, not a runtime failure.
Source
Thrown at crates/edit_prediction_cli/src/format_prompt.rs:137
expected_cursor_offset,
)
.ok()
});
let rejected_output = example.spec.rejected_patch.as_ref().and_then(|patch| {
format_expected_output(prompt_inputs, zeta_format, patch, None).ok()
});
example.prompt = prompt.map(|prompt| ExamplePrompt {
input: prompt,
expected_output,
rejected_output,
provider: args.provider,
prefill: Some(prefill),
});
}
_ => {
panic!("Cannot format prompt for {:?}", args.provider);
}
};
Ok(())
}
pub struct TeacherPrompt;
impl TeacherPrompt {
pub(crate) const EDITABLE_REGION_START: &str = "<|editable_region_start|>\n";
pub(crate) const EDITABLE_REGION_END: &str = "\n<|editable_region_end|>";
pub(crate) const USER_CURSOR_MARKER: &str = "<|user_cursor|>";
pub(crate) const NO_EDITS: &str = "NO_EDITS";
/// Truncate edit history to this number of last lines
const MAX_HISTORY_LINES: usize = 128;
pub fn format_prompt(
example: &Example,View on GitHub (pinned to f4178619ac)
Solutions
- Use a provider that supports formatting: teacher, teacher-non-batching, teacher-jumps, teacher-jumps-non-batching, or zeta2
- If you added a new PredictionProvider variant, implement a formatting arm in the match at crates/edit_prediction_cli/src/format_prompt.rs:68
- Preferably return an anyhow error (`bail!`) for unsupported providers instead of panicking so the CLI reports it cleanly
Example fix
// before
let args = FormatPromptArgs { provider: PredictionProvider::Zeta(..), .. }; // panic: Cannot format prompt
// after
let args = FormatPromptArgs { provider: PredictionProvider::Zeta2(..), .. }; Defensive patterns
Strategy: validation
Validate before calling
let supports_formatting = matches!(
args.provider,
PredictionProvider::Teacher(..)
| PredictionProvider::TeacherNonBatching(..)
| PredictionProvider::TeacherJumps(..)
| PredictionProvider::TeacherJumpsNonBatching(..)
| PredictionProvider::Zeta2(..)
);
anyhow::ensure!(supports_formatting, "provider does not support formatting: {:?}", args.provider); Type guard
fn supports_prompt_formatting(provider: &PredictionProvider) -> bool {
matches!(
provider,
PredictionProvider::Teacher(..)
| PredictionProvider::TeacherNonBatching(..)
| PredictionProvider::TeacherJumps(..)
| PredictionProvider::TeacherJumpsNonBatching(..)
| PredictionProvider::Zeta2(..)
)
} Prevention
- When adding a PredictionProvider variant, extend the match in format_prompt.rs in the same change
- Prefer returning anyhow errors for unsupported combinations instead of panics in CLI paths
- Document which subcommands accept which providers
When it happens
Trigger: Running the format-prompt step with a provider flag that only supports inference (e.g. the zeta client provider) instead of teacher/teacher-jumps/zeta2 variants; or adding a new PredictionProvider variant without extending this match.
Common situations: Copying a `--provider` value from another subcommand that accepts inference providers; introducing a new provider enum variant and forgetting format_prompt.rs.
Related errors
- {} has invalid example extension `{ext}`
- --in-place requires exactly one input file
- output dir is required
- Fatal error: {:?}
- prompt file not found: {name}
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/ec3542701948bde7.
Report an issue: GitHub.