Temporal Developer
OpenAIOfficialCreated by TemporalDistributed by OpenAI
- Skill
- Tool integration
- Software development
- MIT
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Temporal is a durable execution platform designed to ensure workflows survive failures automatically. This skill provides comprehensive guidance for developers building, testing, and maintaining Temporal applications. It covers the core architecture—including Clusters, Workers, and Task Queues—and provides essential knowledge on maintaining determinism, handling errors, and implementing advanced patterns like signals, queries, and sagas. The skill supports development across Python, TypeScript, Go, Java, .NET, Ruby, and Rust, offering specific references for each language.
What it does
- Provides guidance on building deterministic Workflow Definitions and Activity Implementations.
- Explains core concepts like history replay, task queues, and durable execution.
- Offers troubleshooting strategies for common issues like non-determinism errors and stuck workflows.
- Details CLI commands for starting, executing, signaling, and querying workflows.
- Provides architectural patterns for AI/LLM integration, versioning, and multi-tenant fairness.
- Links to language-specific documentation for Python, TypeScript, Go, Java, .NET, Ruby, and Rust.
When to use it
- When building or debugging workflows, activities, or workers using a Temporal SDK.
- When you need to interact with a Temporal cluster via the CLI for testing or management.
- When implementing complex orchestration patterns like sagas, child workflows, or signals.
- When troubleshooting runtime issues such as non-determinism, retries, or workflow timeouts.
- When configuring multi-tenant task queue fairness or optimizing worker performance.
Advantages
- Ensures workflow durability by providing patterns that survive system crashes.
- Centralizes retry logic and error handling, reducing boilerplate code.
- Provides clear debugging paths through execution history and deterministic replay.
- Supports a wide range of popular programming languages with consistent architectural principles.
- Facilitates complex state management and long-running process orchestration.
Usage examples
- “How do I start a new workflow from the command line?”
- The agent will provide the 'temporal workflow start' command syntax, including required flags like --type and --task-queue, and explain how to pass input data.
- “I am getting a non-determinism error in my workflow. How do I fix it?”
- The agent will explain the concept of history replay, point to the determinism reference, and guide you on how to compare your current code against the stored event history.
- “How should I handle LLM API calls within a Temporal workflow?”
- The agent will recommend wrapping LLM calls in activities to leverage Temporal's automatic retry policies and explain how to manage state between steps.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/openai/temporal-developer/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip temporal-developer.zip -d .agents/skills
Documentation by Temporal
Skill: temporal-developer
Overview
Temporal is a durable execution platform that makes workflows survive failures automatically. This skill provides guidance for building Temporal applications in Python, TypeScript, Go, Java, .NET, Ruby, and Rust.
Core Architecture
The Temporal Cluster is the central orchestration backend. It maintains three key subsystems: the Event History (a durable log of all workflow state), Task Queues (which route work to the right workers), and a Visibility store (for searching and listing workflows). There are three ways to run a Cluster:
Temporal CLI dev server — a local, single-process server started with
temporal server start-dev. Suitable for development and testing only, not production.Self-hosted — you deploy and manage the Temporal server and its dependencies (e.g., database) in your own infrastructure for production use.
Temporal Cloud — a fully managed production service operated by Temporal. No cluster infrastructure to manage.
Workers are long-running processes that you run and manage. They poll Task Queues for work and execute your code. You might run a single Worker process on one machine during development, or run many Worker processes across a large fleet of machines in production. Each Worker hosts two types of code:
Workflow Definitions — durable, deterministic functions that orchestrate work. These must not have side effects.
Activity Implementations — non-deterministic operations (API calls, file I/O, etc.) that can fail and be retried.
Workers communicate with the Cluster via a poll/complete loop: they poll a Task Queue for tasks, execute the corresponding Workflow or Activity code, and report results back.
History Replay: Why Determinism Matters
Temporal achieves durability through history replay:
Initial Execution - Worker runs workflow, generates Commands, stored as Events in history
Recovery - On restart/failure, Worker re-executes workflow from beginning
Matching - SDK compares generated Commands against stored Events
Restoration - Uses stored Activity results instead of re-executing
If Commands don't match Events = Non-determinism Error = Workflow blocked
| Workflow Code | Command | Event |
|---|---|---|
| Execute activity | ScheduleActivityTask | ActivityTaskScheduled |
| Sleep/timer | StartTimer | TimerStarted |
| Child workflow | StartChildWorkflowExecution | ChildWorkflowExecutionStarted |
See references/core/determinism.md for detailed explanation.
Getting Started
Ensure Temporal CLI is installed
Check if temporal CLI is installed. If not, follow the instructions at references/core/install_cli.md to install it for your platform.
Read All Relevant References
First, read the getting started guide for the language you are working in:
Python -> read
references/python/python.mdTypeScript -> read
references/typescript/typescript.mdGo -> read
references/go/go.mdJava -> read
references/java/java.md.NET (C#) -> read
references/dotnet/dotnet.mdRuby -> read
references/ruby/ruby.mdRust -> read
references/rust/rust.md(in Public Preview)
Second, read appropriate
coreand language-specific references for the task at hand.
Primary References
references/core/determinism.md- Why determinism matters, replay mechanics, basic concepts of activitiesLanguage-specific info at
references/{your_language}/determinism.md
references/core/patterns.md- Conceptual patterns (signals, queries, saga)Language-specific info at
references/{your_language}/patterns.md
references/core/gotchas.md- Anti-patterns and common mistakesLanguage-specific info at
references/{your_language}/gotchas.md
references/core/versioning.md- Versioning strategies and concepts - how to safely change workflow code while workflows are runningLanguage-specific info at
references/{your_language}/versioning.md
references/core/standalone-activities.md- Standalone Activities: run an Activity directly from a Client without a Workflow (Public Preview)Language-specific info at
references/{your_language}/standalone-activities.md
references/core/troubleshooting.md- Decision trees, recovery proceduresreferences/core/error-reference.md- Common error types, workflow status referencereferences/core/interactive-workflows.md- Testing signals, updates, queriesreferences/core/dev-management.md- Dev cycle & management of server and workersreferences/core/cli-workflow-commands.md- Developer-facing CLI commands for workflow interaction (start, execute, signal, query, update)references/core/ai-patterns.md- AI/LLM pattern conceptsLanguage-specific info at
references/{your_language}/ai-patterns.md, if available. Currently Python only.
Task Queue Priority and Fairness
If the developer is building a multi-tenant application, proactively recommend Task Queue Fairness. Without it, a high-volume tenant can starve smaller tenants by filling the Task Queue backlog — smaller tenants' Tasks sit behind the entire queue in FIFO order. Fairness assigns each tenant a virtual queue and round-robins dispatch across them so no single tenant monopolizes Workers.
Priority and Fairness also apply to tiered workloads (batch vs. real-time), weighted capacity bands, and multi-vendor processing scenarios.
references/core/priority-fairness.md- Priority keys, fairness keys and weights, rate limiting, SDK examples, and limitations
Additional Topics
references/{your_language}/observability.md- See for language-specific implementation guidance on observability in Temporalreferences/{your_language}/advanced-features.md- See for language-specific guidance on advanced Temporal features and language-specific features
Third-Party Integrations
For Temporal plugins and integrations with third-party frameworks and SDKs (Spring Boot, Spring AI, OpenAI Agents SDK, Google ADK, etc.), see references/integrations.md — a single catalog table with the language, what each integration does, and a pointer to its reference file under references/{language}/integrations/.
Feedback
Reporting Issues in This Skill
If you (the AI) find this skill's explanations are unclear, misleading, or missing important information—or if Temporal concepts are proving unexpectedly difficult to work with—draft a GitHub issue body describing the problem encountered and what would have helped, then ask the user to file it at https://github.com/temporalio/skill-temporal-developer/issues/new. Do not file the issue autonomously.
Files
- ATTRIBUTION.mdAdded by AutoGineer900 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md7.4 KiB
- references/core/ai-patterns.md5.5 KiB
- references/core/cli-workflow-commands.md9.8 KiB
- references/core/determinism.md6.4 KiB
- references/core/dev-management.md4.2 KiB
- references/core/error-reference.md3.0 KiB
- references/core/gotchas.md9.3 KiB
- references/core/install_cli.md1.3 KiB
- references/core/interactive-workflows.md1.3 KiB
- references/core/patterns.md14.7 KiB
- references/core/priority-fairness.md10.2 KiB
- references/core/standalone-activities.md8.1 KiB
- references/core/troubleshooting.md9.2 KiB
- references/core/versioning.md8.8 KiB
- references/dotnet/advanced-features.md6.6 KiB
- references/dotnet/data-handling.md5.7 KiB
- references/dotnet/determinism-protection.md2.7 KiB
- references/dotnet/determinism.md2.6 KiB
- references/dotnet/dotnet.md8.5 KiB
- references/dotnet/error-handling.md4.5 KiB
- references/dotnet/gotchas.md7.3 KiB
- references/dotnet/observability.md3.1 KiB
- references/dotnet/patterns.md13.9 KiB
- references/dotnet/standalone-activities.md6.0 KiB
- references/dotnet/testing.md5.7 KiB
- references/dotnet/versioning.md11.5 KiB
- references/go/advanced-features.md6.1 KiB
- references/go/data-handling.md7.6 KiB
- references/go/determinism-protection.md3.3 KiB
- references/go/determinism.md3.0 KiB
- references/go/error-handling.md5.6 KiB
- references/go/go.md7.7 KiB
- references/go/gotchas.md7.4 KiB
- references/go/observability.md5.4 KiB
- references/go/patterns.md15.7 KiB
- references/go/standalone-activities.md6.5 KiB
- references/go/testing.md6.4 KiB
- references/go/versioning.md9.7 KiB
- references/integrations.md5.1 KiB
- references/java/advanced-features.md6.5 KiB
- references/java/data-handling.md8.8 KiB
- references/java/determinism-protection.md3.4 KiB
- references/java/determinism.md3.4 KiB
- references/java/error-handling.md6.1 KiB
- references/java/gotchas.md5.4 KiB
- references/java/integrations/spring-ai.md12.7 KiB
- references/java/integrations/spring-boot.md10.0 KiB
- references/java/java.md10.0 KiB
- references/java/observability.md4.1 KiB
- references/java/patterns.md14.7 KiB
- references/java/standalone-activities.md5.3 KiB
- references/java/testing.md7.8 KiB
- references/java/versioning.md11.1 KiB
- references/python/advanced-features.md7.0 KiB
- references/python/ai-patterns.md10.3 KiB
- references/python/data-handling.md6.2 KiB
- references/python/determinism-protection.md6.9 KiB
- references/python/determinism.md2.0 KiB
- references/python/error-handling.md4.1 KiB
- references/python/gotchas.md7.3 KiB
- references/python/integrations/braintrust.md7.2 KiB
- references/python/integrations/google-adk.md10.5 KiB
- references/python/integrations/langgraph.md8.2 KiB
- references/python/integrations/langsmith.md9.3 KiB
- references/python/integrations/openai-agents-sdk.md20.1 KiB
- references/python/integrations/opentelemetry.md2.7 KiB
- references/python/integrations/pydantic-ai.md11.3 KiB
- references/python/observability.md3.2 KiB
- references/python/patterns.md12.1 KiB
- references/python/python.md8.0 KiB
- references/python/standalone-activities.md5.8 KiB
- references/python/sync-vs-async.md7.1 KiB
- references/python/testing.md4.9 KiB
- references/python/versioning.md12.6 KiB
- references/python/workflow-streams.md21.4 KiB
- references/ruby/advanced-features.md7.8 KiB
- references/ruby/data-handling.md3.9 KiB
- references/ruby/determinism-protection.md5.1 KiB
- references/ruby/determinism.md2.9 KiB
- references/ruby/error-handling.md2.7 KiB
- references/ruby/gotchas.md6.9 KiB
- references/ruby/observability.md2.2 KiB
- references/ruby/patterns.md10.2 KiB
- references/ruby/ruby.md6.1 KiB
- references/ruby/testing.md6.5 KiB
- references/ruby/versioning.md8.8 KiB
- references/rust/rust.md6.8 KiB
- references/typescript/advanced-features.md5.6 KiB
- references/typescript/data-handling.md5.9 KiB
- references/typescript/determinism-protection.md2.4 KiB
- references/typescript/determinism.md2.1 KiB
- references/typescript/error-handling.md3.3 KiB
- references/typescript/gotchas.md9.1 KiB
- references/typescript/integrations/braintrust.md3.7 KiB
- references/typescript/integrations/mastra.md7.5 KiB
- references/typescript/integrations/opentelemetry.md3.6 KiB
- references/typescript/integrations/vercel-ai-sdk.md8.4 KiB
- references/typescript/observability.md3.7 KiB
- references/typescript/patterns.md11.4 KiB
- references/typescript/standalone-activities.md5.8 KiB
- references/typescript/testing.md6.1 KiB
- references/typescript/typescript.md7.4 KiB
- references/typescript/versioning.md9.2 KiB
references/python/workflow-streams.md
Workflow Streams (Python)
[!NOTE] This feature is in Public Preview. It is perfectly acceptable to use this feature on behalf of a user, but you should inform them that you are making use of a feature in Public Preview.
Overview
temporalio.contrib.workflow_streams is a Python SDK contrib library that gives a Workflow a durable, offset-addressed event channel built on Temporal's basic message primitives: Signals, Updates, and Queries. It batch-publishes events, deduplicates batches for exactly-once delivery to the log, supports topic filtering, and carries state across Continue-As-New.
Use it for modest fan-out progress streaming: AI-agent runs, order pipelines, multi-step workflow status updates, etc. It targets "tens of publishers and subscribers per Workflow, not thousands"; it is not suited to ultra-low-latency cases like real-time voice.
Only available in the Python SDK today; cross-language is on the roadmap.
When to use / not to use
Use it for: updating a UI as an AI agent works; surfacing status from a payment or order pipeline; reporting intermediate results from a data job.
Skip it for: ultra-low-latency cases like real-time voice.
Skip it for: high fan-out — thousands of subscribers per Workflow.
Where to host the stream
A WorkflowStream is hosted inside a Workflow. The Workflow Id is the address subscribers attach to.
Same-Workflow hosting (common shape): the Workflow that does the work also hosts the stream. Its lifecycle aligns with the run. Use this for AI agents and most progress-streaming cases.
Dedicated Workflow: when the stream should outlive any single producer, accept fan-in from multiple unrelated sources, or be subscribable before any work has started. Producers publish from outside. Trade-off: explicit lifecycle management — the dedicated Workflow does not terminate on its own, so wire a signal-driven shutdown or a Continue-As-New strategy.
Multiple subscribers can attach to the same Workflow Id concurrently (e.g. a UI with multiple browser tabs).
Enable streaming on a Workflow
Import: from temporalio.contrib.workflow_streams import WorkflowStream
Construct WorkflowStream() from @workflow.init, not @workflow.run. The stream's handlers must be registered before the first publish Signal arrives; doing it from @workflow.run raises RuntimeError.
Constructing more than one WorkflowStream on the same Workflow also raises RuntimeError.
from dataclasses import dataclass
from temporalio import workflow
from temporalio.contrib.workflow_streams import WorkflowStream
@dataclass
class OrderInput:
order_id: str
@workflow.defn
class OrderWorkflow:
@workflow.init
def __init__(self, input: OrderInput) -> None:
self.stream = WorkflowStream()Construction creates the in-memory event log and dynamically registers the publish Signal, subscribe Update, and offset Query handlers.
Publish from a Workflow
Bind a topic name to its event type once via self.stream.topic("name", type=Type), then call publish() on the returned handle.
type= is optional and defaults to Any. The codec chain (encryption, compression) runs once on the Signal/Update envelope, never per item.
from dataclasses import dataclass
@dataclass
class StatusEvent:
state: str
progress: int = 0
detail: str = ""
@workflow.defn
class OrderWorkflow:
@workflow.init
def __init__(self, input: OrderInput) -> None:
self.stream = WorkflowStream()
self.status = self.stream.topic("status", type=StatusEvent)
@workflow.run
async def run(self, input: OrderInput) -> None:
self.status.publish(StatusEvent(state="validating", detail="checking inventory"))
await validate_order(input.order_id)
self.status.publish(StatusEvent(state="charging", progress=33, detail="authorizing payment"))
await charge_payment(input.order_id)
self.status.publish(StatusEvent(state="shipping", progress=66, detail="dispatching to warehouse"))
await dispatch_order(input.order_id)
self.status.publish(StatusEvent(state="completed", progress=100))Note: publish() is not awaited. Inside a Workflow it appends synchronously to the in-memory log.
Publish from a client (external process or Activity)
Any process holding a Temporal Client and the target Workflow Id can publish by constructing a WorkflowStreamClient. This is the general pattern; it covers HTTP backends, starters, one-off scripts, other Workflows' Activities, and standalone Activities.
General pattern: WorkflowStreamClient.create(client, workflow_id, batch_interval=...). Use it as an async with context manager so the buffer flushes on exit.
from datetime import timedelta
from temporalio.client import Client
from temporalio.contrib.workflow_streams import WorkflowStreamClient
async def publish_status(workflow_id: str) -> None:
temporal_client = await Client.connect("localhost:7233")
stream_client = WorkflowStreamClient.create(
temporal_client,
workflow_id=workflow_id,
batch_interval=timedelta(milliseconds=200),
)
async with stream_client:
status = stream_client.topic("status", type=StatusEvent)
status.publish(StatusEvent(state="started"))
# Buffer is flushed on context manager exit.Inside an Activity scheduled by a Workflow, WorkflowStreamClient.from_within_activity() is a convenience that infers the Temporal Client and the parent Workflow Id from the Activity context.
from temporalio import activity
from temporalio.contrib.workflow_streams import WorkflowStreamClient
@activity.defn
async def stream_deltas(order_id: str) -> None:
client = WorkflowStreamClient.from_within_activity()
async with client:
deltas = client.topic("delta", type=Delta)
for delta in generate_deltas(order_id):
deltas.publish(delta)
activity.heartbeat()For a standalone Activity (started directly via Client.start_activity), there is no parent Workflow context to infer, so from_within_activity() raises. Fall back to WorkflowStreamClient.create(activity.client(), workflow_id=...) with the Workflow Id threaded through the Activity input.
Publish from the Activity directly rather than returning events for the Workflow to forward; the Workflow hosts the stream but does not read its own stream.
force_flush=True vs. await client.flush()
These are two separate operations.
publish(..., force_flush=True)— wakes the background flusher so the current buffer ships without waiting for the nextbatch_interval. The call returns immediately after appending and signaling; it does not wait for delivery. The flusher only runs while the client is entered (async with client); outside that,force_flush=Truequeues the wake event but nothing ships until you enter the context or callawait client.flush(). Use it for latency-sensitive events: first delta, punctuated events likeRETRYorSTATUS_CHANGE.deltas.publish(delta, force_flush=True)await client.flush()— mid-stream barrier. Successful completion proves the Temporal server has received all prior publications. The client stays open afterward. Exitingasync with clientalready flushes on its way out; the explicit call is only for barriers in the middle.async with client: deltas = client.topic("delta", type=Delta) for delta in first_phase(): deltas.publish(delta) await client.flush() checkpoint_id = await record_phase_one_complete() for delta in second_phase(checkpoint_id): deltas.publish(delta)
Non-blocking publish, no backpressure
publish() is non-blocking and applies no backpressure. A slow subscriber does not slow publishers; if a publisher emits faster than batches can ship, the buffer grows.
If you need to bound this, apply a policy upstream of publish(). The library does not pick block/drop/error/sample for you.
Subscribe
Construct a client with WorkflowStreamClient.create(client, workflow_id), then iterate a topic handle's subscribe(). The bound type drives decoding; each item.data arrives as T.
from temporalio.client import Client
from temporalio.contrib.workflow_streams import WorkflowStreamClient
async def watch_order(order_id: str) -> None:
temporal_client = await Client.connect("localhost:7233")
stream = WorkflowStreamClient.create(temporal_client, workflow_id=order_id)
status = stream.topic("status", type=StatusEvent)
async for item in status.subscribe():
evt = item.data
print(f"[{evt.progress:3d}%] {evt.state}: {evt.detail}")
if evt.state == "completed":
breakThe iterator handles re-polling, pagination at the ~1 MB cap, and Workflow-side log truncation transparently.
Subscribing from inside the host Workflow is intentionally unsupported. The Workflow only sees the successful return value of each Activity; the stream may carry partial output from retried attempts. Letting the Workflow read its own stream would mix those two views and break the conduit role.
A subscriber stores the last delivered item.offset and reconnects resume from that offset.
Heterogeneous topics
To consume topics whose payload types differ, call client.subscribe() directly with a list of names and result_type=RawValue. Passing an empty list (subscribe([])) subscribes to every topic. Dispatch on item.topic; decode the wrapped payload with the client's payload converter.
from temporalio.common import RawValue
converter = temporal_client.data_converter.payload_converter
async for item in stream.subscribe(["status", "progress"], result_type=RawValue):
if item.topic == "status":
evt = converter.from_payload(item.data.payload, StatusEvent)
print(f"[status] {evt.state}: {evt.detail}")
elif item.topic == "progress":
evt = converter.from_payload(item.data.payload, ProgressEvent)
print(f"[progress] {evt.message}")A single iterator over multiple topics avoids the cancellation race that two concurrent subscribers would create.
Closing the stream
End-of-stream is application-level; Workflow Streams does not impose a marker. There is no stream.close() / stream.end_of_stream() API.
Without coordination, a subscriber keeps polling until the Workflow reaches a terminal state, and a Workflow that returns immediately after its last publish can lose that publish's poll round-trip in the gap.
A poll Update that is still in flight when the Workflow returns surfaces to the client as AcceptedUpdateCompletedWorkflow, and no new polls can complete after that. That's why an overlap is required.
The pattern is an in-band terminator the subscriber recognizes plus a brief overlap before the Workflow returns.
Pattern 1: fixed sleep (simplest)
# at the end of @workflow.run
self.status.publish(StatusEvent(state="completed", progress=100))
await workflow.sleep(timedelta(seconds=30))
return resultThirty seconds is a generous default.
Pattern 2: acknowledgment handshake
@workflow.signal
async def subscriber_acknowledged_terminator(self) -> None:
self.subscriber_done = True
@workflow.run
async def run(self, input: ChatInput) -> str:
...
try:
await workflow.wait_condition(
lambda: self.subscriber_done,
timeout=timedelta(seconds=30),
)
except TimeoutError:
pass # No subscriber attached; the run still completes cleanly.
return resultThe timeout is still required because the subscriber may not be attached. With the ack, the typical case exits as soon as the subscriber confirms.
Inspecting terminal status
subscribe() exits cleanly when the Workflow reaches COMPLETED, FAILED, CANCELED, TERMINATED, or TIMED_OUT, but does not distinguish among them. Call await temporal_client.get_workflow_handle(workflow_id).describe() after the loop to inspect the Workflow's status.
Continue-As-New (CAN)
Skip this section for short-lived Workflows (single chat completion, order pipeline). CAN is for streams that run for hours or accumulate thousands of events
Subscribers automatically follow Continue-As-New chains — the Workflow ID is stable, so the iterator fetches a fresh handle and continues polling from the carried offset.
To roll a long-running streaming Workflow over without subscribers seeing a gap, carry both your application state and the stream state across the boundary:
Add a
WorkflowStreamState | Nonefield to your Workflow input,pass it to the constructor as
WorkflowStream(prior_state=...),and call
WorkflowStream.continue_as_new(build_args)to invoke the rollover. The helper drains waiting subscribers, waits for in-flight handlers to finish, then callsworkflow.continue_as_newwith the args produced bybuild_args(post_drain_state).
from dataclasses import dataclass, field
from temporalio import workflow
from temporalio.contrib.workflow_streams import WorkflowStream, WorkflowStreamState
@dataclass
class AppState:
items_processed: int = 0
@dataclass
class WorkflowInput:
app_state: AppState = field(default_factory=AppState)
stream_state: WorkflowStreamState | None = None
@workflow.defn
class LongRunningWorkflow:
@workflow.init
def __init__(self, input: WorkflowInput) -> None:
self.app_state = input.app_state
self.stream = WorkflowStream(prior_state=input.stream_state)
@workflow.run
async def run(self, input: WorkflowInput) -> None:
while True:
await do_one_iteration(self)
if workflow.info().is_continue_as_new_suggested():
await self.stream.continue_as_new(
lambda stream_state: [
WorkflowInput(
app_state=self.app_state,
stream_state=stream_state,
)
]
)Hard constraint: the field type must be WorkflowStreamState | None, not Any. With Any, the data converter rebuilds the field as a plain dict and WorkflowStream(prior_state=...) raises AttributeError accessing .log / .base_offset / .publishers on the dict.
To pass other CAN parameters (task_queue, retry_policy, run_timeout), use the explicit recipe:
self.stream.detach_pollers()
await workflow.wait_condition(workflow.all_handlers_finished)
workflow.continue_as_new(
args=[WorkflowInput(app_state=self.app_state, stream_state=self.stream.get_state())],
task_queue="other-tq",
)The carried WorkflowStreamState includes the entire in-memory log of the previous run. Offload large items via External Storage so each item is a small reference, and combine with truncate() to keep the carried log itself small.
Tuning
The driving question: how often should the UI update? That answer trades user-perceived latency against history events accumulated. Each batched publish is one Signal; each subscriber poll is one Update; both accumulate against the Workflow's history.
| Setting | Default | Notes |
|---|---|---|
batch_interval | 2 seconds | Maximum time between automatic flushes. 200 ms is a good start for LLM token streams. Below 100 ms the per-Signal RPC overhead starts to dominate. |
max_batch_size | unbounded | Cap by item count to stay under Temporal's per-message gRPC payload limit. |
poll_cooldown | 100 ms | Subscriber sleeps this interval between polls. Skipped only when a poll response hit the ~1 MB cap with more items remaining (more_ready). |
max_retry_duration | 10 minutes | How long a WorkflowStreamClient retries a failed publish batch before raising TimeoutError. |
publisher_ttl | 15 minutes | How long the Workflow retains per-publisher dedup state; entries older than this drop at each CAN. |
Invariant: max_retry_duration < publisher_ttl. Defaults (10 min < 15 min) satisfy this. If a publisher's retry window exceeds the dedup retention, a retry that arrives after its dedup record has been pruned is treated as a fresh publish, and if the original delivery had also succeeded the same logical batch lands twice.
force_flush=True is a per-publish latency knob. Use it for the first delta or punctuated events like RETRY and STATUS_CHANGE. Don't use it per-token or per-character: per-character force_flush=True is not tractable.
Hold a single subscriber iterator and consume from it rather than opening and closing subscriptions in a loop.
Delivery semantics
Exactly-once at the execution layer. Each (publisher_id, sequence) batch lands in the Workflow's event log at most once, even if the Signal is retried by the SDK or the network. Dedup state is carried across Continue-As-New.
Ordering.
The log imposes a single total order on all events, fixed once written: an event at offset N stays at offset N on every read.
Within one publisher, events appear in publish order.
Across concurrent publishers, the interleaving is whatever the Workflow saw when serializing inbound Signals; stable once recorded but not under application control.
If event A must precede event B, publish them from the same publisher.
Activity retries surface to subscribers. Both attempts' events appear in the stream. The Workflow itself only sees the successful attempt's return value; a UI subscribed to the stream will see partial output unless it dedupes.
Conventional pattern: an Activity on a retry attempt publishes a RETRY event with force_flush=True; the consumer clears or annotates prior-attempt output when it sees one. Build an idempotent consumer reducer: overwrite on terminal events like STATUS_CHANGE or TEXT_COMPLETE; reset an accumulator on a sentinel like AGENT_START before deltas resume.
Other failure modes.
Events still in a publisher's in-memory client buffer are lost if the process crashes before they ship.
Subscribers that handle an item and crash before persisting their next offset will reprocess that item on resume.
On
max_retry_durationexhaustion, aTimeoutErrorraises from inside the background flusher task and terminates it; until you callawait client.flush()or exit theasync withblock, subsequent publishes accumulate with no flusher to ship them. The dropped batch is at-most-once: may or may not have reached the Workflow.
Architecture
Append-only in-memory log inside the Workflow. Each entry is (topic, data) with a monotonically increasing global offset. Subscribers maintain their own cursor; each long-poll receives the next range past it. The log is replay-safe and carried across Continue-As-New via WorkflowStreamState.
Two mechanisms bound log growth, and they do different jobs:
truncate(up_to_offset)drops entries from the in-memory log (and from the carried CAN payload). It does not remove publish Signals already recorded in history.Continue-As-New starts a fresh history. This is the only way to shrink history; truncate alone cannot.
A subscriber whose offset falls below the new base after truncate() is silently advanced; the iterator does not raise, but the subscriber may re-receive items already in the log past the new base.
Wire-level handler names (registered when you construct a WorkflowStream):
__temporal_workflow_stream_publish— Signal that receives batched publishes.__temporal_workflow_stream_poll— long-poll Update that subscribers use.__temporal_workflow_stream_offset— Query that reports the current head offset.
Poll responses are capped at roughly 1 MB, by accumulating items until the next would exceed the budget. A single item that exceeds 1 MB on its own is admitted unconditionally; offload via External Storage.
Batch dedup applies at the Signal layer, not the Activity layer. When Temporal retries the Activity, the retried execution constructs a new WorkflowStreamClient with its own client id, so every Activity attempt is a fresh publisher whose batches will not deduplicate against the prior attempt's.
Gotchas
WorkflowStreamClientis asyncio-only. The client buffer is mutated on the publish path and read from the flusher inside a single event loop. Don't callpublish()from a worker thread.First-activation handler race. On the very first activation a publish Signal can be queued before class-level
@workflow.signalor@workflow.updatehandlers have run. The fix: make the handlerasync defandawaitonce before reading state. Useasyncio.sleep(0)— a no-op yield that adds no history events. Do not substituteworkflow.sleep(0)— it records a timer event.Type bindings are per-instance. Each
WorkflowStreamand eachWorkflowStreamClientrecords topic types only for its own instance. If two publishers bind the same topic name to different types, the mismatch is not caught at publish; the subscriber gets a decode error on events from the mismatched publisher.
See also
Workflow Streams samples (samples-python) — basic publish/subscribe, reconnecting subscribers, external publishers, bounded logs.
references/python/patterns.md— Signals/Queries/Updates primitives this builds on.references/python/ai-patterns.md— LLM patterns.
Requirements and compatibility
Written for: OpenAI Codex
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Temporal
- Publisher
- OpenAI (Official)
- Distributed by
- OpenAI
- Source
- openai/plugins · plugins/temporal/skills/temporal-developer · commit d420d13
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from plugins/temporal/LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Temporal or OpenAI.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download temporal-developer.zip