Add apply_patch code mode result (#15100)

It's empty !
This commit is contained in:
pakrym-oai 2026-03-18 16:11:10 -07:00 committed by GitHub
parent 3590e181fa
commit 56d0c6bf67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 3 deletions

View file

@ -199,6 +199,41 @@ impl ToolOutput for FunctionToolOutput {
}
}
pub struct ApplyPatchToolOutput {
pub text: String,
}
impl ApplyPatchToolOutput {
pub fn from_text(text: String) -> Self {
Self { text }
}
}
impl ToolOutput for ApplyPatchToolOutput {
fn log_preview(&self) -> String {
telemetry_preview(&self.text)
}
fn success_for_logging(&self) -> bool {
true
}
fn to_response_item(&self, call_id: &str, payload: &ToolPayload) -> ResponseInputItem {
function_tool_response(
call_id,
payload,
vec![FunctionCallOutputContentItem::InputText {
text: self.text.clone(),
}],
Some(true),
)
}
fn code_mode_result(&self, _payload: &ToolPayload) -> JsonValue {
JsonValue::Object(serde_json::Map::new())
}
}
pub struct AbortedToolOutput {
pub message: String,
}

View file

@ -13,6 +13,7 @@ use crate::codex::TurnContext;
use crate::function_tool::FunctionCallError;
use crate::sandboxing::effective_file_system_sandbox_policy;
use crate::sandboxing::merge_permission_profiles;
use crate::tools::context::ApplyPatchToolOutput;
use crate::tools::context::FunctionToolOutput;
use crate::tools::context::SharedTurnDiffTracker;
use crate::tools::context::ToolInvocation;
@ -125,7 +126,7 @@ async fn effective_patch_permissions(
#[async_trait]
impl ToolHandler for ApplyPatchHandler {
type Output = FunctionToolOutput;
type Output = ApplyPatchToolOutput;
fn kind(&self) -> ToolKind {
ToolKind::Function
@ -179,7 +180,7 @@ impl ToolHandler for ApplyPatchHandler {
{
InternalApplyPatchInvocation::Output(item) => {
let content = item?;
Ok(FunctionToolOutput::from_text(content, Some(true)))
Ok(ApplyPatchToolOutput::from_text(content))
}
InternalApplyPatchInvocation::DelegateToExec(apply) => {
let changes = convert_apply_patch_to_protocol(&apply.action);
@ -233,7 +234,7 @@ impl ToolHandler for ApplyPatchHandler {
Some(&tracker),
);
let content = emitter.finish(event_ctx, out).await?;
Ok(FunctionToolOutput::from_text(content, Some(true)))
Ok(ApplyPatchToolOutput::from_text(content))
}
}
}

View file

@ -1911,6 +1911,7 @@ async fn code_mode_can_apply_patch_via_nested_tool() -> Result<()> {
),
text_item(&items, 0),
);
assert_eq!(text_item(&items, 1), "{}");
let file_path = test.cwd_path().join(file_name);
assert_eq!(fs::read_to_string(&file_path)?, "hello from code_mode\n");