parent
3590e181fa
commit
56d0c6bf67
3 changed files with 40 additions and 3 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue