fix: always send full instructions when using the Responses API (#1207)
This fixes a longstanding error in the Rust CLI where `codex.rs` contained an errant `is_first_turn` check that would exclude the user instructions for subsequent "turns" of a conversation when using the responses API (i.e., when `previous_response_id` existed). While here, renames `Prompt.instructions` to `Prompt.user_instructions` since we now have quite a few levels of instructions floating around. Also removed an unnecessary use of `clone()` in `Prompt.get_full_instructions()`.
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct Prompt {
|
||||
pub prev_id: Option<String>,
|
||||
/// Optional instructions from the user to amend to the built-in agent
|
||||
/// instructions.
|
||||
pub instructions: Option<String>,
|
||||
pub user_instructions: Option<String>,
|
||||
/// Whether to store response on server side (disable_response_storage = !store).
|
||||
pub store: bool,
|
||||
|
||||
@@ -37,21 +37,14 @@ pub struct Prompt {
|
||||
|
||||
impl Prompt {
|
||||
pub(crate) fn get_full_instructions(&self, model: &str) -> Cow<str> {
|
||||
[
|
||||
Some(Cow::Borrowed(BASE_INSTRUCTIONS)),
|
||||
self.instructions.as_ref().map(|s| Cow::Owned(s.clone())),
|
||||
if model.starts_with("gpt-4.1") {
|
||||
Some(Cow::Borrowed(APPLY_PATCH_TOOL_INSTRUCTIONS))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
]
|
||||
.iter()
|
||||
.filter_map(|s| s.as_ref())
|
||||
.map(|cow| cow.as_ref())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
.into()
|
||||
let mut sections: Vec<&str> = vec![BASE_INSTRUCTIONS];
|
||||
if let Some(ref user) = self.user_instructions {
|
||||
sections.push(user);
|
||||
}
|
||||
if model.starts_with("gpt-4.1") {
|
||||
sections.push(APPLY_PATCH_TOOL_INSTRUCTIONS);
|
||||
}
|
||||
Cow::Owned(sections.join("\n"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user