Python: preserve local history with skill approvals#5686
Open
he-yufeng wants to merge 1 commit intomicrosoft:mainfrom
Open
Python: preserve local history with skill approvals#5686he-yufeng wants to merge 1 commit intomicrosoft:mainfrom
he-yufeng wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a local-session regression where enabling SkillsProvider(require_script_approval=True) prevented the default in-memory history from being used, causing approval resume turns to omit the prior function_call needed to correctly replay an approved tool/script execution.
Changes:
- Adjust local history auto-injection to look specifically for an existing
HistoryProvider(instead of “any context provider”). - Insert the auto-injected
InMemoryHistoryProviderahead of other context providers so stored conversation history loads before per-turn context augmentation. - Add a regression test asserting the approval resume model call includes the original
function_callbefore the correspondingfunction_result.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/_agents.py |
Fixes local history auto-injection logic to preserve history alongside other context providers and ensures correct provider ordering. |
python/packages/core/tests/core/test_agents.py |
Adds a regression test covering skill script approvals and verifying correct replay ordering of tool call/result in the final model call. |
ead9573 to
d11a50a
Compare
d11a50a to
0d58f00
Compare
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
Fixes #5672.
When a local Agent session is used with
SkillsProvider(require_script_approval=True), the approval resume turn needs the previous assistantfunction_callin the messages sent to the model. Before this change, adding a context provider such asSkillsProviderprevented the default in-memory history provider from being added, so the approved script result could be replayed without the original tool call.Description
This changes the local history auto-injection guard to check for an existing
HistoryProvider, rather than checking whether any context provider exists. The injectedInMemoryHistoryProvideris inserted before other providers so stored conversation history is loaded before provider-added context for the current turn.The regression test covers a code-defined skill script with
require_script_approval=True, resumes withrequest.to_function_approval_response(True), and asserts that the final model call includes the original assistantfunction_callbefore the matchingfunction_result.Contribution Checklist
To verify:
uv run pytest packages\core\tests\core\test_agents.py::test_chat_agent_skill_script_approval_replays_stored_tool_call -quv run pytest packages\core\tests\core\test_agents.py -quv run pytest packages\core\tests\core\test_function_invocation_logic.py -quv run ruff check agent_framework\_agents.py tests\core\test_agents.py --no-fixuv run ruff format agent_framework\_agents.py tests\core\test_agents.py --checkuv run python -m py_compile agent_framework\_agents.py tests\core\test_agents.pygit diff --checkI also ran
uv run poe test -P core; it completed with one unrelated failure intests/core/test_telemetry.py::test_detect_hosted_fallback_import_errorwhile patchingbuiltins.__import__aroundazure.ai.agentserver. I did not change telemetry code. I trieduv run poe syntax -P core --check; the whole-package run reports an existing line-length issue intests/core/test_skills.py:1193, outside this change.