Repository navigation
fix: honor Agents sensitive trace setting for instructions - #1786
mikemikimike wants to merge 2 commits into
Conversation
Reviewer's GuideUpdates OpenAI Agents instruction capture to honor the SDK’s sensitive trace configuration without changing OpenLIT’s own content-capture behavior, with focused tests covering setting parsing, defaults, suppression, and compatibility fallback. Sequence diagram for OpenAI Agents instruction capture privacysequenceDiagram
participant Agent as Agent
participant OpenLIT as OpenLIT instrumentation
participant SDK as Agents SDK
participant Span as create_agent span
Agent->>OpenLIT: create_agent()
OpenLIT->>SDK: _default_trace_include_sensitive_data()
SDK-->>OpenLIT: enabled or disabled
alt capture_message_content and sensitive trace enabled
OpenLIT->>Span: set_attribute(instructions)
else content capture disabled or sensitive trace disabled
OpenLIT-->>Span: omit instructions
end
Flow diagram for instruction capture eligibilityflowchart TD
A[Agent instructions available] --> B{capture_message_content?}
B -->|No| D[Do not capture instructions]
B -->|Yes| C{SDK sensitive trace setting enabled?}
C -->|Yes| E[Format and set span instruction attribute]
C -->|No| D
C -. SDK helper unavailable .-> F[Use enabled fallback]
F --> E
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="sdk/python/src/openlit/instrumentation/openai_agents/__init__.py" line_range="31-32" />
<code_context>
+ """Return the SDK default available while an Agent is being constructed."""
+ try:
+ from agents.run_config import _default_trace_include_sensitive_data
+ except ImportError:
+ return True
+
+ return _default_trace_include_sensitive_data()
</code_context>
<issue_to_address>
**Import errors enable instruction capture**
When importing `agents.run_config` raises `ImportError` for a reason other than the helper being absent, while sensitive-data capture is disabled, an `ImportError` from `agents.run_config` or one of its dependencies is treated as an unavailable helper, so the function returns `True` and captures instructions even when the SDK privacy setting is false. The caller sees sensitive instructions in the `create_agent` span.
Only use the legacy fallback when the helper is genuinely absent; otherwise fail closed and omit the instructions.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the setting is read incorrectly as enabled, system instructions—including potentially confidential rules—are attached to exported spans and can remain in telemetry after a revert. Correctly reading a disabled setting prevents that capture; reverting restores the prior unconditional capture behavior.
Blocking findings: sdk/python/src/openlit/instrumentation/openai_agents/__init__.py:32
This fixes OpenAI Agents instruction capture when the SDK's default trace setting excludes sensitive data. The create_agent span now follows the SDK setting while preserving OpenLIT's capture_message_content behavior.
Regression coverage verifies the SDK setting's supported values, its enabled default, OpenLIT content suppression, and compatibility when the SDK helper is unavailable. The end-to-end reproduction uses a local mock Responses API.
Validation: focused OpenAI Agents privacy tests, focused Pylint, poetry check, and poetry build.
Issue: #1759
Fixes #1759
Summary by Sourcery
Respect the OpenAI Agents SDK privacy setting when capturing agent instructions.
Bug Fixes:
Tests: