Skip to content

Commit ef8756a

Browse files
authored
Merge branch 'main' into add-github-action-for-nix
2 parents 4ac625c + 7bff8df commit ef8756a

File tree

11 files changed

+289
-559
lines changed

11 files changed

+289
-559
lines changed

codex-rs/core/src/apply_patch.rs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use crate::codex::Session;
22
use crate::codex::TurnContext;
3+
use crate::function_tool::FunctionCallError;
34
use crate::protocol::FileChange;
45
use crate::protocol::ReviewDecision;
56
use crate::safety::SafetyCheck;
67
use crate::safety::assess_patch_safety;
78
use codex_apply_patch::ApplyPatchAction;
89
use codex_apply_patch::ApplyPatchFileChange;
9-
use codex_protocol::models::FunctionCallOutputPayload;
10-
use codex_protocol::models::ResponseInputItem;
1110
use std::collections::HashMap;
1211
use std::path::PathBuf;
1312

@@ -17,7 +16,7 @@ pub(crate) enum InternalApplyPatchInvocation {
1716
/// The `apply_patch` call was handled programmatically, without any sort
1817
/// of sandbox, because the user explicitly approved it. This is the
1918
/// result to use with the `shell` function call that contained `apply_patch`.
20-
Output(ResponseInputItem),
19+
Output(Result<String, FunctionCallError>),
2120

2221
/// The `apply_patch` call was approved, either automatically because it
2322
/// appears that it should be allowed based on the user's sandbox policy
@@ -33,12 +32,6 @@ pub(crate) struct ApplyPatchExec {
3332
pub(crate) user_explicitly_approved_this_action: bool,
3433
}
3534

36-
impl From<ResponseInputItem> for InternalApplyPatchInvocation {
37-
fn from(item: ResponseInputItem) -> Self {
38-
InternalApplyPatchInvocation::Output(item)
39-
}
40-
}
41-
4235
pub(crate) async fn apply_patch(
4336
sess: &Session,
4437
turn_context: &TurnContext,
@@ -77,25 +70,15 @@ pub(crate) async fn apply_patch(
7770
})
7871
}
7972
ReviewDecision::Denied | ReviewDecision::Abort => {
80-
ResponseInputItem::FunctionCallOutput {
81-
call_id: call_id.to_owned(),
82-
output: FunctionCallOutputPayload {
83-
content: "patch rejected by user".to_string(),
84-
success: Some(false),
85-
},
86-
}
87-
.into()
73+
InternalApplyPatchInvocation::Output(Err(FunctionCallError::RespondToModel(
74+
"patch rejected by user".to_string(),
75+
)))
8876
}
8977
}
9078
}
91-
SafetyCheck::Reject { reason } => ResponseInputItem::FunctionCallOutput {
92-
call_id: call_id.to_owned(),
93-
output: FunctionCallOutputPayload {
94-
content: format!("patch rejected: {reason}"),
95-
success: Some(false),
96-
},
97-
}
98-
.into(),
79+
SafetyCheck::Reject { reason } => InternalApplyPatchInvocation::Output(Err(
80+
FunctionCallError::RespondToModel(format!("patch rejected: {reason}")),
81+
)),
9982
}
10083
}
10184

0 commit comments

Comments
 (0)