Improve tracing for nested tool calls and exec processes (#41950)

## Why

Code-mode callbacks can outlive their initial request and run in separate tasks,
so their trace context must be preserved explicitly.

## What changed

- Preserve the execution context for code-mode callbacks and add spans for
  nested tool invocations in the runtime and dispatch broker.
- Propagate each tool invocation span as the parent of its streamed gRPC
  callback, falling back to the outer execution context when needed.
- Add a `codex.exec_server.process` span for each process lifetime, including
  its process ID and completion result, without retaining the request span.

GitOrigin-RevId: a6059e34d895416f5517e51dad6ca0078355adca
This commit is contained in:
Adam Perry @ OpenAI authored and copyberry committed 2026-09-01 01:00:50 +00:00
1 parent bfa9646787
commit 55e5158e18
10 files changed
+61 -4

No files matched your search

@@ -255,6 +255,17 @@ async fn wait_until_cell_ready_for_dispatch(
}
impl CodeModeSessionDelegate for CodeModeDispatchBroker {
#[tracing::instrument(
name = "code_mode.broker.invoke_tool",
level = "info",
skip_all,
fields(
cell.id = %invocation.cell_id,
runtime_tool_call_id = invocation.runtime_tool_call_id.as_str(),
tool_name = invocation.tool_name.name.as_str(),
tool_namespace = invocation.tool_name.namespace.as_deref(),
)
)]
fn invoke_tool<'a>(
&'a self,
invocation: CodeModeNestedToolCall,