Skip to content

Python: Align docstrings with actual signatures - #14378

Open
陈志谦 (simpleqt) wants to merge 2 commits into
microsoft:mainfrom
simpleqt:docs/align-docstrings-with-signatures
Open

Python: Align docstrings with actual signatures#14378
陈志谦 (simpleqt) wants to merge 2 commits into
microsoft:mainfrom
simpleqt:docs/align-docstrings-with-signatures

Conversation

@simpleqt

Copy link
Copy Markdown

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: four include_vectors Args entries said "Default is True" while every signature declares include_vectors: bool = False (the sibling docstring already said False)
  • orchestration/group_chat.py: filter_results documented participant_descriptions, which it does not take (its sibling select_next_speaker legitimately does — untouched)
  • 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_message_content.py + contents/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

One deliberate non-change, for the record: the identical if/else arms in the response_format validators (open_ai_prompt_execution_settings.py, azure_ai_inference_prompt_execution_settings.py) look like a bug but are not — the non-BaseModel type path is a supported input consumed by _handle_structured_output Case 2 (schema built from the bare type), so both arms intentionally set structured_json_response = True.

Contribution checklist:

  • The code builds clean locally
  • All unit tests pass (docstring-only change)

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
Copilot AI lite review requested due to automatic review settings September 4, 2026 15:38
@simpleqt
陈志谦 (simpleqt) requested a review from a team as a code owner September 4, 2026 15:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_score and include_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-existent root_key argument.
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.

Comment on lines 97 to 102
@@ -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})

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
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.

2 participants