mirror of
https://github.com/openai/codex.git
synced 2026-11-20 07:06:24 +00:00
Add TUI tools for managing Codex tasks (#40308)
## Why The TUI rejected app-server dynamic tool calls as unsupported, so agents could not inspect or manage other Codex tasks through a TUI session. ## What changed - Add the `codex_tui` tool namespace for listing, reading, waiting on, creating, forking, messaging, renaming, archiving, and restoring tasks. - Handle tool calls through existing app-server thread operations, with bounded inputs and responses and cleanup when calls complete or the TUI disconnects. - Route delegation tools through an authenticated local MCP server with explicit approval prompts, while respecting configured and managed MCP policies. - Fall back to starting threads without dynamic tools when connected to an older app server that does not support them. ## Testing Add coverage for tool schemas and response bounds, task lifecycle operations, approval-gated MCP transport, namespace dispatch, cancellation, and legacy app-server fallback behavior. GitOrigin-RevId: c782c11f0a3edceb3fa6909a4b92d6ce01a6eed3
This commit is contained in:
1 parent
fb0781b9ee
commit
a8468330bb
18 files changed
+3722
-62
No files matched your search
@@ -5018,7 +5018,7 @@ async fn discard_side_thread_keeps_local_state_when_server_close_fails() -> Resu
|
||||
|
||||
#[tokio::test]
|
||||
async fn background_side_cleanup_removes_local_state_and_ignores_late_events() -> Result<()> {
|
||||
let mut app = make_test_app().await;
|
||||
let (mut app, mut events, _ops) = make_test_app_with_channels().await;
|
||||
let mut app_server =
|
||||
crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref()).await?;
|
||||
let parent_thread_id = ThreadId::new();
|
||||
@@ -5034,9 +5034,21 @@ async fn background_side_cleanup_removes_local_state_and_ignores_late_events() -
|
||||
Some("side".to_string()),
|
||||
/*is_closed*/ false,
|
||||
);
|
||||
app.dynamic_tool_tasks.insert(
|
||||
AppServerRequestId::Integer(123),
|
||||
(
|
||||
side_thread_id.to_string(),
|
||||
tokio::spawn(std::future::pending::<()>()),
|
||||
),
|
||||
);
|
||||
app.discard_side_thread_in_background(&mut app_server, side_thread_id)
|
||||
.await;
|
||||
|
||||
assert_matches!(
|
||||
events.try_recv(),
|
||||
Ok(AppEvent::DynamicToolCallCompleted { response, .. }) if !response.success
|
||||
);
|
||||
assert!(app.dynamic_tool_tasks.is_empty());
|
||||
assert_eq!(app.active_thread_id, Some(parent_thread_id));
|
||||
assert!(!app.side_threads.contains_key(&side_thread_id));
|
||||
assert!(!app.thread_event_channels.contains_key(&side_thread_id));
|
||||
@@ -5413,6 +5425,8 @@ async fn make_test_app() -> App {
|
||||
primary_session_configured: None,
|
||||
pending_primary_events: VecDeque::new(),
|
||||
pending_app_server_requests: PendingAppServerRequests::default(),
|
||||
dynamic_tool_status_updates: tokio::sync::broadcast::channel(/*capacity*/ 64).0,
|
||||
dynamic_tool_tasks: HashMap::new(),
|
||||
pending_startup_thread_start: false,
|
||||
startup_protected_input_boundary: false,
|
||||
startup_pending_protected_request: false,
|
||||
@@ -5490,6 +5504,8 @@ async fn make_test_app_with_channels() -> (
|
||||
primary_session_configured: None,
|
||||
pending_primary_events: VecDeque::new(),
|
||||
pending_app_server_requests: PendingAppServerRequests::default(),
|
||||
dynamic_tool_status_updates: tokio::sync::broadcast::channel(/*capacity*/ 64).0,
|
||||
dynamic_tool_tasks: HashMap::new(),
|
||||
pending_startup_thread_start: false,
|
||||
startup_protected_input_boundary: false,
|
||||
startup_pending_protected_request: false,
|
||||
|
||||
Reference in new issue
Block a user