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

+1 -3
View File
@@ -15,7 +15,6 @@ use crate::mcp_tool_call::request_mcp_tool_user_approval;
use crate::sandboxing::SandboxPermissions;
use crate::session::session::Session;
use crate::session::turn_context::TurnContext;
use crate::tools::flat_tool_name;
use crate::tools::hook_names::HookToolName;
use crate::tools::runtimes::apply_patch::ApplyPatchApprovalKey;
use crate::tools::runtimes::unified_exec::UnifiedExecApprovalKey;
@@ -778,9 +777,8 @@ fn record_resolution(ctx: &ApprovalContext, resolution: &ApprovalResolution) {
ApprovalResolutionSource::Guardian => ToolDecisionSource::AutomatedReviewer,
ApprovalResolutionSource::User => ToolDecisionSource::User,
};
let tool_name = flat_tool_name(&ctx.tool_name);
ctx.review_context.turn().session_telemetry.tool_decision(
tool_name.as_ref(),
&ctx.tool_name,
&ctx.call_id,
&resolution.decision,
Some(source),