Temporal+Stompy

Durable workflows with durable memory

Workflows that survive, knowledge that persists

The Problem

Temporal is durability perfected. Workflows that survive anything—crashes, restarts, infrastructure failures, even datacenter outages. Your business-critical logic is indestructible. You've built saga patterns, compensation handlers, long-running workflows that span days. State machines that guarantee exactly-once execution.

But durability isn't the same as memory.

Your order processing workflow is bulletproof. It handles payment failures, inventory checks, shipping coordination. But when order #50,001 comes in from the same customer who had issues with orders #42,847 and #49,221, your workflow has no idea. It can't learn from patterns across executions because each workflow instance is isolated—beautifully durable, completely amnesiac.

You've built retry logic that handles transient failures perfectly. But what about recurring issues? The payment provider that fails every Tuesday at 3 PM? The inventory service that times out during peak hours? Your workflows handle these failures—they don't predict or prevent them.

Temporal gives you time travel for workflows. You can replay, debug, understand what happened. But you can't give workflows knowledge of what typically happens. Each execution is a fresh start in a system designed for durability, not learning.

Durable execution needs durable knowledge.

How Stompy Helps

Stompy brings institutional memory to Temporal's durable execution model.

Your workflows gain cross-execution intelligence. Activities can recall patterns from thousands of previous runs before making decisions. The payment activity checks if this customer has historically needed manual intervention. The inventory activity knows which SKUs typically have availability issues.

This isn't stored in Temporal's event history—it's a separate memory layer specifically for patterns, insights, and learnings that span workflow boundaries.

Your durable workflows become learning workflows: - **Pattern detection activities**: Query Stompy for historical patterns before executing critical paths - **Outcome logging**: Save workflow outcomes as searchable context for future executions - **Failure prediction**: Recognize conditions that have historically caused issues - **Customer intelligence**: Build customer profiles from all workflow interactions, not just the current one

Temporal handles "what if this fails." Stompy handles "what typically happens and what should we know."

Integration Walkthrough

1

Create memory-aware Temporal activities

Build activities that can read from and write to Stompy's persistent memory.

from temporalio import activity
from dataclasses import dataclass
import httpx
import os
STOMPY_URL = "https://mcp.stompy.ai/sse"
STOMPY_TOKEN = os.environ['STOMPY_TOKEN']
@dataclass
class CustomerContext:
customer_id: str
historical_issues: list[str]
preferred_handling: str | None
@activity.defn
async def get_customer_intelligence(customer_id: str) -> CustomerContext:
"""Retrieve customer patterns from all previous workflow interactions."""
async with httpx.AsyncClient() as client:
response = await client.post(
STOMPY_URL,
headers={"Authorization": f"Bearer {STOMPY_TOKEN}"},
json={
"tool": "context_search",
"params": {
"query": f"customer:{customer_id} workflow outcomes",
"limit": 10
}
}
)
results = response.json().get("contexts", [])
return CustomerContext(
customer_id=customer_id,
historical_issues=[r["content"] for r in results if "issue" in r.get("tags", "")],
preferred_handling=results[0].get("handling") if results else None
)
2

Build learning workflows

Integrate memory activities into your Temporal workflows for context-aware execution.

from temporalio import workflow
from temporalio.common import RetryPolicy
from datetime import timedelta
@workflow.defn
class OrderWorkflow:
@workflow.run
async def run(self, order: Order) -> OrderResult:
# Get customer intelligence before processing
customer_ctx = await workflow.execute_activity(
get_customer_intelligence,
order.customer_id,
schedule_to_close_timeout=timedelta(seconds=30),
)
# Adjust processing based on historical patterns
if customer_ctx.historical_issues:
# Customer has had issues - use more careful handling
retry_policy = RetryPolicy(maximum_attempts=5)
else:
retry_policy = RetryPolicy(maximum_attempts=3)
# Process order with context-informed logic
result = await workflow.execute_activity(
process_order,
order,
retry_policy=retry_policy,
schedule_to_close_timeout=timedelta(minutes=5),
)
# Save outcome for future workflows
await workflow.execute_activity(
save_workflow_outcome,
WorkflowOutcome(
workflow_id=workflow.info().workflow_id,
customer_id=order.customer_id,
success=result.success,
issues=result.issues,
duration_ms=result.duration_ms
),
schedule_to_close_timeout=timedelta(seconds=30),
)
return result
3

Save outcomes for cross-workflow learning

Record workflow outcomes as searchable memory for future executions.

from temporalio import activity
from dataclasses import dataclass
import httpx
import json
@dataclass
class WorkflowOutcome:
workflow_id: str
customer_id: str
success: bool
issues: list[str]
duration_ms: int
@activity.defn
async def save_workflow_outcome(outcome: WorkflowOutcome) -> None:
"""Save workflow outcome for future pattern detection."""
content = f"""Workflow: {outcome.workflow_id}
Customer: {outcome.customer_id}
Success: {outcome.success}
Issues: {', '.join(outcome.issues) if outcome.issues else 'None'}
Duration: {outcome.duration_ms}ms"""
tags = ["temporal", "workflow-outcome"]
if not outcome.success:
tags.append("issue")
if outcome.issues:
tags.extend([f"issue:{issue}" for issue in outcome.issues])
async with httpx.AsyncClient() as client:
await client.post(
STOMPY_URL,
headers={"Authorization": f"Bearer {STOMPY_TOKEN}"},
json={
"tool": "lock_context",
"params": {
"topic": f"workflow_{outcome.workflow_id}",
"content": content,
"tags": ",".join(tags)
}
}
)

What You Get

  • Cross-workflow intelligence that detects patterns across thousands of executions
  • Customer context from all historical interactions available to every workflow
  • Failure prediction based on historical patterns and conditions
  • Memory that persists as durably as Temporal's own workflow state
  • Versioned context that aligns with Temporal's workflow versioning model

Ready to give Temporal a memory?

Join the waitlist and be the first to know when Stompy is ready. Your Temporal projects will never forget again.