Skip to content

Python: fix TypeError in the mixed_chat_images sample (credential not passed to the kernel helper) - #14349

Open
Tai An (Anai-Guo) wants to merge 1 commit into
microsoft:mainfrom
Anai-Guo:fix-mixed-chat-images-credential
Open

Python: fix TypeError in the mixed_chat_images sample (credential not passed to the kernel helper)#14349
Tai An (Anai-Guo) wants to merge 1 commit into
microsoft:mainfrom
Anai-Guo:fix-mixed-chat-images-credential

Conversation

@Anai-Guo

Copy link
Copy Markdown

Motivation and Context

python/samples/concepts/agents/mixed_chat/mixed_chat_images.py cannot run. Its local
helper is

def _create_kernel_with_chat_completion(service_id: str, credential: TokenCredential) -> Kernel:

but the one call site passes only service_id:

summary_agent = ChatCompletionAgent(
    kernel=_create_kernel_with_chat_completion(service_id=service_id),   # line 60
    ...
)

so the sample raises

TypeError: _create_kernel_with_chat_completion() missing 1 required positional argument: 'credential'

right after the assistant is created — i.e. after the Azure client and the assistant
definition have already been provisioned, and before any of the image content the sample
is meant to demonstrate is produced.

credential is already in scope: main() builds credential = AzureCliCredential() on
its first line and passes it to AzureAssistantAgent.create_client(credential=credential)
a few lines above. Only the kernel helper call was missed.

The four sibling samples in the same directory all pass it:

sample call binds?
mixed_chat_agents_plugins.py:90 _create_kernel_with_chat_completion("artdirector", credential)
mixed_chat_files.py:73 _create_kernel_with_chat_completion(service_id=service_id, credential=credential)
mixed_chat_images.py:60 _create_kernel_with_chat_completion(service_id=service_id) TypeError
mixed_chat_reset.py:46 _create_kernel_with_chat_completion("chat", credential)
mixed_chat_streaming.py:50 _create_kernel_with_chat_completion("artdirector", credential)

Description

One line: pass credential at the call site, making it byte-identical to the
mixed_chat_files.py:73 form.

Verified by replaying every _create_kernel_with_chat_completion call site in
samples/concepts/agents/mixed_chat/ against a stub built from that file's own def
with inspect.Signature.bind — before the change one of five call sites fails, after it
all five bind:

                              before                          after
mixed_chat_agents_plugins.py :90   OK                         OK
mixed_chat_files.py          :73   OK                         OK
mixed_chat_images.py         :60   TypeError: missing a       OK
                                   required argument:
                                   'credential'
mixed_chat_reset.py          :46   OK                         OK
mixed_chat_streaming.py      :50   OK                         OK

The sample still needs live Azure OpenAI resources to run end to end, so it was not
executed against a real deployment; the failure being fixed is a pure call-signature
mismatch that is reproducible without one.

Contribution Checklist

🤖 Generated with Claude Code

…ion in mixed_chat_images

The helper in this sample takes (service_id, credential), like the four
other mixed_chat samples, but the call site only passes service_id, so
the sample dies with TypeError before it reaches the group chat.
Copilot AI lite review requested due to automatic review settings August 29, 2026 22:26
@Anai-Guo
Tai An (Anai-Guo) requested a review from a team as a code owner August 29, 2026 22:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a runtime TypeError in the Python mixed_chat_images sample by passing the required credential argument into the local _create_kernel_with_chat_completion(...) helper when constructing the ChatCompletionAgent, allowing the sample to run far enough to demonstrate its intended image/group-chat behavior.

Changes:

  • Pass credential=credential to _create_kernel_with_chat_completion(...) in mixed_chat_images.py when creating summary_agent.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): 59faa6498ae1
Model: claude-opus-4.8

Overview

This PR adds the already-in-scope credential argument to the single
_create_kernel_with_chat_completion(...) call site in the
mixed_chat_images.py sample, fixing a reproducible TypeError that crashed the
sample before it produced any output. The helper signature requires the argument
(no default), credential is unconditionally bound at the top of main() and
already reused for the assistant client, and the edit is byte-identical to the
sibling mixed_chat_files.py:73 form. The change introduces no new auth,
lifecycle, or compatibility surface and carries no residual risk warranting a
finding.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants