mirror of
https://github.com/openai/codex.git
synced 2026-11-10 21:00:47 +00:00
Remove agent job resume tool
This commit is contained in:
@@ -22,7 +22,6 @@ use once_cell::sync::Lazy;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
@@ -61,13 +60,6 @@ struct JobIdArgs {
|
||||
job_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RunAgentJobArgs {
|
||||
job_id: String,
|
||||
max_concurrency: Option<usize>,
|
||||
auto_export: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct WaitAgentJobArgs {
|
||||
job_id: String,
|
||||
@@ -165,7 +157,6 @@ impl ToolHandler for AgentJobsHandler {
|
||||
|
||||
match tool_name.as_str() {
|
||||
"spawn_agents_on_csv" => spawn_agents_on_csv::handle(session, turn, arguments).await,
|
||||
"run_agent_job" => run_agent_job::handle(session, turn, arguments).await,
|
||||
"get_agent_job_status" => get_agent_job_status::handle(session, arguments).await,
|
||||
"wait_agent_job" => wait_agent_job::handle(session, arguments).await,
|
||||
"export_agent_job_csv" => export_agent_job_csv::handle(session, turn, arguments).await,
|
||||
@@ -311,60 +302,6 @@ mod spawn_agents_on_csv {
|
||||
}
|
||||
}
|
||||
|
||||
mod run_agent_job {
|
||||
use super::*;
|
||||
|
||||
pub async fn handle(
|
||||
session: Arc<Session>,
|
||||
turn: Arc<TurnContext>,
|
||||
arguments: String,
|
||||
) -> Result<ToolOutput, FunctionCallError> {
|
||||
let args: RunAgentJobArgs = parse_arguments(arguments.as_str())?;
|
||||
let job_id = args.job_id;
|
||||
let db = required_state_db(&session)?;
|
||||
let job = db
|
||||
.get_agent_job(job_id.as_str())
|
||||
.await
|
||||
.map_err(|err| {
|
||||
FunctionCallError::RespondToModel(format!(
|
||||
"failed to load agent job {job_id}: {err}"
|
||||
))
|
||||
})?
|
||||
.ok_or_else(|| {
|
||||
FunctionCallError::RespondToModel(format!("agent job {job_id} not found"))
|
||||
})?;
|
||||
if !job_runner_active(job_id.as_str()).await {
|
||||
db.reset_agent_job_running_items(job_id.as_str())
|
||||
.await
|
||||
.map_err(|err| {
|
||||
FunctionCallError::RespondToModel(format!(
|
||||
"failed to reset running items for agent job {job_id}: {err}"
|
||||
))
|
||||
})?;
|
||||
}
|
||||
let options = build_runner_options(
|
||||
&session,
|
||||
&turn,
|
||||
args.max_concurrency,
|
||||
args.auto_export.or(Some(job.auto_export)),
|
||||
)
|
||||
.await?;
|
||||
let started = start_job_runner(session, job_id.clone(), options).await?;
|
||||
let status = render_job_status(db, job_id.as_str()).await?;
|
||||
let content = serde_json::to_string(&json!({
|
||||
"started": started,
|
||||
"status": status,
|
||||
}))
|
||||
.map_err(|err| {
|
||||
FunctionCallError::Fatal(format!("failed to serialize run_agent_job result: {err}"))
|
||||
})?;
|
||||
Ok(ToolOutput::Function {
|
||||
body: FunctionCallOutputBody::Text(content),
|
||||
success: Some(true),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
mod get_agent_job_status {
|
||||
use super::*;
|
||||
|
||||
@@ -1194,6 +1131,7 @@ fn csv_escape(value: &str) -> String {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn parse_csv_supports_quotes_and_commas() {
|
||||
|
||||
@@ -556,44 +556,6 @@ fn create_spawn_agents_on_csv_tool() -> ToolSpec {
|
||||
})
|
||||
}
|
||||
|
||||
fn create_run_agent_job_tool() -> ToolSpec {
|
||||
let mut properties = BTreeMap::new();
|
||||
properties.insert(
|
||||
"job_id".to_string(),
|
||||
JsonSchema::String {
|
||||
description: Some("Identifier of the job to resume.".to_string()),
|
||||
},
|
||||
);
|
||||
properties.insert(
|
||||
"max_concurrency".to_string(),
|
||||
JsonSchema::Number {
|
||||
description: Some(
|
||||
"Maximum concurrent workers for this job. Defaults to 64 and is capped by config."
|
||||
.to_string(),
|
||||
),
|
||||
},
|
||||
);
|
||||
properties.insert(
|
||||
"auto_export".to_string(),
|
||||
JsonSchema::Boolean {
|
||||
description: Some(
|
||||
"Whether to auto-export CSV output on successful completion (default true)."
|
||||
.to_string(),
|
||||
),
|
||||
},
|
||||
);
|
||||
ToolSpec::Function(ResponsesApiTool {
|
||||
name: "run_agent_job".to_string(),
|
||||
description: "Resume execution of an existing agent job.".to_string(),
|
||||
strict: false,
|
||||
parameters: JsonSchema::Object {
|
||||
properties,
|
||||
required: Some(vec!["job_id".to_string()]),
|
||||
additional_properties: Some(false.into()),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fn create_get_agent_job_status_tool() -> ToolSpec {
|
||||
let mut properties = BTreeMap::new();
|
||||
properties.insert(
|
||||
@@ -1614,13 +1576,11 @@ pub(crate) fn build_specs(
|
||||
if config.collab_tools {
|
||||
let agent_jobs_handler = Arc::new(AgentJobsHandler);
|
||||
builder.push_spec(create_spawn_agents_on_csv_tool());
|
||||
builder.push_spec(create_run_agent_job_tool());
|
||||
builder.push_spec(create_get_agent_job_status_tool());
|
||||
builder.push_spec(create_wait_agent_job_tool());
|
||||
builder.push_spec(create_export_agent_job_csv_tool());
|
||||
builder.push_spec(create_report_agent_job_result_tool());
|
||||
builder.register_handler("spawn_agents_on_csv", agent_jobs_handler.clone());
|
||||
builder.register_handler("run_agent_job", agent_jobs_handler.clone());
|
||||
builder.register_handler("get_agent_job_status", agent_jobs_handler.clone());
|
||||
builder.register_handler("wait_agent_job", agent_jobs_handler.clone());
|
||||
builder.register_handler("export_agent_job_csv", agent_jobs_handler.clone());
|
||||
@@ -1885,7 +1845,6 @@ mod tests {
|
||||
"wait",
|
||||
"close_agent",
|
||||
"spawn_agents_on_csv",
|
||||
"run_agent_job",
|
||||
"get_agent_job_status",
|
||||
"wait_agent_job",
|
||||
"export_agent_job_csv",
|
||||
|
||||
Reference in New Issue
Block a user