Python : Support FakeChatClient#5663
Open
andresliszt wants to merge 2 commits intomicrosoft:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a deterministic FakeChatClient to the Python core SDK to support testing/demo scenarios without a real model dependency (as requested in #5568).
Changes:
- Introduces
agent_framework.fake.FakeChatClient(andFakeChatOptions) for queued/cycling fake responses and basic streaming behavior. - Adds unit tests covering init/serialization, middleware integration, cycling/exhaustion behavior, and streaming finalization.
- Updates
python/PACKAGE_STATUS.mdto include a new “fake” package entry.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/fake/_chat_client.py | Implements FakeChatClient and options, including response selection, cycling, and streaming updates. |
| python/packages/core/agent_framework/fake/init.py | Exposes the fake client/options from the agent_framework.fake namespace. |
| python/packages/core/tests/core/test_fake_chat_client.py | Adds test coverage for FakeChatClient behavior (middleware, streaming, exhaustion, cycle). |
| python/PACKAGE_STATUS.md | Adds an entry for an “agent-framework-fake” package. |
Comment on lines
+41
to
+52
| class FakeChatOptions(ChatOptions[ResponseModelT], Generic[ResponseModelT], total=False): | ||
| """Fake-model options used by FakeChatClient. | ||
|
|
||
| Keys: | ||
| model: Optional model name override for this request. | ||
| response: Optional one-off response that overrides queued responses. | ||
| cycle: Optional per-request override for cycling behavior. | ||
| """ | ||
|
|
||
| response: FakeResponseItem | ||
| cycle: bool | ||
|
|
Author
There was a problem hiding this comment.
This is incorrect, my code follows the option pattern of all other existing clients, and can be imported without any problem
Comment on lines
+91
to
+95
| self.middleware = list(self.chat_middleware) | ||
| self._responses = list(responses) | ||
| self._response_index = 0 | ||
| self._cycle = cycle | ||
|
|
Author
There was a problem hiding this comment.
Good catch, I was following the other clients as example, for instance look this ollama client:
So my question is, exposing the middleware attribute is needed, even if is only a snapshot ? For the public API?
Author
|
@microsoft-github-policy-service agree |
0c1194b to
df93388
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
Description
Thanks for this amazing project. This PR supports #5568.
Contribution Checklist