Skip to content

Commit 40652e2

Browse files
authored
chore(docs): update docs to reflect removal of decorators in dapr/dapr-agents 405 (#5022)
Signed-off-by: Casper Nielsen <[email protected]>
1 parent fbee78b commit 40652e2

File tree

1 file changed

+57
-69
lines changed

1 file changed

+57
-69
lines changed

daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -337,91 +337,79 @@ Workflows are structured processes where LLM agents and tools collaborate in pre
337337
This approach is particularly suitable for business-critical applications where you need both the intelligence of LLMs and the reliability of traditional software systems.
338338

339339
```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
348341

342+
import dapr.ext.workflow as wf
349343

350-
@runtime.workflow(name="task_chain_workflow")
351-
def task_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()
356345

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.",
360-
llm=llm,
361-
)
362-
def get_character(ctx) -> str:
363-
pass
346+
@wfr.workflow(name="support_workflow")
347+
def support_workflow(ctx: wf.DaprWorkflowContext, request: dict) -> str:
348+
triage_result = yield ctx.call_child_workflow(
349+
workflow="agent_workflow",
350+
input={"task": f"Assist with the following support request:\n\n{request}"},
351+
app_id="triage-agent",
352+
)
353+
if triage_result:
354+
print("Triage result:", triage_result.get("content", ""), flush=True)
364355

356+
recommendation = yield ctx.call_child_workflow(
357+
workflow="agent_workflow",
358+
input={"task": triage_result.get("content", "")},
359+
app_id="expert-agent",
360+
)
361+
if recommendation:
362+
print("Recommendation:", recommendation.get("content", ""), flush=True)
365363

366-
@runtime.activity(name="get_line")
367-
@llm_activity(
368-
prompt="What is a famous line by {character}?",
369-
llm=llm,
370-
)
371-
def get_line(ctx, character: str) -> str:
372-
pass
364+
return recommendation.get("content", "") if recommendation else ""
373365

366+
wfr.start()
367+
time.sleep(5)
374368

375-
runtime.start()
376369
client = wf.DaprWorkflowClient()
377-
instance_id = client.schedule_new_workflow(task_chain_workflow)
378-
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",
373+
}
374+
instance_id = client.schedule_new_workflow(
375+
workflow=support_workflow,
376+
input=request,
397377
)
398-
def generate_outline(ctx, topic: str) -> str:
399-
pass
378+
client.wait_for_workflow_completion(instance_id, timeout_in_seconds=60)
379+
wfr.shutdown()
400380
```
401381

402-
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:
406383

407384
```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
414390

415-
@runtime.activity(name="plan_outline")
416-
@agent_activity(agent=planner)
417-
def plan_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.",
397+
],
398+
llm=DaprChatClient(component_name="llm-provider"),
399+
memory=AgentMemoryConfig(
400+
store=ConversationDaprStateMemory(
401+
store_name="agent-memory",
402+
session_id=f"expert-agent-session",
403+
)
404+
),
405+
)
406+
runner = AgentRunner()
407+
try:
408+
runner.serve(expert_agent, port=8001)
409+
finally:
410+
runner.shutdown(expert_agent)
419411
```
420412

421-
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-
425413
### Workflow Patterns
426414

427415
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

Comments
 (0)