Repository navigation
Post Plan completion to the reply chain in 1:1 threads - #670
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
a56b0f0 to
f62a569
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The documentation misstates reply-chain routing and omits the serialization options needed to prevent a KeyError when restoring a Plan.
2 open issues
What changed in this PR
Updates the Teams SDK so standalone Plan.complete() responses stay in the inbound 1:1 message thread, including when a Plan is restored from saved state.
Changes:
- Capture chat reply-chain placement and use it for completions, leaving typing and streaming behavior unchanged.
- Export
PlanReplyChainand preserve optional placement metadata without changing legacy serialized shapes. - Add routing and serialization tests, and update the Plan example documentation.
| File | Description |
|---|---|
packages/apps/tests/test_plan.py |
Tests saved placement, legacy serialization, and typing routing. |
packages/apps/tests/test_activity_context.py |
Tests completion placement in chat threads, top-level chats, and channels. |
packages/apps/src/microsoft_teams/apps/routing/activity_context.py |
Binds Plans to the inbound chat reply chain. |
packages/apps/src/microsoft_teams/apps/plan.py |
Adds placement metadata, serialization support, and reply-chain completion routing. |
packages/apps/src/microsoft_teams/apps/__init__.py |
Exports PlanReplyChain. |
examples/plan/README.md |
Documents reply-chain metadata in saved Plans. |
Review effort: Max
There was a problem hiding this comment.
🟡 Changes recommended
Active documentation issues misdescribe reply-chain routing and recommend serialization without by_alias=False, causing the documented Plan reconstruction path to raise KeyError.
2 open issues
1 resolved since last review
Review effort: Max
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The public Plan docstring still contradicts the implementation by claiming conversation_id is always the outbound target and describing serialized state without reply_chain.
No open issues 🎉
2 resolved since last review
Review effort: Max
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Summary
Plan.complete()now lands in the thread of the message the user acted on in a 1:1 chat, the same placectx.sendputs it.Before,
Plansent every activity toPOST /v3/conversations/{id}/activities. A bare 1:1conversation.idcarries no thread, so the completion landed at the top level of the chat. Channels were not affected, because the channelconversation.idalready carries;messageid={root}.ctx.plan()now readschannel_data(chat.id,reply_chain.id) from the inbound activity and stores it on the Plan asreply_chain. A standalonecomplete()then posts to/replyChains/{root}. The SDK does not read or modifyconversation.id.A Plan rebuilt from saved state (
PlanOptions(**plan.model_dump(...), api_client=...)) keeps its placement. The field is left out ofmodel_dumpwhen unset, so previously saved shapes load and re-serialize unchanged.Typing activities (start, update, stop, error) stay on the conversation, matching
ctx.send, which only placesmessageactivities. The stream path is unchanged, andreply_to_idis still set on every Plan activity.Public API change
New optional
reply_chainonPlanOptionsandPlan, and an exportedPlanReplyChainmodel (chat_or_channel_id,reply_chain_id). The plan example README no longer says serialization contains only two IDs.Testing
Unit tests cover the placed completion, a rebuilt Plan keeping its chain, a saved shape without one, and the
ctx.plan()fill for a 1:1 thread, a top-level message and a channel thread.