Spaces:
Runtime error
Runtime error
Update agents/state.py
Browse files- agents/state.py +8 -2
agents/state.py
CHANGED
|
@@ -5,6 +5,12 @@ Agent state definition for the pharmaceutical data management system.
|
|
| 5 |
import operator
|
| 6 |
from typing import Dict, List, Any, Literal, TypedDict, Optional, Annotated
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
class AgentState(TypedDict):
|
| 9 |
"""
|
| 10 |
State definition for the pharmaceutical data management agents.
|
|
@@ -28,5 +34,5 @@ class AgentState(TypedDict):
|
|
| 28 |
# Status remains a single-value key
|
| 29 |
status: Literal["planning", "executing", "complete", "error", "pending_approval"]
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
current_agent: str
|
|
|
|
| 5 |
import operator
|
| 6 |
from typing import Dict, List, Any, Literal, TypedDict, Optional, Annotated
|
| 7 |
|
| 8 |
+
# Define a reducer function for current_agent
|
| 9 |
+
# This function will take the last value in case of conflicts
|
| 10 |
+
def last_value_reducer(existing_value: str, new_value: str) -> str:
|
| 11 |
+
"""Returns the new value, effectively taking the last agent in the chain."""
|
| 12 |
+
return new_value
|
| 13 |
+
|
| 14 |
class AgentState(TypedDict):
|
| 15 |
"""
|
| 16 |
State definition for the pharmaceutical data management agents.
|
|
|
|
| 34 |
# Status remains a single-value key
|
| 35 |
status: Literal["planning", "executing", "complete", "error", "pending_approval"]
|
| 36 |
|
| 37 |
+
# Use Annotated with last_value_reducer for current_agent to handle concurrent updates
|
| 38 |
+
current_agent: Annotated[str, last_value_reducer]
|