-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Circular Reference Error when running Process samples with SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS_SENSITIVE=true
Issue Content (内容)
Describe the bug
When running the Process Framework sample (step03a_food_preparation.py) with the environment variable SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS_SENSITIVE set to true, every function invocation within a KernelProcessStep fails with a Circular reference detected error.
This strongly suggests that the internal KernelProcessStepContext object, which is passed as an argument to step functions (like GatherIngredients), contains a reference loop that prevents successful JSON serialization required for sensitive OpenTelemetry diagnostics.
To Reproduce
-
Clone the Semantic Kernel repository and navigate to the sample directory.
-
Run the sample script with the sensitive diagnostic flag enabled:
SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS_SENSITIVE=true python step03a_food_preparation.py
-
Observe the repeated error:
Something went wrong in function invocation. During function invocation: '...-GatherIngredients'. Error description: 'Circular reference detected' Error in Step ...: Error occurred while invoking function: '...-GatherIngredients'
Expected behavior
The Process sample should run successfully, and function invocation tracing/logging should handle the complex KernelProcessStepContext object gracefully (e.g., by excluding it from serialization or only recording safe identifiers like step_id), even when sensitive diagnostics are enabled.
Platform
- Language: Python
- Source: main branch of repository (running samples from
/python/samples/getting_started_with_processes/step03/) - AI model: OpenAI
- IDE: (Not critical to the bug)
- OS: Mac (macOS)
- Python Version: 3.11.9 (from traceback)
Additional context
The error occurs across all variations of the process execution (FriedFishProcess, PotatoFriesProcess, stateful steps, state loading), indicating the issue is fundamental to how Kernel.invoke (or the underlying OpenTelemetry hooks) handles the KernelProcessStepContext argument when serializing for sensitive diagnostics.
The initial traceback also shows an expected ServiceInitializationError: The OpenAI API key is required. which must be resolved before the circular reference error is reached. The main issue is the recurring Circular reference detected after the service is initialized.