Commit Graph

13 Commits

Author SHA1 Message Date
Adam Perry @ OpenAI
55e5158e18 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
2026-09-01 01:00:50 +00:00
Adam Perry @ OpenAI
48e22a5fa0 Report code mode host request durations (#41452)
## Why

Code mode wall time should measure the host operation itself, without including
client-side response delays or idle time between requests.

## What changed

- Measure each execute, wait, and terminate request in the code mode host.
- Carry the duration through the stdio and gRPC protocols and use it for
  model-visible wall time.
- Emit a structured `codex.code_mode.host_timing` event correlated with the
  conversation, turn, tool call, and cell.

## Testing

- Cover successful and failed execution timing, delayed response reads,
  repeated waits, termination, and missing cells across stdio and gRPC.
- Verify timing survives protocol serialization and is reflected in app-server
  model output and structured telemetry.

GitOrigin-RevId: d24af30c3fc5820521b4beba1f9970714dad6482
2026-08-29 02:52:58 +00:00
yqz-openai
eed1dee69e Propagate trace context through gRPC code mode (#41017)
## What changed

- Inject W3C `traceparent` metadata into code-mode session and execution requests.
- Carry each execution's trace context on streamed tool callbacks so callback and nested-tool spans remain connected across the gRPC boundary.
- Preserve the relevant spans when execution, callback, and dispatch work moves into spawned tasks.

GitOrigin-RevId: 6482963cb9b2e2f0ea27f1345bba208b70a80d0b
2026-08-27 01:55:53 +00:00
yqz-openai
3ba7b6941d Add OpenTelemetry tracing to the code-mode host (#40760)
## What changed

- Add `--otel-trace-exporter` for sending OTLP/HTTP JSON traces directly to an exporter.
- Add the mutually exclusive `--otel-trace-listen` option for streaming raw OTLP trace batches over a trace-only WebSocket, backed by a loopback OTLP receiver.
- Instrument host startup, transport requests, and gRPC operations with request, session, execution, cell, wait, and tool-call identifiers where available.
- Flush the trace provider with a bounded timeout during shutdown.

GitOrigin-RevId: 4dcdb2bc3b15166dccd5041fb875caea74f3f6fe
2026-08-26 02:49:51 +00:00
Adam Perry @ OpenAI
ff6e7c77a3 Canonicalize default namespaces in gRPC subscription filters (#38650)
## What changed

- Normalize both tool invocations and subscription filters before matching them.
- Treat missing and empty namespaces as aliases for the `functions` namespace while preserving the namespace reported with each invocation.

## Testing

- Add a gRPC service test covering missing, empty, and explicit default namespaces on both sides of a filtered subscription.

GitOrigin-RevId: 409326f8ee6b3ab9a6ff5ceca0693558bc9c364d
2026-08-14 21:03:00 +00:00
Adam Perry @ OpenAI
6595071e65 Remove the gRPC code-mode open session limit (#38630)
## What changed

Allow the gRPC code-mode host to register more than
`MAX_IN_FLIGHT_REQUESTS` open sessions. Existing limits on in-flight
requests, control requests, and active cells remain unchanged.

GitOrigin-RevId: 126c5088868e7783f8592f3f9250f5c8573df51f
2026-08-14 19:26:36 +00:00
Adam Perry @ OpenAI
478215c5c1 Preserve large gRPC code-mode tool errors (#38621)
## Why

Code-mode tool failure messages larger than 64 KiB were truncated before they
reached the host.

## What changed

- Remove the tool error size limit from the gRPC protocol and host validation.
- Forward failed tool completion messages without truncation.

## Testing

- Verify that a multibyte error larger than 64 KiB is preserved exactly.

GitOrigin-RevId: 264ae4ba4adea5c19b669e4f41ccfd41a0c30fb5
2026-08-14 18:30:45 +00:00
Adam Perry @ OpenAI
0fce933290 Remove the gRPC code-mode enabled tool limit (#38615)
## What changed

Stop rejecting code-mode execute requests solely because `enabled_tools`
contains more than 1,024 definitions. Continue validating each tool definition
while converting the request.

GitOrigin-RevId: da83b61c5f659e6aa221ed663821edcdfc29d3f1
2026-08-14 17:50:01 +00:00
Adam Perry @ OpenAI
a3cb1c14fb Allow larger gRPC code mode tool descriptions (#38606)
## What changed

Stop rejecting gRPC execute requests when an enabled tool's description exceeds
16 KiB. Identifier, tool-count, and subscription-filter limits remain in place.

GitOrigin-RevId: c30dbf555e691b02bd6d6a835a0c40f671b0d172
2026-08-14 16:42:32 +00:00
Channing Conger
ba2fb48319 Forward gRPC code-mode callbacks to session delegates (#38072)
## What changed

- Subscribe each gRPC code-mode session to nested tool calls and forward tool and notification callbacks to its delegate.
- Complete tool calls through the host while bounding oversized results and errors.
- Track callback ownership and cancellation so completed cells drain notifications, terminated cells cancel them, and shutdown revokes outstanding work.
- Validate callback identifiers, cell ownership, enabled tools, and pending callback limits without serializing independent callbacks or sessions.

## Testing

- Add integration and state tests for callback forwarding, completion ordering, cancellation, malformed callbacks, delegate panics, oversized results, and concurrent work.

GitOrigin-RevId: 005afbb90eea0eb77d746b930a1a96ca6dfcd4e7
2026-08-11 20:40:26 +00:00
Channing Conger
1e557a554e Add gRPC-backed code-mode sessions (#38041)
## What changed

- Add `GrpcCodeModeSessionProvider` for opening code-mode sessions over HTTP/2 or an existing `tonic` channel.
- Support execution, waiting, termination, per-session limits, cell-closure callbacks, and graceful shutdown over the gRPC protocol.
- Bound transport waits and error messages, validate host identifiers and responses, and clean up abandoned executions and observers.

## Testing

- Add end-to-end TCP tests covering session persistence, cancellation, concurrent waits, shutdown, cell cleanup, and independent yield limits.
- Add unit coverage for protocol conversion, deadlines, and session lifecycle state.

GitOrigin-RevId: d4729ce608ad4b42a99744b07e1f230e46cb24ec
2026-08-11 17:31:11 +00:00
Channing Conger
9be95745fb Make gRPC code-mode notifications fire-and-forget (#37906)
## What changed

- Send notification events without waiting for client acknowledgment, so an
  unacknowledged notification no longer delays cell completion.
- Keep the notification acknowledgment RPC as a compatibility no-op after
  validating the session and notification ID.
- Remove pending-notification tracking and cancellation events from the gRPC
  session routing path.

## Testing

- Verify that a cell completes after emitting an unacknowledged notification
  and that a later acknowledgment is still accepted.

GitOrigin-RevId: 19cf3ed5ce82cf45d84fa75f238c2afa4e83acb5
2026-08-11 00:52:35 +00:00
Channing Conger
61a3dd4387 Implement the gRPC code-mode host service (#37530)
## What changed

- Export `GrpcCodeModeHost` as a transport-independent implementation of the
  code-mode gRPC API.
- Support leased sessions, execution and wait lifecycle operations, filtered
  nested tool-call subscriptions, tool completions, and notification
  acknowledgements.
- Share host-wide request and active-cell limits across the existing and gRPC
  transports, and bound identifiers, metadata, subscriptions, and pending
  callbacks.

## Testing

- Add coverage for request conversion, ordered callback routing, cancellation,
  session cleanup, backpressure, malformed input, and resource-limit handling.

GitOrigin-RevId: f146ba7e6fe4e4aa02f25dd3f961120980516d0e
2026-08-08 04:13:55 +00:00