Python: Clear stale service session on full-history replay - #7354
Draft
hsusul wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an executor-layer session-continuation bug in the Python workflow runtime: when an AgentExecutorRequest replays a prior conversation (including tool calls), the executor must not reuse an unrelated service_session_id from a previous run, which can incorrectly combine explicit history with a provider-side continuation handle.
Changes:
- Clear
service_session_idinAgentExecutor.run()when an incomingAgentExecutorRequestreplays function-call history. - Promote the previously strict-xfailed regression test to a normal test.
- Add a boundary test ensuring a function-result-only request preserves
service_session_idfor legitimate continuation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_agent_executor.py | Clears stale service_session_id on replayed function-call history before running the agent. |
| python/packages/core/tests/workflow/test_full_conversation.py | Converts the regression from xfail to pass and adds a boundary test for function-result continuation behavior. |
Comment on lines
+210
to
+211
| if any(content.type == "function_call" for message in request.messages for content in message.contents): | ||
| self._session.service_session_id = None |
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 & Context
AgentExecutorRequestcan replay an explicit prior conversation, including model-issued function calls, while the target executor still carries aservice_session_idfrom an earlier run. That combines caller-supplied history with an unrelated service-side continuation handle.The executor-layer regression was already recorded as a strict xfail when #5690 fixed the OpenAI wire-format half of #3295. Running that test with
--runxfailon currentmainfails because the agent receivesresp_PREVIOUS_RUNinstead ofNone.Description & Review Guide
service_session_idbefore handling anAgentExecutorRequestthat replays model-issuedfunction_callcontent.from_responsepath continue to preserveservice_session_id.function_callcontent is the right narrow signal that distinguishes explicit replay from a function-result continuation.Validation:
.venv/bin/uv run pytest packages/core/tests/workflow/test_full_conversation.py -q— 10 passed..venv/bin/uv run poe check -P core— formatting, lint, source Pyright, and all five test type checkers passed; 3,690 tests passed, 18 skipped, and 1 unrelated test xfailed.No live provider credentials were used. The regression captures the session value at the provider boundary, and #5690 retains the separate OpenAI wire-format protection.
Related Issue
Follow-up to #3295 and #5690. The issue is already closed; this completes the executor-layer strict-xfail follow-up documented by the merged fix, so no closing keyword is used.
No open PR found for this executor behavior. #7345 covers approval replay and touches neither affected file.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.