mirror of
https://github.com/openai/codex.git
synced 2026-11-14 06:48:26 +00:00
Scope code mode callback delegates to individual executions (#44865)
## Why A delegate bound at session creation cannot provide different callbacks for cells sharing that session. Each execution needs to retain its own delegate across yields and release it when the cell is cleaned up. ## What changed - Pass `CodeModeSessionDelegate` to `execute` instead of session creation. - Route tool calls, notifications, and cell closure callbacks through the execution's delegate in the in-process runtime and the gRPC and stdio transports. - Retain delegates with pending executions and live cells, releasing them through closure and cancellation cleanup. ## Testing Add coverage for distinct delegates across yielded cells, gRPC callbacks before cell admission, and delegate release after completion or abandoned execution cleanup. Update transport tests to verify callbacks reach the owning cell's delegate. GitOrigin-RevId: 7469f52104b993e790a40c65fb800ad02b7fd606
This commit is contained in:
1 parent
bc5957eac9
commit
3305c4f31d
30 files changed
+1027
-637
No files matched your search
@@ -119,7 +119,7 @@ async fn stdio_execution_timing_includes_javascript_but_excludes_delayed_reads()
|
||||
);
|
||||
let delegate = Arc::new(RecordingDelegate::default());
|
||||
let session = provider
|
||||
.create_session(delegate.clone())
|
||||
.create_session()
|
||||
.await
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
|
||||
@@ -127,17 +127,20 @@ async fn stdio_execution_timing_includes_javascript_but_excludes_delayed_reads()
|
||||
for (index, suffix) in endings.into_iter().enumerate() {
|
||||
let observed = Instant::now();
|
||||
let started = session
|
||||
.execute(ExecuteRequest {
|
||||
tool_call_id: format!("call-{index}"),
|
||||
source: format!(
|
||||
"const until = Date.now() + 150; while (Date.now() < until) {{}} \
|
||||
.execute(
|
||||
ExecuteRequest {
|
||||
tool_call_id: format!("call-{index}"),
|
||||
source: format!(
|
||||
"const until = Date.now() + 150; while (Date.now() < until) {{}} \
|
||||
await new Promise(resolve => setTimeout(resolve, 150)); \
|
||||
notify('finished'); {suffix}"
|
||||
),
|
||||
enabled_tools: Vec::new(),
|
||||
yield_time_ms: Some(/*value*/ 5_000),
|
||||
max_output_tokens: Some(/*value*/ 1_000),
|
||||
})
|
||||
),
|
||||
enabled_tools: Vec::new(),
|
||||
yield_time_ms: Some(/*value*/ 5_000),
|
||||
max_output_tokens: Some(/*value*/ 1_000),
|
||||
},
|
||||
delegate.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
timeout(TEST_TIMEOUT, delegate.notification_delivered.notified())
|
||||
@@ -184,17 +187,20 @@ async fn observation_timing_excludes_previous_requests_and_background_time() ->
|
||||
];
|
||||
for provider in providers {
|
||||
let session = provider
|
||||
.create_session(Arc::new(NoopCodeModeSessionDelegate))
|
||||
.create_session()
|
||||
.await
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let started = session
|
||||
.execute(ExecuteRequest {
|
||||
tool_call_id: "call-1".to_string(),
|
||||
source: "await new Promise(() => {});".to_string(),
|
||||
enabled_tools: Vec::new(),
|
||||
yield_time_ms: Some(/*value*/ 200),
|
||||
max_output_tokens: Some(/*value*/ 1_000),
|
||||
})
|
||||
.execute(
|
||||
ExecuteRequest {
|
||||
tool_call_id: "call-1".to_string(),
|
||||
source: "await new Promise(() => {});".to_string(),
|
||||
enabled_tools: Vec::new(),
|
||||
yield_time_ms: Some(/*value*/ 200),
|
||||
max_output_tokens: Some(/*value*/ 1_000),
|
||||
},
|
||||
Arc::new(NoopCodeModeSessionDelegate),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let cell_id = started.cell_id.clone();
|
||||
|
||||
Reference in new issue
Block a user