Commit Graph
1 Commits
Author SHA1 Message Date
João MouraandClaude Opus 5.5 fbcf2de39d fix(tracing): keep tool and task outputs whole in exported spans (#7833)
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
Vulnerability Scan / Detect changes (push) Has been cancelled
Vulnerability Scan / pip-audit (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
* fix(tracing): keep tool and task outputs whole in exported spans

Every gen_ai.* content attribute was capped at 32 KiB, and a value over the
cap that was not a message array became an envelope holding a 4 KiB preview:
a 33 KB tool result reached the trace as 4 KB. Graders checking a summary
against the data a tool returned could not decide.

- DEFAULT_MAX_ATTR_BYTES is 384 KiB, sized to Wharf's 3,072,000-byte request
  limit: seven attributes at the bound still fit one request.
- Over the bound, a value loses only what is over it (the envelope preview
  fills the bound; a message's text is cut by the overshoot, not halved), with
  the existing <attr>.truncated / <attr>.original_size_bytes markers.
- Every other string attribute (crewai.task.output, crewai.mcp.tool_result,
  serialized flow state) gets the same bound and markers; before, one huge
  value made the span too large for Wharf and the exporter dropped it whole.
- An OpenTelemetry SDK attribute length limit, when set, lowers the bound, so
  the SDK (which cuts without a marker) never has anything left to cut.
  CREWAI_OTEL_MAX_ATTR_BYTES still replaces the bound; no new setting.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(tracing): honour SDK length limits as the SDK reads them; cut plain attributes plainly

- The span attribute length limit is read like SpanLimits: the span setting
  wins over the general one, an explicitly empty value means unlimited, and 0
  is a limit (every string cut to nothing, with crewAI's marker).
- Plain attributes (crewai.task.output, crewai.mcp.tool_result, flow state)
  keep their head up to the bound with the .truncated / .original_size_bytes
  markers; only gen_ai.* messages get message-aware truncation, so a
  role-bearing JSON list a task produced is never reshaped as a conversation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(tracing): clamp the attribute bound at the Wharf-safe ceiling; shrink a span that does not fit instead of dropping it

- CREWAI_OTEL_MAX_ATTR_BYTES and the OTel SDK span attribute length limit
  can lower the 384 KiB bound, never raise it. A higher
  CREWAI_OTEL_MAX_ATTR_BYTES is clamped with one warning naming the value,
  the ceiling and why (Wharf's 3,072,000-byte request). No new setting.
- GrantSpanExporter no longer drops a span whose attributes, each within its
  bound, add up to more than one request: the largest string attributes are
  cut by the overshoot, each with .truncated / .original_size_bytes, until it
  fits. A span whose excess is in its resource, scope or events is still
  skipped, as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 03:37:42 -03:00