Skip to content

Commit ab51aaa

Browse files
committed
refactor: Remove unnecessary TYPE_CHECKING guard for StateModelBundle import and clarify bundle override logic
Signed-off-by: Roberto Rodriguez <[email protected]>
1 parent e763544 commit ab51aaa

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

dapr_agents/agents/components.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import random
55
import time
66
from datetime import datetime, timezone
7-
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Sequence
7+
from typing import Any, Callable, Dict, Optional, Sequence
88

99
from dapr.clients.grpc._state import Concurrency, Consistency, StateOptions
1010
from pydantic import BaseModel, ValidationError
@@ -14,14 +14,12 @@
1414
AgentRegistryConfig,
1515
AgentStateConfig,
1616
DEFAULT_AGENT_WORKFLOW_BUNDLE,
17+
StateModelBundle,
1718
)
1819
from dapr_agents.agents.schemas import AgentWorkflowEntry
1920
from dapr_agents.storage.daprstores.stateservice import StateStoreError
2021
from dapr_agents.types.workflow import DaprWorkflowStatus
2122

22-
if TYPE_CHECKING:
23-
from dapr_agents.agents.configs import StateModelBundle
24-
2523
logger = logging.getLogger(__name__)
2624

2725

@@ -46,7 +44,7 @@ def __init__(
4644
registry: Optional[AgentRegistryConfig] = None,
4745
base_metadata: Optional[Dict[str, Any]] = None,
4846
max_etag_attempts: int = 10,
49-
default_bundle: Optional["StateModelBundle"] = None,
47+
default_bundle: Optional[StateModelBundle] = None,
5048
) -> None:
5149
"""
5250
Initialize component wiring.
@@ -84,6 +82,9 @@ def __init__(
8482

8583
bundle = None
8684
if state is not None:
85+
# Allow default_bundle to override the state's bundle. This enables
86+
# orchestrators and agents to share the same AgentStateConfig instance
87+
# while each using their own specialized state model schemas.
8788
if default_bundle is not None:
8889
state.ensure_bundle(default_bundle)
8990
try:

dapr_agents/agents/orchestrators/base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import asyncio
44
import logging
55
from collections.abc import Coroutine
6-
from typing import TYPE_CHECKING, Any, Dict, Optional
6+
from typing import Any, Dict, Optional
77

88
import dapr.ext.workflow as wf
99

@@ -13,12 +13,10 @@
1313
AgentPubSubConfig,
1414
AgentRegistryConfig,
1515
AgentStateConfig,
16+
StateModelBundle,
1617
)
1718
from dapr_agents.agents.utils.text_printer import ColorTextFormatter
1819

19-
if TYPE_CHECKING:
20-
from dapr_agents.agents.configs import StateModelBundle
21-
2220
logger = logging.getLogger(__name__)
2321

2422

@@ -44,7 +42,7 @@ def __init__(
4442
agent_metadata: Optional[Dict[str, Any]] = None,
4543
runtime: Optional[wf.WorkflowRuntime] = None,
4644
workflow_client: Optional[wf.DaprWorkflowClient] = None,
47-
default_bundle: Optional["StateModelBundle"] = None,
45+
default_bundle: Optional[StateModelBundle] = None,
4846
) -> None:
4947
"""
5048
Initialize the orchestrator base.

0 commit comments

Comments
 (0)