Skip to content

Python : Support FakeChatClient#5663

Open
andresliszt wants to merge 2 commits intomicrosoft:mainfrom
andresliszt:gh-5568
Open

Python : Support FakeChatClient#5663
andresliszt wants to merge 2 commits intomicrosoft:mainfrom
andresliszt:gh-5568

Conversation

@andresliszt
Copy link
Copy Markdown

@andresliszt andresliszt commented May 5, 2026

Motivation and Context

Description

Thanks for this amazing project. This PR supports #5568.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings May 5, 2026 21:46
@moonbox3 moonbox3 added documentation Improvements or additions to documentation python labels May 5, 2026
@github-actions github-actions Bot changed the title Gh 5568 Python: Gh 5568 May 5, 2026
@andresliszt andresliszt changed the title Python: Gh 5568 Python : Support FakeChatClient May 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (and FakeChatOptions) 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.md to 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

Copy link
Copy Markdown
Author

@andresliszt andresliszt May 6, 2026

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

@andresliszt andresliszt May 6, 2026

Choose a reason for hiding this comment

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

Good catch, I was following the other clients as example, for instance look this ollama client:

self.middleware = list(self.chat_middleware)

So my question is, exposing the middleware attribute is needed, even if is only a snapshot ? For the public API?

Comment thread python/packages/core/agent_framework/fake/_chat_client.py
Comment thread python/packages/core/agent_framework/fake/_chat_client.py Outdated
Comment thread python/PACKAGE_STATUS.md Outdated
@andresliszt
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@andresliszt andresliszt force-pushed the gh-5568 branch 2 times, most recently from 0c1194b to df93388 Compare May 6, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants