Don't require prompt in headless mode for recipes (#2403)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Douwe Osinga
2025-05-02 12:20:29 -04:00
committed by GitHub
parent ca8be0ac8d
commit 2366a3ad01
2 changed files with 11 additions and 6 deletions

View File

@@ -504,7 +504,7 @@ pub async fn cli() -> Result<()> {
InputConfig {
contents: recipe.prompt,
extensions_override: recipe.extensions,
additional_system_prompt: Some(recipe.instructions),
additional_system_prompt: recipe.instructions,
}
}
(None, None, None) => {

View File

@@ -41,7 +41,7 @@ fn default_version() -> String {
/// version: "1.0.0".to_string(),
/// title: "Example Agent".to_string(),
/// description: "An example Recipe configuration".to_string(),
/// instructions: "Act as a helpful assistant".to_string(),
/// instructions: Some("Act as a helpful assistant".to_string()),
/// prompt: None,
/// extensions: None,
/// context: None,
@@ -59,9 +59,11 @@ pub struct Recipe {
pub description: String, // a longer description of the recipe
pub instructions: String, // the instructions for the model
// Optional fields
// Note: at least one of instructions or prompt need to be set
#[serde(skip_serializing_if = "Option::is_none")]
pub instructions: Option<String>, // the instructions for the model
#[serde(skip_serializing_if = "Option::is_none")]
pub prompt: Option<String>, // the prompt to start the session with
@@ -193,13 +195,16 @@ impl RecipeBuilder {
pub fn build(self) -> Result<Recipe, &'static str> {
let title = self.title.ok_or("Title is required")?;
let description = self.description.ok_or("Description is required")?;
let instructions = self.instructions.ok_or("Instructions are required")?;
if self.instructions.is_none() && self.prompt.is_none() {
return Err("At least one of 'prompt' or 'instructions' is required");
}
Ok(Recipe {
version: self.version,
title,
description,
instructions,
instructions: self.instructions,
prompt: self.prompt,
extensions: self.extensions,
context: self.context,