mirror of
https://github.com/openai/codex.git
synced 2026-11-11 21:10:39 +00:00
Render host-owned V2 subagent rosters in environment context (#59531)
## What changed - Expose `AgentSessionReader` and `AgentRef` for read-only access to host-owned agent session membership. - Read direct children when rendering V2 environment context, using the existing roster size limits. Refresh membership when rebuilding context after compaction, and omit the roster if the provider is absent or the read fails. - Preserve unrecorded initial input across suspension or interruption while waiting for a roster read. Resolve the roster before advancing the compaction window. ## Testing Add coverage for roster refreshes after compaction, unchanged environments avoiding extra reads, unavailable rosters, recoverable input during blocked reads, and stale compaction results rejected after a concurrent history replacement. GitOrigin-RevId: 3c7e3822af09e9295d405e53dabb87b020c8f00c
This commit is contained in:
@@ -61,7 +61,7 @@ pub(super) async fn admit(
|
||||
.filter(|_| !cancellation.is_cancelled())
|
||||
.ok_or_else(|| CodexErr::new(CodexErrorDetails::TurnAborted))?;
|
||||
task._agent_execution_guard = Some(guard);
|
||||
task.pending_admission_input.take().ok_or_else(|| {
|
||||
task.pending_initial_input.take().ok_or_else(|| {
|
||||
CodexErr::Fatal("initial input missing from the task awaiting host admission".into())
|
||||
})
|
||||
}
|
||||
@@ -77,7 +77,7 @@ impl Session {
|
||||
}
|
||||
|
||||
/// Interruption and suspension stop the task before it can persist its initial input.
|
||||
pub(crate) async fn record_unadmitted_input(
|
||||
pub(crate) async fn record_pending_initial_input(
|
||||
self: &Arc<Self>,
|
||||
context: &Arc<TurnContext>,
|
||||
turn_state: &Mutex<TurnState>,
|
||||
|
||||
@@ -362,7 +362,7 @@ impl Session {
|
||||
)
|
||||
.await;
|
||||
let host_admission = self.host_turn_admission();
|
||||
let (agent_execution_guard, task_input, pending_admission_input) = match &host_admission {
|
||||
let (agent_execution_guard, task_input, pending_initial_input) = match &host_admission {
|
||||
Some(_) => (None, Vec::new(), Some(input)),
|
||||
None => (
|
||||
self.services.agent_control.admit_turn(
|
||||
@@ -474,7 +474,7 @@ impl Session {
|
||||
cancellation_token,
|
||||
turn_context: Arc::clone(&turn_context),
|
||||
_agent_execution_guard: agent_execution_guard,
|
||||
pending_admission_input,
|
||||
pending_initial_input,
|
||||
_diagnostics_guard: ACTIVE_TURNS.track(),
|
||||
_timer: timer,
|
||||
};
|
||||
@@ -739,8 +739,9 @@ impl Session {
|
||||
active_turn.finishing = Some(finishing);
|
||||
(
|
||||
Arc::clone(&active_turn.turn_state),
|
||||
task.pending_admission_input.is_some().then_some(task.task),
|
||||
task.pending_admission_input.unwrap_or_default(),
|
||||
(task._agent_execution_guard.is_none() && task.pending_initial_input.is_some())
|
||||
.then_some(task.task),
|
||||
task.pending_initial_input.unwrap_or_default(),
|
||||
)
|
||||
};
|
||||
turn_context
|
||||
@@ -1078,10 +1079,10 @@ impl Session {
|
||||
let _ = task.handle.await;
|
||||
|
||||
if let Err(error) = self
|
||||
.record_unadmitted_input(
|
||||
.record_pending_initial_input(
|
||||
&task.turn_context,
|
||||
turn_state,
|
||||
task.pending_admission_input,
|
||||
task.pending_initial_input,
|
||||
Some(&reason),
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user