feat: add multi-actions to presentation tool (#13357)

This commit is contained in:
jif-oai
2026-03-03 14:37:26 +00:00
committed by GitHub
Unverified
parent ad393fa753
commit 1df040e62b
8 changed files with 262 additions and 55 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ use async_channel::Sender;
use chrono::Local;
use chrono::Utc;
use codex_artifact_presentation::PresentationArtifactError;
use codex_artifact_presentation::PresentationArtifactRequest;
use codex_artifact_presentation::PresentationArtifactExecutionRequest;
use codex_artifact_presentation::PresentationArtifactResponse;
use codex_hooks::HookEvent;
use codex_hooks::HookEventAfterAgent;
@@ -1782,11 +1782,11 @@ impl Session {
pub(crate) async fn execute_presentation_artifact(
&self,
request: PresentationArtifactRequest,
request: PresentationArtifactExecutionRequest,
cwd: &Path,
) -> Result<PresentationArtifactResponse, PresentationArtifactError> {
let mut state = self.state.lock().await;
state.presentation_artifacts.execute(request, cwd)
state.presentation_artifacts.execute_requests(request, cwd)
}
async fn record_initial_history(&self, conversation_history: InitialHistory) {
@@ -2,7 +2,7 @@ use async_trait::async_trait;
use codex_artifact_presentation::PathAccessKind;
use codex_artifact_presentation::PathAccessRequirement;
use codex_artifact_presentation::PresentationArtifactError;
use codex_artifact_presentation::PresentationArtifactRequest;
use codex_artifact_presentation::PresentationArtifactToolRequest;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::ReviewDecision;
use serde_json::to_string;
@@ -37,23 +37,10 @@ impl ToolHandler for PresentationArtifactHandler {
let ToolPayload::Function { arguments } = &invocation.payload else {
return true;
};
let Ok(request) = parse_arguments::<PresentationArtifactRequest>(arguments) else {
let Ok(request) = parse_arguments::<PresentationArtifactToolRequest>(arguments) else {
return true;
};
!matches!(
request.action.as_str(),
"get_summary"
| "list_slides"
| "list_layouts"
| "list_layout_placeholders"
| "list_slide_placeholders"
| "inspect"
| "resolve"
| "to_proto"
| "get_style"
| "describe_styles"
| "record_patch"
)
request.is_mutating().unwrap_or(true)
}
async fn handle(&self, invocation: ToolInvocation) -> Result<ToolOutput, FunctionCallError> {
@@ -80,7 +67,7 @@ impl ToolHandler for PresentationArtifactHandler {
}
};
let request: PresentationArtifactRequest = parse_arguments(&arguments)?;
let request: PresentationArtifactToolRequest = parse_arguments(&arguments)?;
for access in request
.required_path_accesses(&turn.cwd)
.map_err(presentation_error)?
@@ -89,7 +76,12 @@ impl ToolHandler for PresentationArtifactHandler {
}
let response = session
.execute_presentation_artifact(request, &turn.cwd)
.execute_presentation_artifact(
request
.into_execution_request()
.map_err(presentation_error)?,
&turn.cwd,
)
.await
.map_err(presentation_error)?;
+27 -12
View File
@@ -567,6 +567,26 @@ fn create_view_image_tool() -> ToolSpec {
}
fn create_presentation_artifact_tool() -> ToolSpec {
let action_step_schema = JsonSchema::Object {
properties: BTreeMap::from([
(
"action".to_string(),
JsonSchema::String {
description: Some("Action name to run for this step.".to_string()),
},
),
(
"args".to_string(),
JsonSchema::Object {
properties: BTreeMap::new(),
required: None,
additional_properties: Some(true.into()),
},
),
]),
required: Some(vec!["action".to_string(), "args".to_string()]),
additional_properties: Some(false.into()),
};
let properties = BTreeMap::from([
(
"artifact_id".to_string(),
@@ -577,17 +597,12 @@ fn create_presentation_artifact_tool() -> ToolSpec {
},
),
(
"action".to_string(),
JsonSchema::String {
description: Some("Action name to run against the artifact.".to_string()),
},
),
(
"args".to_string(),
JsonSchema::Object {
properties: BTreeMap::new(),
required: None,
additional_properties: Some(true.into()),
"actions".to_string(),
JsonSchema::Array {
items: Box::new(action_step_schema),
description: Some(
"Array of `(action, args)` steps to execute sequentially.".to_string(),
),
},
),
]);
@@ -598,7 +613,7 @@ fn create_presentation_artifact_tool() -> ToolSpec {
strict: false,
parameters: JsonSchema::Object {
properties,
required: Some(vec!["action".to_string(), "args".to_string()]),
required: Some(vec!["actions".to_string()]),
additional_properties: Some(false.into()),
},
})