Repository navigation
Python: Fix ChatKit integration sample startup and weather widgets - #9579
Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Conversation
The sample imported the removed FunctionResultContent type, so app.py failed with ImportError at startup. It also relied on a str subclass (WeatherResponse) surviving as the function result to carry WeatherData to the widget renderer, but tool results are now normalized to list[Content], so the weather widget could never render, and Role.USER no longer exists, which broke title generation and the city selector action. Pass a request-scoped weather_results list to get_weather through function_invocation_kwargs (read from FunctionInvocationContext.kwargs, never exposed to the model), detect the city selector marker via content.type, and use role="user". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Naveen Chatlapalli (1aifanatic)
deployed
to
github-app-auth
October 21, 2026 14:26 — with
GitHub Actions
Active
Naveen Chatlapalli (1aifanatic)
deployed
to
github-app-auth
October 21, 2026 14:26 — with
GitHub Actions
Active
Naveen Chatlapalli (1aifanatic)
deployed
to
github-app-auth
October 21, 2026 14:26 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused sample fixes align with current invocation and streaming contracts, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Updates the Python ChatKit sample to current Agent Framework APIs, restoring startup and weather widgets for #9578.
Changes:
- Passes weather widget data through a request-scoped tool invocation collector.
- Replaces removed imports and role constants with current APIs.
- Updates city-selector detection and simplifies action streaming.
| File | Description |
|---|---|
python/samples/05-end-to-end/chatkit-integration/app.py |
Fixes API compatibility and weather widget data handling. |
Review effort: Balanced
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Oct 22, 2026
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
The sample is updated consistently with the current function-result, role, and invocation-context APIs. The request-scoped weather_results collector keeps widget data isolated from the model and from concurrent requests.
6 of 7 tasks
This branch was successfully deployed
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
The ChatKit end-to-end sample (
python/samples/05-end-to-end/chatkit-integration/app.py) has drifted from the current core API (details and reproduction in #9578):FunctionResultContent, soapp.pyfails withImportErrorat startup.WeatherResponse(str)subclass soWeatherDatawould ride along oncontent.result. Tool results are now normalized tolist[Content], so that attribute is always lost and the weather widget never renders.Role.USERno longer exists (Roleis aNewType), which breaks title generation and thecity_selectedaction.Description & Review Guide
get_weathertakes aFunctionInvocationContextand appends itsWeatherDatato a request-scopedweather_resultslist read fromctx.kwargs.respond()andaction()pass that list viafunction_invocation_kwargs, the pattern fromsamples/02-agents/tools/function_tool_with_kwargs.py. The structured data never reaches the model, and the per-request list keeps concurrent requests isolated.WeatherResponsesubclass and theFunctionResultContentimports. Detect the city selector marker withcontent.type == "function_result".Role.USERwith"user".action()no longer needs an intercepting stream, so it passes the agent stream straight tostream_agent_response.function_invocation_kwargsis the pattern you want this sample to teach for tool-to-UI side data. An alternative is returning a JSON string and parsing it, which would expose structured data to the model.Verified locally by driving
respond()andaction()with a scripted chat client (the core tests'MockBaseChatClient, so tools run through the real function-invocation layer):mainapp.pyImportError: FunctionResultContentrespond()→get_weatherrespond()→show_city_selectoraction(city_selected)→get_weatherPyright on
app.pygoes from 4 errors to 0.ruff format --checkpasses.ruff checkreports the same two pre-existingE501lines asmain(a longNOTEcomment and a# fmt: skipline), neither of which this PR touches.Related Issue
Fixes #9578
AI Assistance
AI assistance details: Claude Code helped find the breakages, implement the fix, build the scripted-client verification harness, and draft this description and the linked issue.
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.🤖 Generated with Claude Code