The model seam: a chat model whose every call becomes a Temporal activity.
TemporalModel is a real BaseChatModel. Placed anywhere Deep Agents
expects a model, it routes each generation through the deepagents.invoke_model
activity instead of calling the provider inline. Because Deep Agents' sub-agents
inherit the parent's model instance by default, substituting this one object
makes every model call in the whole agent tree durable — no middleware injection
that a sub-agent could silently miss.
Two ways to get one:
- explicit — the user writes TemporalModel("anthropic:claude-...") and hands it to create_deep_agent(model=...); this is the public type users assert against;
- implicit — while running inside a workflow, the plugin patches
create_deep_agent so a bare model="anthropic:..." string is wrapped
automatically (see
install_model_patch).
Worker-wide dispatch defaults (activity options, streaming topic) live in
temporalio.contrib.deepagents._serde.Settings, a module global set by
the plugin. They live in _serde (not here) so the plugin can configure them
without importing this module — which would drag LangChain into plugin
construction. This module is under temporalio, which the workflow sandbox
passes through, so the object the workflow reads is the same one the plugin set.
| Function | install |
Route Deep Agents' model resolution through TemporalModel. |
| Function | uninstall |
Restore the original resolve_model / create_deep_agent. |
| Function | _as |
Re-shape a finished AIMessage as the AIMessageChunk a stream yields. |
| Function | _looks |
A single ActivityConfig has known option keys; a per-model map does not. |
| Function | _resolve |
Merge worker defaults with a per-instance override into execute_activity kwargs. |
| Function | _wrap |
Resolve a create_deep_agent model argument to a durable model. |
| Constant | _DEFAULT |
Undocumented |
| Variable | _original |
Undocumented |
| Variable | _original |
Undocumented |
Route Deep Agents' model resolution through TemporalModel.
Patches deepagents.graph.resolve_model (the seam create_deep_agent
uses for the main agent and every sub-agent) so a bare model="..."
string becomes a durable TemporalModel, and additionally wraps
deepagents.create_deep_agent to fire the advisory tool / checkpointer
warnings. Both only act when called inside a workflow, so importing
deepagents on a plain client / activity worker is unaffected. Idempotent.
str, instance_options: Mapping[ str, Any] | None) -> dict[ str, Any]:
(source)
¶
Merge worker defaults with a per-instance override into execute_activity kwargs.
Resolve a create_deep_agent model argument to a durable model.
A name string becomes a TemporalModel. A TemporalModel
passes through. Any other live BaseChatModel instance is rejected at the
workflow boundary: it has no name the activity could rebuild from, so it would
run its provider call inside the workflow — nondeterministic and unsafe.