mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Remove the unused agent extension crate (#63648)
## What changed Delete `codex-agent-extension`, whose `AgentRunner` submitted resolved agent prompts in forked legacy threads and was used only by the crate's integration test. Remove the test, the Bazel target, and the crate's Cargo workspace and lockfile entries. GitOrigin-RevId: 1e966ccb7b7f37f6cdd68882975bb1e940ae85db
This commit is contained in:
Generated
-12
@@ -1899,18 +1899,6 @@ dependencies = [
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codex-agent-extension"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"codex-core",
|
||||
"codex-protocol",
|
||||
"core_test_support",
|
||||
"pretty_assertions",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codex-agent-graph-store"
|
||||
version = "0.0.0"
|
||||
|
||||
@@ -66,7 +66,6 @@ members = [
|
||||
"exec-server/tests/support",
|
||||
"execpolicy",
|
||||
"execpolicy-rules",
|
||||
"ext/agent",
|
||||
"ext/agent-message-board",
|
||||
"ext/connectors",
|
||||
"ext/extension-api",
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
name = "agent",
|
||||
crate_name = "codex_agent_extension",
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
[package]
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
name = "codex-agent-extension"
|
||||
version.workspace = true
|
||||
|
||||
[lib]
|
||||
name = "codex_agent_extension"
|
||||
path = "src/lib.rs"
|
||||
doctest = false
|
||||
test = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
codex-core = { workspace = true }
|
||||
codex-protocol = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = { workspace = true }
|
||||
core_test_support = { workspace = true }
|
||||
pretty_assertions = { workspace = true }
|
||||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
|
||||
@@ -1,102 +0,0 @@
|
||||
use codex_core::CodexThread;
|
||||
use codex_core::NewThread;
|
||||
use codex_core::StartIfIdleSubmission;
|
||||
use codex_core::StartThreadOptions;
|
||||
use codex_core::ThreadManager;
|
||||
use codex_core::TurnInputRequest;
|
||||
use codex_core::config::Config;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::Result as CodexResult;
|
||||
use codex_protocol::protocol::W3cTraceContext;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Weak;
|
||||
|
||||
/// A fully resolved agent invocation.
|
||||
///
|
||||
/// Agent discovery owns rendering `prompt`, including any selected skill
|
||||
/// references. The runtime only starts that prompt in isolated forked context.
|
||||
pub struct AgentInvocation {
|
||||
pub config: Config,
|
||||
pub prompt: String,
|
||||
pub parent_trace: Option<W3cTraceContext>,
|
||||
}
|
||||
|
||||
/// A spawned agent whose initial turn has been submitted.
|
||||
pub struct AgentRun {
|
||||
pub thread_id: ThreadId,
|
||||
pub turn_id: String,
|
||||
pub thread: Arc<CodexThread>,
|
||||
}
|
||||
|
||||
/// Runs resolved agents in legacy threads forked by the owning [`ThreadManager`].
|
||||
#[derive(Clone)]
|
||||
pub struct AgentRunner {
|
||||
thread_manager: Weak<ThreadManager>,
|
||||
}
|
||||
|
||||
impl AgentRunner {
|
||||
pub fn new(thread_manager: Weak<ThreadManager>) -> Self {
|
||||
Self { thread_manager }
|
||||
}
|
||||
|
||||
/// Starts a resolved agent in a fork of a legacy `parent_thread_id`.
|
||||
///
|
||||
/// Paginated parents are rejected by [`ThreadManager::spawn_legacy_subagent`].
|
||||
pub async fn start(
|
||||
&self,
|
||||
parent_thread_id: ThreadId,
|
||||
invocation: AgentInvocation,
|
||||
) -> CodexResult<AgentRun> {
|
||||
let AgentInvocation {
|
||||
config,
|
||||
prompt,
|
||||
parent_trace,
|
||||
} = invocation;
|
||||
if prompt.trim().is_empty() {
|
||||
return Err(CodexErr::InvalidRequest(
|
||||
"agent prompt must not be empty".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let thread_manager = self
|
||||
.thread_manager
|
||||
.upgrade()
|
||||
.ok_or_else(|| CodexErr::UnsupportedOperation("thread manager dropped".to_string()))?;
|
||||
let NewThread {
|
||||
thread_id, thread, ..
|
||||
} = thread_manager
|
||||
.spawn_legacy_subagent(
|
||||
parent_thread_id,
|
||||
StartThreadOptions {
|
||||
parent_trace: parent_trace.clone(),
|
||||
..StartThreadOptions::new(config)
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
let turn_id = match thread
|
||||
.start_turn_if_idle(
|
||||
TurnInputRequest::user_input(vec![UserInput::Text {
|
||||
text: prompt,
|
||||
text_elements: Vec::new(),
|
||||
}])
|
||||
.with_trace(parent_trace),
|
||||
)
|
||||
.await?
|
||||
{
|
||||
StartIfIdleSubmission::Started { turn_id, .. } => turn_id,
|
||||
StartIfIdleSubmission::NotSubmitted { reason } => {
|
||||
return Err(CodexErr::InvalidRequest(format!(
|
||||
"agent prompt was not submitted: {reason:?}"
|
||||
)));
|
||||
}
|
||||
};
|
||||
|
||||
Ok(AgentRun {
|
||||
thread_id,
|
||||
turn_id,
|
||||
thread,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
use anyhow::Result;
|
||||
use codex_agent_extension::AgentInvocation;
|
||||
use codex_agent_extension::AgentRunner;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::skip_if_no_network;
|
||||
use core_test_support::test_codex::test_codex;
|
||||
use core_test_support::wait_for_event;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn starts_resolved_agent_prompt_in_forked_thread() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let response_mock = responses::mount_sse_once(
|
||||
&server,
|
||||
responses::sse(vec![
|
||||
responses::ev_response_created("agent-response"),
|
||||
responses::ev_completed("agent-response"),
|
||||
]),
|
||||
)
|
||||
.await;
|
||||
let test = test_codex().build_with_auto_env(&server).await?;
|
||||
let parent_thread_id = test.session_configured.session_id.into();
|
||||
let agent_runner = AgentRunner::new(std::sync::Arc::downgrade(&test.thread_manager));
|
||||
|
||||
let agent_run = agent_runner
|
||||
.start(
|
||||
parent_thread_id,
|
||||
AgentInvocation {
|
||||
config: test.config.clone(),
|
||||
prompt: "Use $example-agent to inspect the current changes.".to_string(),
|
||||
parent_trace: None,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert_ne!(agent_run.thread_id, parent_thread_id);
|
||||
assert_eq!(
|
||||
agent_run
|
||||
.thread
|
||||
.config_snapshot()
|
||||
.await
|
||||
.forked_from_thread_id,
|
||||
Some(parent_thread_id)
|
||||
);
|
||||
let started = wait_for_event(&agent_run.thread, |event| {
|
||||
matches!(event, EventMsg::TurnStarted(_))
|
||||
})
|
||||
.await;
|
||||
let EventMsg::TurnStarted(started) = started else {
|
||||
unreachable!("event predicate only matches turn started events");
|
||||
};
|
||||
assert_eq!(started.turn_id, agent_run.turn_id);
|
||||
wait_for_event(&agent_run.thread, |event| {
|
||||
matches!(event, EventMsg::TurnComplete(_))
|
||||
})
|
||||
.await;
|
||||
|
||||
let request = response_mock.single_request();
|
||||
assert!(
|
||||
request
|
||||
.message_input_texts("user")
|
||||
.iter()
|
||||
.any(|text| text == "Use $example-agent to inspect the current changes.")
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user