You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md
+57-69Lines changed: 57 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -337,91 +337,79 @@ Workflows are structured processes where LLM agents and tools collaborate in pre
337
337
This approach is particularly suitable for business-critical applications where you need both the intelligence of LLMs and the reliability of traditional software systems.
338
338
339
339
```python
340
-
import dapr.ext.workflow as wf
341
-
from dapr.ext.workflow import DaprWorkflowContext
342
-
343
-
from dapr_agents.llm.dapr import DaprChatClient
344
-
from dapr_agents.workflow.decorators import llm_activity
345
-
346
-
runtime = wf.WorkflowRuntime()
347
-
llm = DaprChatClient(component_name="openai")
340
+
import time
348
341
342
+
import dapr.ext.workflow as wf
349
343
350
-
@runtime.workflow(name="task_chain_workflow")
351
-
deftask_chain_workflow(ctx: DaprWorkflowContext):
352
-
character =yield ctx.call_activity(get_character)
353
-
line =yield ctx.call_activity(get_line, input={"character": character})
354
-
return line
355
-
344
+
wfr = wf.WorkflowRuntime()
356
345
357
-
@runtime.activity(name="get_character")
358
-
@llm_activity(
359
-
prompt="Pick a random character from The Lord of the Rings. Respond with the name only.",
state = client.wait_for_workflow_completion(instance_id)
379
-
print(state.serialized_output)
380
-
runtime.shutdown()
381
-
```
382
-
383
-
This workflow demonstrates sequential task execution where the output of one LLM-backed activity becomes the input for the next. The `@llm_activity` decorator wires prompts, formatting, and response handling so activities stay deterministic while still using model reasoning.
384
-
385
-
Dapr Agents supports coordination of LLM interactions at different levels of granularity:
386
-
387
-
### LLM Activities
388
-
`@llm_activity` binds a workflow activity to a prompt, LLM client, and optional structured output. The decorated function body can stay empty because the decorator handles prompting, retries, and response parsing.
389
-
390
-
```python
391
-
llm = DaprChatClient(component_name="openai")
392
-
393
-
@runtime.activity(name="generate_outline")
394
-
@llm_activity(
395
-
prompt="Create a short outline about {topic}.",
396
-
llm=llm,
370
+
request = {
371
+
"customer": "alice",
372
+
"issue": "Unable to access dashboard after recent update",
LLM activities are perfect for lightweight reasoning steps, extraction tasks, or summarization stages that need deterministic workflow control with LLM flexibility.
403
-
404
-
### Agent Activities
405
-
`@agent_activity` lets workflows call fully-configured `Agent` instances (tools, memory, instructions) as activities. The workflow provides the inputs, and the decorator routes execution through the agent’s reasoning loop.
382
+
Here the `call_child_workflow` is used to invoke the workflow of two Dapr Agents and pass output from one as input to the other. This requires the `DurableAgent` to run as:
406
383
407
384
```python
408
-
planner = Agent(
409
-
name="PlannerAgent",
410
-
role="Trip planner",
411
-
instructions=["Create a concise 3-day plan for any city."],
412
-
llm=DaprChatClient(component_name="openai"),
413
-
)
385
+
from dapr_agents import DurableAgent
386
+
from dapr_agents.agents.configs import AgentMemoryConfig
387
+
from dapr_agents.llm.dapr import DaprChatClient
388
+
from dapr_agents.memory import ConversationDaprStateMemory
389
+
from dapr_agents.workflow.runners.agent import AgentRunner
414
390
415
-
@runtime.activity(name="plan_outline")
416
-
@agent_activity(agent=planner)
417
-
defplan_outline(ctx, destination: str) -> dict:
418
-
pass
391
+
expert_agent = DurableAgent(
392
+
name="expert_agent",
393
+
role="Technical Support Specialist",
394
+
goal="Provide recommendations based on customer context and issue.",
395
+
instructions=[
396
+
"Provide a clear, actionable recommendation to resolve the issue.",
Agent activities enable workflows to leverage specialized agents with their own tools, memory, and reasoning capabilities while maintaining the structured coordination benefits of workflow orchestration.
422
-
423
-
> **Note:** Agent activities must use regular `Agent` instances, not `DurableAgent` instances, because workflows manage the execution context and durability through the Dapr workflow engine.
424
-
425
413
### Workflow Patterns
426
414
427
415
Workflows enable the implementation of various agentic patterns through structured orchestration, including Prompt Chaining, Routing, Parallelization, Orchestrator-Workers, Evaluator-Optimizer, Human-in-the-loop, and others. For detailed implementations and examples of these patterns, see the [Patterns documentation]({{< ref dapr-agents-patterns.md >}}).
0 commit comments