Skip to content

Post Plan completion to the reply chain in 1:1 threads - #670

Merged
Corina (corinagum) merged 5 commits into
mainfrom
cg/glowing-guacamole
Nov 5, 2026
Merged

Corina (corinagum) merged 5 commits into
mainfrom
cg/glowing-guacamole

Conversation

@corinagum

Copy link
Copy Markdown
Contributor

Summary

Plan.complete() now lands in the thread of the message the user acted on in a 1:1 chat, the same place ctx.send puts it.
Before, Plan sent every activity to POST /v3/conversations/{id}/activities. A bare 1:1 conversation.id carries no thread, so the completion landed at the top level of the chat. Channels were not affected, because the channel conversation.id already carries ;messageid={root}.

ctx.plan() now reads channel_data (chat.id, reply_chain.id) from the inbound activity and stores it on the Plan as reply_chain. A standalone complete() then posts to /replyChains/{root}. The SDK does not read or modify conversation.id.

A Plan rebuilt from saved state (PlanOptions(**plan.model_dump(...), api_client=...)) keeps its placement. The field is left out of model_dump when 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 places message activities. The stream path is unchanged, and reply_to_id is still set on every Plan activity.

Public API change

New optional reply_chain on PlanOptions and Plan, and an exported PlanReplyChain model (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.

Copilot AI max review requested due to automatic review settings November 5, 2026 01:50
Corina (corinagum) and others added 2 commits November 4, 2026 17:53
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 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 PlanReplyChain and 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

Comment thread examples/plan/README.md Resolved
Copilot AI max review requested due to automatic review settings November 5, 2026 02:03

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.

🟡 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>
Copilot AI max review requested due to automatic review settings November 5, 2026 17:13

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.

🔵 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>
Copilot AI max review requested due to automatic review settings November 5, 2026 18:50
@corinagum
Corina (corinagum) merged commit 26ee328 into main Nov 5, 2026
9 checks passed
@corinagum
Corina (corinagum) deleted the cg/glowing-guacamole branch November 5, 2026 19:01

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.

🔵 Needs a closer look

The public PlanOptions docstring remains internally inconsistent about the outbound conversation target and serialized bindings when reply_chain is set.

No open issues 🎉

2 resolved since last review

Review effort: Max

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.

3 participants