From fe336b12c8ea058f39c379787a5cbdee5845f5ce Mon Sep 17 00:00:00 2001 From: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com> Date: Sun, 26 Apr 2026 10:30:48 +0000 Subject: [PATCH 1/2] docs(agents): document context-aware logger for DurableAgent Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com> --- .../dapr-agents/dapr-agents-core-concepts.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md b/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md index aedba05a229..fe336f0e05c 100644 --- a/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md +++ b/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md @@ -119,6 +119,26 @@ In Summary: - `DurableAgent` (Workflow-backed): Interaction is asynchronous—you trigger the agent once, and it runs autonomously in the background until completion. The conversation state and the execution are persisted and can resume across failures or restarts. +#### Replay-Aware Logging + +Because `DurableAgent` relies on Dapr Workflows, the underlying execution model uses event sourcing. This means the workflow code is re-executed (replayed) from the beginning to rebuild local state after awaiting external activities or tool calls. + +To prevent duplicate logs from polluting your output during these rehydration cycles, Dapr Agents provides a `ContextAwareLogger`. This logger automatically hooks into the `DaprWorkflowContext` and silently suppresses log records when the workflow is actively replaying. + +```python +from dapr_agents.utils import get_context_aware_logger + +# Initialize the logger at the module level +logger = get_context_aware_logger(__name__) + +@workflow_entry +def my_workflow(self, ctx: DaprWorkflowContext, wf_input: dict) -> str: + # This will only print once, even if the workflow suspends and replays 5 times + logger.info("Starting workflow execution...") + # ... +``` + + ## Core Agent Features An agentic system is a distributed system that requires a variety of behaviors and supporting infrastructure. From 236e821bbd841077d7b06964664c9a39f55ccee9 Mon Sep 17 00:00:00 2001 From: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com> Date: Wed, 20 May 2026 09:37:04 +0000 Subject: [PATCH 2/2] docs: address review nits (imports and formatting) Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com> --- .../en/developing-ai/dapr-agents/dapr-agents-core-concepts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md b/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md index fe336f0e05c..f8d615a49b8 100644 --- a/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md +++ b/daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md @@ -127,6 +127,7 @@ To prevent duplicate logs from polluting your output during these rehydration cy ```python from dapr_agents.utils import get_context_aware_logger +from dapr_agents.workflow.decorators import workflow_entry # Initialize the logger at the module level logger = get_context_aware_logger(__name__) @@ -138,7 +139,6 @@ def my_workflow(self, ctx: DaprWorkflowContext, wf_input: dict) -> str: # ... ``` - ## Core Agent Features An agentic system is a distributed system that requires a variety of behaviors and supporting infrastructure.