Python: Fix broken samples and add missing READMEs#5038
Open
giles17 wants to merge 4 commits intomicrosoft:mainfrom
Open
Python: Fix broken samples and add missing READMEs#5038giles17 wants to merge 4 commits intomicrosoft:mainfrom
giles17 wants to merge 4 commits intomicrosoft:mainfrom
Conversation
- simple_context_provider: move instructions kwarg into options dict - suspend_resume_session: use OpenAIChatCompletionClient for in-memory demo - foundry_chat_client_with_hosted_mcp: move store kwarg into options dict - Add README.md for context_providers and conversations sample folders Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes several Python sample runtime issues caused by incorrect keyword argument placement, and adds missing README documentation for sample folders.
Changes:
- Fix
Agent.run()andget_response()option passing by nesting previously top-level kwargs intooptions={...}. - Update the in-memory session example to use
OpenAIChatCompletionClient()instead ofFoundryChatClient()to match the sample’s intent. - Add top-level READMEs for
conversations/andcontext_providers/sample folders.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/providers/foundry/foundry_chat_client_with_hosted_mcp.py | Fixes incorrect store=True kwarg usage by moving it into options for Agent.run(). |
| python/samples/02-agents/conversations/suspend_resume_session.py | Switches the in-memory demo client to OpenAIChatCompletionClient() to align with the sample’s described comparison. |
| python/samples/02-agents/conversations/README.md | Adds documentation for conversation/session samples and per-sample prerequisites. |
| python/samples/02-agents/context_providers/simple_context_provider.py | Fixes incorrect instructions= placement by moving it into the options dict for get_response(). |
| python/samples/02-agents/context_providers/README.md | Adds documentation for context provider samples and links to subfolder READMEs. |
eavanvalkenburg
approved these changes
Apr 1, 2026
TaoChenOSU
approved these changes
Apr 1, 2026
- mem0_basic: send preferences query before sleep so Mem0 can learn them, print result from new session recall - mem0_sessions: add session for multi-turn conversation in agent-scoped example, remove user_id from agent-scoped provider (Mem0 API stores memories without user_id when agent_id is provided), use single message for storing preferences - redis_basics: print retrieved context messages instead of raw object - redis_sessions: add missing load_dotenv() call - redis_basics/redis_sessions: fix docstrings referencing wrong client type - azure_redis_conversation: replace duplicate copyright with load_dotenv() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
openai_responses_agent.py was renamed to openai_agent.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fix runtime errors in several Python samples and add missing README documentation for sample folders.
Description
Sample fixes
instructionswas passed as a top-level kwarg toget_response(), but it must be inside theoptionsdict. This caused a silent failure (swallowed bysuppress(Exception)) where user info extraction never worked.FoundryChatClient()with no args, which requires a credential. Changed toOpenAIChatCompletionClient()to match the docstring intent of comparing service-managed vs in-memory sessions.store=Truewas passed as a top-level kwarg toAgent.run(), but it must be insideoptions={"store": True}. This caused aTypeErrorcrash.user_idwithagent_idwhich Mem0 API does not support (memories stored without user_id when agent_id is provided).SessionContextobject instead of retrieved context messages. Fixed docstring referencing wrong client type.load_dotenv()call causedKeyErroronFOUNDRY_PROJECT_ENDPOINT. Fixed docstring referencing wrong client type.load_dotenv()call.New READMEs
Checklist