Repository navigation
Python: Avoid logging function argument values - #14574
Eduard van Valkenburg (eavanvalkenburg) merged 4 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
Sensitive argument values are removed with focused regression coverage; only minor message grammar remains.
1 open finding
What changed in this PR
Removes function argument values from Python logs while preserving useful invocation diagnostics.
Changes:
- Replaces argument values with names/counts in invocation logs.
- Adds regression coverage across automatic, direct, and template invocations.
| File | Description |
|---|---|
python/semantic_kernel/kernel.py |
Removes automatic-call arguments from INFO logs. |
python/semantic_kernel/functions/kernel_function_log_messages.py |
Logs argument counts instead of values. |
python/semantic_kernel/prompt_template/utils/template_function_helpers.py |
Replaces template values with invocation counts. |
python/tests/unit/kernel/test_kernel.py |
Tests automatic invocation logging. |
python/tests/unit/functions/test_kernel_function_from_method.py |
Tests direct invocation logging. |
python/tests/unit/prompt_template/test_template_helper.py |
Tests synchronous/asynchronous template logging. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 3e5773ad4a0f
Model: gpt-5.6-sol
Overview
The PR replaces argument-bearing invocation logs with function identity and argument-count diagnostics across direct, automatic, and template invocation paths. The shared direct-invocation helper also covers streaming calls, sensitive tracing remains explicitly gated, and focused tests verify that sentinel values do not reach the changed loggers. No Critical, High, or Medium defect introduced by the reviewed diff was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Two privacy paths remain in the shared invocation layer: successful return values can echo arguments into DEBUG logs, and failure messages can expose them through ERROR logs and non-sensitive OpenTelemetry spans.
d99be89 to
49eebee
Compare
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Both privacy findings are resolved. Successful invocation diagnostics no longer serialize result values, including direct, automatic, and template paths. Failure diagnostics now keep raw exception text out of ordinary ERROR logs and non-sensitive spans across streaming and non-streaming invocation, while preserving exception details when sensitive diagnostics are explicitly enabled. The added regression coverage exercises those paths, and the current Python CI matrix is green.

Motivation and Context
Function invocation diagnostics currently include complete argument, result, or exception values at INFO, DEBUG, or ERROR level. This change keeps invocation diagnostics useful while avoiding recording those values in ordinary application logs or non-sensitive function spans.
Description
Validation:
uv build --out-dir /tmp/semantic-kernel-pr-review-build— passed; built the source distribution and wheel.uv run pre-commit run --files semantic_kernel/kernel.py semantic_kernel/functions/kernel_function.py semantic_kernel/functions/kernel_function_log_messages.py semantic_kernel/prompt_template/utils/template_function_helpers.py semantic_kernel/utils/telemetry/model_diagnostics/function_tracer.py tests/unit/kernel/test_kernel.py tests/unit/functions/test_kernel_function_from_method.py tests/unit/prompt_template/test_template_helper.py— passed all applicable hooks.uv run pytest tests/unit/kernel/test_kernel.py tests/unit/functions/test_kernel_function_from_method.py tests/unit/prompt_template/test_template_helper.py— 132 passed.uv run pytest tests/unit/utils/model_diagnostics/test_trace_chat_completion.py tests/unit/utils/model_diagnostics/test_trace_streaming_chat_completion.py tests/unit/utils/model_diagnostics/test_trace_text_completion.py tests/unit/utils/model_diagnostics/test_trace_streaming_text_completion.py— 28 passed.The full unit-test suite was not run locally; the targeted files cover each changed logging and tracing path.
Contribution Checklist