Make tool-result telemetry limits configurable (#39779)

## What changed

- Add `otel.tool_result.max_bytes`, defaulting to 2048 bytes, to control the
  text included in `codex.tool_result` logs independently of model-visible
  output limits.
- Apply truncation centrally when emitting telemetry, preserve UTF-8
  boundaries, and report whether the logged output was truncated.
- Record typed tool names and namespaces, agent names, and process-local result
  sequence numbers while keeping tool arguments and output out of trace events.

## Testing

- Cover configuration propagation, UTF-8-safe truncation, raw tool-output
  logging, and log/trace event routing and fields.

GitOrigin-RevId: 89ca76e55f1a09b729e7770ce01f2e4d98f9a22d
This commit is contained in:
tongzhou wang authored and copyberry committed 2026-08-20 19:09:04 +00:00
1 parent 5663754f62
commit 854cbb2fd4
39 files changed
+583 -310

No files matched your search

+2 -1
View File
@@ -1067,7 +1067,8 @@ impl Session {
terminal_type.clone(),
session_configuration.session_source.clone(),
)
.with_auth_env(auth_env_telemetry.to_otel_metadata());
.with_auth_env(auth_env_telemetry.to_otel_metadata())
.with_tool_result_log_config(config.otel.tool_result);
if let Some(service_name) = session_configuration.metrics_service_name.as_deref() {
session_telemetry = session_telemetry.with_metrics_service_name(service_name);
}