USMAN’S INSIGHTS
AI ARCHITECT
  • Home
  • About
  • Thought Leadership
  • Book
Press / Contact
USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeBook
HomeBookThe Hybrid Engine: Combining Actors with Workflows
Previous Chapter
Workflow Patterns Saga Monitor
Next Chapter
Multi-App Workflows
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

15 sections

Progress0%
1 / 15

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a leading Agentic AI Architect and Software Engineer specializing in the design and deployment of multi-agent autonomous systems. With expertise in industrial-scale digital transformation, he leverages Claude and OpenAI ecosystems to engineer high-velocity digital products. His work is centered on achieving 30x industrial growth through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. Based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Book
  • About
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Combining Actors with Workflows

You've built actors that maintain state for individual entities. You've built workflows that orchestrate multi-step processes. Now the real power emerges: combining both to create systems where stateful entities participate in durable orchestration.

Consider an AI agent task management system. Each task needs its own state—title, status, deadline, assignee, history. That's perfect for a TaskActor. But completing a task isn't a single operation—it requires validation, assignment, notification, and status updates across multiple steps. That's perfect for a TaskProcessingWorkflow. The question isn't "actors OR workflows?" but "actors AND workflows working together."


The Decision Framework

When should you use actors, workflows, or both? Apply this analysis:

Use Actors When

CharacteristicExample
Entity has identityUser-123, Task-456, Device-789
Stateful ownershipConversation history, task status, device settings
Turn-based accessOnly one operation on this entity at a time
Entity timersDeadline notifications, session timeouts

Use Workflows When

CharacteristicExample
Multi-step processValidate -> Assign -> Notify -> Track
Durability requiredMust survive crashes, complete after restart
Parallel executionProcess 10 items concurrently, aggregate results
Compensation neededUndo step 2 if step 3 fails (saga pattern)
Human approvalWait hours/days for external event

The Hybrid Model

The most powerful systems leverage the strengths of both:

Actor ResponsibilityWorkflow Responsibility
Own entity state (Ground Truth)Orchestrate multi-entity processes
Enforce turn-based accessManage long-running operations
Handle entity-specific timersCoordinate parallel work
Maintain instance consistencyImplement global compensation logic

Pattern 1: Workflow Calling Actors

The most common hybrid pattern: workflows invoke actor methods through activities to update entity state at each orchestration step.

Replay-Safe Actor Invocations

Workflow code must be deterministic. Actor calls involve network I/O—you can't call them directly in workflow code. Instead, wrap actor invocations in activities:

python
from dapr.ext.workflow import WorkflowRuntime from dapr.actor import ActorProxy, ActorId from dataclasses import dataclass wfr = WorkflowRuntime() @dataclass class TaskStatusUpdate: task_id: str status: str # Activity that calls an actor @wfr.activity def update_task_status(ctx, update: TaskStatusUpdate) -> dict: """ Activity wrapping actor invocation. Activities CAN be non-deterministic (IO, external calls). """ from task_actor import TaskActorInterface proxy = ActorProxy.create( "TaskActor", ActorId(update.task_id), TaskActorInterface ) # Call actor method result = proxy.UpdateStatus(update.status) return {"task_id": update.task_id, "new_status": update.status}

Pattern 2: Actor Triggering Workflow

Sometimes state changes in an actor should kick off a workflow. For example, when a TaskActor's status changes to "ready_for_processing", it should start the processing workflow.

Actor with Workflow Triggering

python
class TaskActor(Actor, TaskActorInterface): async def submit_for_processing(self, assignee: str) -> dict: """ Submit task for processing - triggers a workflow. Actor coordinates with workflow for multi-step processing. """ task_data = await self._state_manager.get_state("task_data") # Don't re-submit if already processing if task_data.get("workflow_instance"): return {"success": False, "reason": "Already submitted"} # Start workflow client = DaprWorkflowClient() instance_id = client.schedule_new_workflow( workflow="task_processing_workflow", input={"task_id": self.id.id, "assignee": assignee}, instance_id=f"process-{self.id.id}" ) # Update actor state with workflow reference task_data["status"] = "processing" task_data["workflow_instance"] = instance_id await self._state_manager.set_state("task_data", task_data) await self._state_manager.save_state() return {"success": True, "workflow_instance": instance_id}

Designing State Boundaries

The key to hybrid systems is clear ownership of state and responsibility.

State ComponentOwnerRationale
Entity AttributesActorTitle, description, and core identity state.
Current StatusActorThe 'source of truth' for entity readiness.
Process ProgressWorkflowWhich orchestration step is currently active.
Retry StateWorkflowBackoff timings and attempt counters.
CompensationWorkflowHistory of what must be undone on failure.
History LogActorAudit trail of human/system interactions.

Reflect on Your Skill

Your dapr-deployment skill now covers actors and workflows separately. Extend it with hybrid patterns.

Test Your Skill

text
Using my dapr-deployment skill, design a system for processing customer orders: - Each order needs to track its own status and items - Orders go through: validate -> charge payment -> ship -> notify Should I use actors, workflows, or both? Explain the responsibilities.

Try With AI

Prompt 1: Design a Hybrid System

text
I'm building a task management system for AI agents. Help me design the architecture: Requirements: - Each task has status, assignee, deadline, and history - Tasks go through: create -> validate -> assign -> process -> complete - If assignment fails, task should return to unassigned state What components do I need? Should I use actors, workflows, or both? Show me the responsibilities of each component.

Prompt 2: Implement Workflow-to-Actor Communication

text
Show me how to implement a workflow activity that updates a TaskActor. The workflow should: 1. Validate the task 2. Update TaskActor status to "validated" 3. Assign to a user Include the activity functions and workflow code.

Prompt 3: Implement Actor-to-Workflow Triggering

text
Implement a TaskActor with a submit_for_processing method that: 1. Checks if task isn't already being processed 2. Starts a TaskProcessingWorkflow 3. Stores the workflow instance ID in actor state Also show me how to query both actor state and workflow status together.

Safety Note: When actors trigger workflows, ensure idempotency. The actor should check if a workflow is already running before starting a new one. Multiple workflow instances processing the same entity can cause status corruption.