Python: Align docstrings with actual signatures - #14378
Conversation
Remove documented parameters that no longer exist and correct two wrong
documented defaults:
- data/vector.py: four include_vectors Args entries said 'Default is
True' while every signature declares False
- orchestration/group_chat.py: filter_results documented
participant_descriptions, which it does not take
- kernel.py: as_mcp_server documented a kernel parameter it does not
take
- memory/semantic_text_memory_base.py: min_relevance_score documented
default 0.0, actual default is 0.7
- contents/{chat,streaming_chat}_message_content.py: to_element
documented a root_key argument it does not take
- agents/bedrock/bedrock_agent.py: create_channel documented
chat_history, which it does not take
- connectors/ai/open_ai/exceptions/content_filter_ai_exception.py:
from_inner_error_result documented a key parameter it does not take
There was a problem hiding this comment.
🟡 Changes recommended
SemanticTextMemoryBase.search() still documents a with_embeddings argument that is not present in its signature, so the docstrings are not fully aligned with the API surface.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates Python docstrings to match the actual function signatures, removing parameters that aren’t accepted and correcting documented default values to prevent misleading API docs.
Changes:
- Corrected documented defaults (e.g.,
min_relevance_scoreandinclude_vectors) to match declared defaults. - Removed docstring-only parameters that are not present in method signatures across several modules.
- Simplified
to_element()docstrings by removing a non-existentroot_keyargument.
File summaries
| File | Description |
|---|---|
| python/semantic_kernel/memory/semantic_text_memory_base.py | Updates search() docstring default for min_relevance_score (and related Args section). |
| python/semantic_kernel/kernel.py | Removes non-existent kernel parameter from as_mcp_server docstring. |
| python/semantic_kernel/data/vector.py | Fixes include_vectors documented default to match the overloads/implementation. |
| python/semantic_kernel/contents/streaming_chat_message_content.py | Removes non-existent root_key arg from to_element() docstring. |
| python/semantic_kernel/contents/chat_message_content.py | Removes non-existent root_key arg from to_element() docstring. |
| python/semantic_kernel/connectors/ai/open_ai/exceptions/content_filter_ai_exception.py | Removes non-existent key arg from from_inner_error_result() docstring. |
| python/semantic_kernel/agents/orchestration/group_chat.py | Removes non-existent participant_descriptions arg from filter_results() docstring. |
| python/semantic_kernel/agents/bedrock/bedrock_agent.py | Removes non-existent chat_history arg from create_channel() docstring. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -98,7 +98,7 @@ async def search( | |||
| collection (str): The collection to search in. | |||
| query (str): The query to search for. | |||
| limit (int): The maximum number of results to return. (default: {1}) | |||
| min_relevance_score (float): The minimum relevance score to return. (default: {0.0}) | |||
| min_relevance_score (float): The minimum relevance score to return. (default: {0.7}) | |||
| with_embeddings (bool): Whether to return the embeddings of the results. (default: {False}) | |||
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 29fca33110a7
Model: claude-opus-4.8
Overview
This is a docstring-only change across eight files (+5/−15, all edits inside triple-quoted docstrings) that removes documented parameters absent from the real signatures and corrects two wrong documented defaults. Every edit was independently verified against the signature directly above it in the frozen checkout: no removed Arg corresponded to a real parameter, and both corrected defaults (include_vectors=False, min_relevance_score=0.7) match the code. No executable code, signature, default, control flow, or serialized/wire format changes, and the edited docstrings are not consumed as runtime metadata (MCP tool/prompt descriptions derive from KernelFunctionMetadata.description, not these method docstrings), so there is no behavioral, compatibility, or trust-boundary surface. Interface/implementation docstring parity is preserved (e.g., ChatCompletionAgent.create_channel, which legitimately takes chat_history, was correctly left untouched).
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.
The abstract SemanticTextMemoryBase.search() does not accept with_embeddings (only the concrete SemanticTextMemory.search() does); follow-up to the docstring alignment PR.
Docstring-only fix: removes documented parameters that don't exist in the actual signatures and corrects two wrong documented defaults. Each item verified against the signature directly above it:
data/vector.py: fourinclude_vectorsArgs entries said "Default is True" while every signature declaresinclude_vectors: bool = False(the sibling docstring already said False)orchestration/group_chat.py:filter_resultsdocumentedparticipant_descriptions, which it does not take (its siblingselect_next_speakerlegitimately does — untouched)kernel.py:as_mcp_serverdocumented akernelparameter it does not takememory/semantic_text_memory_base.py:min_relevance_scoredocumented default{0.0}, actual default is0.7contents/chat_message_content.py+contents/streaming_chat_message_content.py:to_element()documented aroot_keyargument it does not takeagents/bedrock/bedrock_agent.py:create_channeldocumentedchat_history, which it does not takeconnectors/ai/open_ai/exceptions/content_filter_ai_exception.py:from_inner_error_resultdocumented akeyparameter it does not takeOne deliberate non-change, for the record: the identical if/else arms in the
response_formatvalidators (open_ai_prompt_execution_settings.py,azure_ai_inference_prompt_execution_settings.py) look like a bug but are not — the non-BaseModeltypepath is a supported input consumed by_handle_structured_outputCase 2 (schema built from the bare type), so both arms intentionally setstructured_json_response = True.Contribution checklist: