-
Notifications
You must be signed in to change notification settings - Fork 6
Add suppress_invoke_agent_input option to OpenAI trace processor #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🤖 Auto-AssignmentThis PR was automatically assigned to @fpfp100 for review. Reason: This is a parity implementation for issue #110, which was triggered by @fpfp100's original PR (microsoft/Agent365-nodejs#121). Next Steps:
Automated by AI-First Polling Workflow |
Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
…ve efficiency Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
| """Check if input messages should be suppressed for the given trace.""" | ||
| return self._suppress_invoke_agent_input and self._is_in_invoke_agent_scope(trace_id) | ||
|
|
||
| def _is_in_invoke_agent_scope(self, trace_id: str) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a different way of detecting an invoke agent span?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can we use a different tactic to detect invoke agent spans? one that does not require keeping track all active agent spans in a dictionary?
For example:
core/trace_processor/span_processor.py
operation_name = ... // get operation name from attributes
is_invoke_agent = False
if operation_name == INVOKE_AGENT_OPERATION_NAME:
is_invoke_agent = True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored the implementation to check the parent span's operation name instead of maintaining a tracking dictionary. The new approach:
- Checks if
span.parent_idexists - Retrieves the parent span from
self._otel_spans - Checks if the parent's
GEN_AI_OPERATION_NAME_KEYattribute equalsINVOKE_AGENT_OPERATION_NAME
This eliminates the need for the _active_agent_spans dictionary and associated tracking logic in on_span_start and on_span_end.
Changes in commit cff467f.
…ctionary Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
SDK parity with Node.js PR microsoft/Agent365-nodejs#121. Adds option to suppress LLM prompt data in InvokeAgent scopes while preserving other telemetry.
Changes
OpenAIAgentsTraceProcessor: Addedsuppress_invoke_agent_inputparameter (defaults toFalse)GEN_AI_OPERATION_NAME_KEYattributeGEN_AI_INPUT_MESSAGES_KEYfor Generation/Response spans when inside InvokeAgent scope_should_suppress_input(span)encapsulates the detection and suppression logicOpenAIAgentsTraceInstrumentor: Accepts and forwardssuppress_invoke_agent_inputkwarg to processorTests: Added unit tests for configuration validation and suppression behavior
Implementation Details
The implementation checks if a span's parent has an operation name matching
INVOKE_AGENT_OPERATION_NAMEby looking up the parent span in the existing_otel_spansdictionary and inspecting its attributes. This approach avoids the need for separate state tracking.Usage
When enabled, input messages are suppressed only for spans within InvokeAgent scopes. Spans outside these scopes continue recording input messages normally. Output messages and all other attributes remain unaffected.
Parity source: microsoft/Agent365-nodejs#121 by @fpfp100
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.