Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

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: Added suppress_invoke_agent_input parameter (defaults to False)

    • Detects InvokeAgent scope by checking parent span's GEN_AI_OPERATION_NAME_KEY attribute
    • Conditionally filters GEN_AI_INPUT_MESSAGES_KEY for Generation/Response spans when inside InvokeAgent scope
    • Helper method _should_suppress_input(span) encapsulates the detection and suppression logic
  • OpenAIAgentsTraceInstrumentor: Accepts and forwards suppress_invoke_agent_input kwarg to processor

  • Tests: 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_NAME by looking up the parent span in the existing _otel_spans dictionary and inspecting its attributes. This approach avoids the need for separate state tracking.

Usage

instrumentor = OpenAIAgentsTraceInstrumentor()
instrumentor.instrument(suppress_invoke_agent_input=True)

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

This section details on the original issue you should resolve

<issue_title>[SDK Parity] Python for PR microsoft/Agent365-nodejs#121</issue_title>
<issue_description>## SDK Parity Update Required

This issue was automatically created by the AI-First Polling workflow to maintain SDK parity.

Source PR Information

Original PR: microsoft/Agent365-nodejs#121 - Add option to auto instrumentation to prevent sending the LLM [FILTERED] …
PR URL: microsoft/Agent365-nodejs#121
PR Author: @fpfp100

PR Description

[Node.js SDK] Add option to auto instrumentation to prevent sending the LLM [FILTERED] on InvokeAgent scopes.


Parity Task

Changes detected in: Node.js/TypeScript SDK
Target SDK: Python

Action Required

Please apply the changes described in the original PR (microsoft/Agent365-nodejs#121) to the Python SDK to maintain feature parity across all SDKs.

Before implementing:

  • First, check if this feature already exists in the Python SDK
  • If the feature is already implemented, close this issue with the wontfix label and add a comment explaining that parity already exists

For bug fixes (IMPORTANT):

  • Bug fixes require extra caution - only act if the same bug exists in the Python SDK
  • Carefully analyze whether the bug described in the original PR replicates in the target platform
  • If the bug does NOT exist in the Python SDK, close this issue with the wontfix label and explain that the bug is not present
  • Stay strictly in context - only fix the specific bug described, do not make additional changes or "improvements"
  • Do not port bug fixes that are specific to the source SDK's language or platform constraints

When creating the PR for this implementation:

  • Assign the PR to @fpfp100 (the author of the original PR)
  • Reference this issue in the PR description
  • Ensure the PR description explains what parity changes were made

Implementation Guidelines for Python

When implementing this feature in the Python SDK:

  • Review existing code in python/libraries/ to understand the codebase structure and patterns
  • Follow the coding style, naming conventions, and architectural patterns used in the Python SDK
  • Check for configuration files (e.g., pyproject.toml, .flake8, mypy.ini) that define coding standards
  • Ensure your implementation is consistent with existing SDK components
  • Include appropriate tests following the testing patterns in the Python SDK

Related Information


This is an automated issue. Please close with wontfix label if parity is not needed.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@sergioescalera
Copy link
Contributor

🤖 Auto-Assignment

This 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:

  • @fpfp100: Please review this implementation to ensure it matches your intent
  • Validate the parity changes are correct and complete
  • Approve and merge when satisfied

Automated by AI-First Polling Workflow

Copilot AI and others added 2 commits January 9, 2026 18:12
Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
…ve efficiency

Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option for auto instrumentation in Python SDK Add suppress_invoke_agent_input option to OpenAI trace processor Jan 9, 2026
Copilot AI requested a review from sergioescalera January 9, 2026 18:19
"""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:
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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:

  1. Checks if span.parent_id exists
  2. Retrieves the parent span from self._otel_spans
  3. Checks if the parent's GEN_AI_OPERATION_NAME_KEY attribute equals INVOKE_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SDK Parity] Python for PR microsoft/Agent365-nodejs#121

4 participants