Skip to content

Add Microsoft Agent Framework plugin samples - #418

Merged
DABH merged 38 commits into
mainfrom
dabh/agent-framework-plugin
Nov 20, 2026
Merged

DABH merged 38 commits into
mainfrom
dabh/agent-framework-plugin

Conversation

@DABH

@DABH DABH commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

This PR adds samples for the new Temporal plugin for Microsoft Agent Framework that we just shipped on PyPI.

The usual samples are included: hello world, tools, MCP, human in the loop, middleware, multi-agent, structured output, streaming, continue-as-new and OpenTelemetry.

The MCP sample is a standalone uv project like openai_agents/mcp_v2, because the Strands and Google GenAI groups pin mcp<2 and the plugin needs mcp>=2.2.

The plugin requires temporalio>=1.36, which dropped Python 3.10, so the group carries python_version >= '3.11' markers and the lock forks. Will update this once the repo drops 3.10 overall (I see there's already a PR for this).

Note that there are side effects of using 1.36 that show up in this PR (outside the MAF-specific code). On 1.36 the SDK's ClientConnectConfig carries plugins, so 17 existing Client.connect(**config, plugins=...) calls now add their plugin to the config's plugins and pass **config, as the load_client_connect_config docstring asks. Also, claude_agent_sdk_plugin/human_in_the_loop now records its decision in the Update handler, since 1.36 delivers an Update and a Signal in one activation.

Why?

The plugin and its docs page need runnable, tested samples to quote.

Checklist

  1. No linked issue.

  2. How was this tested: 39 tests pass locally across the new and the Claude samples (12 on the time-skipping server, where the Claude suite skips itself), the standalone MCP test passes, lint is clean on 3.10 and 3.14, all on the published 0.0.1.

DABH added 17 commits November 12, 2026 22:40
temporalio 1.36 processes a workflow activation's jobs as one batch
(workflow logic flag 2), so a signal or update handler no longer runs
before the other jobs delivered in the same activation. When the decide
Update arrived in the same activation as the lost-connection failure of
the read Activity, the wait in ask_human was cancelled before it consumed
the decision and the finally block reset it, so the turn redone after a
Worker restart asked again.

Recording the decision in the handler itself, keyed by the pending call,
keeps it for the redone turn on 1.35 and 1.36. Fixes
tests/claude_agent_sdk_plugin/human_in_the_loop_test.py::test_decision_survives_a_worker_restart
on temporalio 1.36.0 (failed 3 of 3 runs before, passes 3 of 3 after;
3 of 3 on 1.35.0 before and after). The docs snippets
python-claude-agent-sdk-human-in-the-loop-approval and -decision change
with it.
An AssertionError in an Update handler fails the Workflow Task, which the
Worker retries while the Update stays stuck; an ApplicationError fails
only this Update. call_key is now a static method inside the
python-claude-agent-sdk-human-in-the-loop-approval snippet, so the quoted
code shows it. No marker name changes.
Both lock files move temporalio-agent-framework from b5ed079c to
1c2006ae on dabh/agent-framework-python; no signature the samples use
changed.
Both locks move temporalio-agent-framework from 1c2006ae to 509bfab4 on
dabh/agent-framework-python; the only change in each lock is that commit
hash.
DABH added 12 commits November 13, 2026 00:49
The plugin is now temporalio-microsoft-agent-framework, since an
unqualified agent framework could be anyone's, and the samples follow it
in the directory, the dependency group, the task queues, the snippet
markers and the uv source pin, which now points at the renamed plugin
revision. The framework's own agent_framework imports and the
agent-framework-openai distribution are Microsoft's names and stay as
they are.
Both locks move temporalio-microsoft-agent-framework from d20bc0c8 to
d374e26c on dabh/agent-framework-python; the only change in each lock is
that commit hash.
Since d374e26c a client with streaming_topic runs every model call as
the streaming Activity, with or without stream=True, so the sample calls
agent.run(prompt) and the README no longer says a topic needs
stream=True. The test's expectations were already met: one
invoke_model_streaming Activity and every update at the subscriber.
Both locks move temporalio-microsoft-agent-framework from d374e26c to
8b472d21 on dabh/agent-framework-python. Each lock changes the git
revision line and adds opentelemetry-api to the plugin's dependency
list, which the plugin now declares; no other package moves.
A turn sent during another turn's model call gets its reply from the run
the server delivers it to, and an end_chat sent during a turn ends the
chat after that turn. The sample's turns are Updates, so nothing waits
in Workflow fields at the handoff; the README and the module docstring
say so, and the new test drives three turns and the end_chat across a
continue-as-new chain with a slow scripted client.
Both locks move temporalio-microsoft-agent-framework from 8b472d21 to
a453fa6c on dabh/agent-framework-python. The mcp project's lock also
moves temporalio-mcp from 0.3.0 to 0.4.0, which the plugin now requires;
no other package moves.
Both locks move temporalio-microsoft-agent-framework from a453fa6c to
54998df8 on dabh/agent-framework-python; the only change in each lock is
that commit hash. agent-framework-core stays at 1.26.0 here: this
repository has no cooldown, and the plugin's floor allows it.
ai-integrations#522 merged as e7303bbc, the same tree as 54998df8, and
the branch was deleted, so both [tool.uv.sources] entries now name the
commit with rev instead of the branch. Each lock changes its source line
and the dependency reference accordingly; no package moves.
On temporalio 1.36 the SDK's ClientConnectConfig carries plugins, so
mypy rejects Client.connect(**config, plugins=[...]) as passing plugins
twice. The SDK's load_client_connect_config docstring asks callers to
combine their plugins with the config's plugins rather than pass them
separately, and these 17 sites now do that and pass **config alone. The
config is copied into a plain dict first because the Python 3.10 cell
lints against temporalio 1.35, whose ClientConnectConfig has no plugins
key.
The plugin is published, so both [tool.uv.sources] git entries go and
the group and the mcp project pin temporalio-microsoft-agent-framework
>=0.0.1 the way the other plugin samples pin theirs. In each lock only
the plugin moves, from 0.0.0 at e7303bbc to 0.0.1 on PyPI.
@DABH
DABH marked this pull request as ready for review November 16, 2026 03:03
@DABH
DABH requested review from a team as code owners November 16, 2026 03:04
DABH added 6 commits November 16, 2026 23:31
Once the Workflow is complete, subscribe reads the rest of the stream
and then ends, so the starter awaits the consume task after
handle.result() and drops the drain loop, its 10-second timeout and the
printed list. The test does the same without the early return, and
checks that a subscriber that starts after the Workflow completed still
gets every update.
@workflow.init gives __init__ the ChatInput and runs before any handler,
so the agent and the session exist when a turn arrives with the start
or right after a continue-as-new. turn loses its wait and assert, and
transcript its None check.
The project installs the plugin on 3.11 and later, so an ImportError
there is a failure, not a reason to collect nothing and stay green. The
guard now skips collection below 3.11 only.
Agent Framework starts invoke_agent from Workflow code, and the replay-
safe provider is why the sample uses create_tracer_provider(). The
Worker replays the Workflow (max_cached_workflows=0), so the test now
checks that the span appears once, with RunWorkflow:TracedWorkflow as
its parent and the caller's trace id.
/tmp/../etc/passwd passed the startswith check. The middleware now
normalizes the path with posixpath.normpath first, which has no side
effects and works in the Workflow sandbox; the import sits inside the
quoted snippet region. The test adds that path and the README says so.
validate_decide rejects the Update when nothing is pending, and nothing
runs between the validator and the handler, so the branch is not
reachable; it narrows the type for the checker, and raising
ApplicationError there fails only the Update if that ever changed.
@DABH DABH mentioned this pull request Nov 17, 2026
The .NET sample does the same, so both report `/tmp/../etc/passwd` for that call.
On CI's Python 3.10 runners their Workflows trip the two-second deadlock detector, and the evicted run never finishes, so the job hangs until its 30-minute timeout. CI still runs them on 3.14.
@DABH
DABH merged commit 3cee3b5 into main Nov 20, 2026
26 of 27 checks passed
@DABH
DABH deleted the dabh/agent-framework-plugin branch November 20, 2026 17:42
DABH added a commit that referenced this pull request Nov 20, 2026
Keeps this branch's form of the langsmith chatbot starter and relocks from this branch's uv.lock, which adds the Agent Framework sample group from #418.
DABH added a commit that referenced this pull request Nov 20, 2026
#418 copied the config into a plain dict at these call sites because 3.10 resolved temporalio 1.35, whose ClientConnectConfig has no plugins key. This branch requires 3.11 and 1.36, so they go back to the typed form.
DABH added a commit that referenced this pull request Nov 20, 2026
#418 skipped them on 3.10, where their Workflows hung CI. This branch no longer runs 3.10.
DABH added a commit to temporalio/documentation that referenced this pull request Nov 20, 2026
The samples merged in temporalio/samples-python#418, so the page now carries their code.
VegetarianOrc added a commit that referenced this pull request Nov 20, 2026
* Update dependencies and upgrade Temporal Python SDK to 1.36.0

* Record human approval decisions before completing updates

* Revert human approval behavior and test changes

* Upgrade Go workflow sample to Temporal SDK v1.51.0

* Drop the client config copies that only Python 3.10 needed

#418 copied the config into a plain dict at these call sites because 3.10 resolved temporalio 1.35, whose ClientConnectConfig has no plugins key. This branch requires 3.11 and 1.36, so they go back to the typed form.

* Remove the Python 3.10 skip from the Google ADK tests

#418 skipped them on 3.10, where their Workflows hung CI. This branch no longer runs 3.10.

* Drop the arize_tracing exclusion for Python 3.10

---------

Co-authored-by: DABH <DABH@users.noreply.github.com>
Duncanma pushed a commit to temporalio/documentation that referenced this pull request Nov 24, 2026
* Add Microsoft Agent Framework Python integration docs

Add docs/develop/python/integrations/agent-framework.mdx for the
temporalio-agent-framework plugin, register it first in the Python
Integrations sidebar category, list it on the Python SDK index page, and
add its IntegrationsGrid entry.

The snippet blocks are empty on purpose. They reference markers in the
samples-python agent_framework_plugin samples, which are not on main yet.
Run yarn snipsync after that PR merges, before marking the docs PR ready.

* Revise the Agent Framework page after its first review

Describe the streamed Activity result as the plugin now records it:
text runs and tool-call argument deltas merged, one payload under the
2 MiB limit, and a retried stream publishing from its first update again.
State the Python floor as the plugin's requires-python, lead the install
with the package alone and move the mcp extra to the MCP section, match
the middleware and approval prose to the samples (a Decision with the
request id, a validator that checks the input, a handler that checks the
state), explain add_temporal_spans=True and show the tracer provider
call, give the heartbeat numbers, and spell out identifier outside code.

* Revise the Agent Framework page after its second review

Say that each published streaming batch is a Signal that counts toward
the 10,000 a Workflow Execution can receive, so a chat that streams has
to Continue-As-New sooner, and name that limit as the second
non-retryable StreamError case. Make the unknown-model-name failure per
Worker, add the MCP tool classes and the OpenTelemetry globals to the
limitations list, describe the lock, end_chat Signal and transcript
Query the continue-as-new snippet shows, and apply the wording nits:
run commands for hello world, exhausted MCP Activities, run-level tool
collisions, the MCPPlugin name clash, compaction, the OTLP endpoint
variable, and "Out of scope" as the label.

* Rename the page to microsoft-agent-framework

The short name is too generic: any vendor, Temporal included, could
publish an agent framework, so the integration takes the product's full
name. The plugin and the samples are renamed the same way, and the
page's slug, sidebar entry, grid href, install commands, imports, class,
error and Activity names and links follow them.

* Match the Agent Framework page to the plugin's parity pass

The plugin changed after the second review: a client with
streaming_topic now runs every call through the streaming Activity and
publishes on each one, batches cap at 256 updates, activity_as_tool
needs a timeout when the tool is built, a raising or wrong-type factory
fails the Activity once with a typed error, hosted MCP headers move to
the Worker through hosted_mcp_headers, sync tools run inline through a
rebound asyncio.to_thread, and Retry-After dates are parsed. Say each of
those, and add the loop settings, the unanswered-approval behavior, the
version-qualified MCP heartbeat sentence and the unregistered-server
case.

* Update the Agent Framework page for the plugin's review changes

The plugin changed after a maintainer review: the plugin goes on
Client.connect, because only a plugin on the Client sets the data
converter and provider imports must stay out of the sandboxed Workflow
file; TemporalChatClient sends store=False unless set; a factory that
raises is retried while None or a wrong type fails once; the stream
error type is MicrosoftAgentFrameworkStreamError; MCP tool names are
normalized as MCPTool does and temporalio-mcp is described at 0.3 only;
client_kwargs are recorded in Event History and credential headers are
refused; structured output sends the strict schema; prompts arriving
mid-run must be carried across Continue-As-New; Retry-After parses as
seconds or milliseconds, capped at 60 seconds; the seam error names the
tested range.

* Describe MCP heartbeats on the Agent Framework page

The plugin now requires temporalio-mcp 0.4, whose MCP Activities
heartbeat by default with a 10-second heartbeat timeout, so a cancel
reaches a running request and a lost Worker is noticed within seconds.
Replace the sentence that said the provider sets no heartbeat timeout
and that 0.3 does not heartbeat, name the heartbeat_timeout option on
TemporalMCPToolProvider (None turns heartbeats off), and name the 0.4
floor where the mcp extra is installed.

* Carry the tested range and connector token rules onto the page

The plugin now defines its tested range as the floor it was first
tested on through the version its lock pins, which CI runs on every
change, so the range is 1.23.0 through 1.24.0; the runtime seam error
names that range. For a hosted MCP connector tool, the authorization
entry in hosted_mcp_headers goes to the tool's authorization field as
the bare token, with a leading "Bearer " dropped, because the Responses
API takes the bare token there.

* Sync the Agent Framework snippets from samples-python

The samples merged in temporalio/samples-python#418, so the page now carries their code.

* Say the middleware sample normalizes the path before its check

* Update the MCP page for temporalio-mcp 0.4

temporalio-mcp 0.4 sends Heartbeats with a 10-second default Heartbeat Timeout, so a cancel reaches a running request, and it requires Python 3.11 and Temporal Python SDK 1.36. The page still said MCP Activities do not heartbeat, which contradicted the Agent Framework page that links to it.
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