Skip to content

Commit 9925bf8

Browse files
Revert "make memory serialization great again (#18621)"
This reverts commit 98aca7e.
1 parent 89c190b commit 9925bf8

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
AgentSetup,
1616
AgentOutput,
1717
)
18-
from llama_index.core.bridge.pydantic import model_serializer
1918
from llama_index.core.llms import ChatMessage, TextBlock
2019
from llama_index.core.llms.llm import LLM
2120
from llama_index.core.memory import BaseMemory, ChatMemoryBuffer
@@ -81,17 +80,6 @@ async def handoff(ctx: Context, to_agent: str, reason: str) -> str:
8180
return handoff_output_prompt.format(to_agent=to_agent, reason=reason)
8281

8382

84-
class AgentWorkflowStartEvent(StartEvent):
85-
86-
@model_serializer()
87-
def serialize_start_event(self) -> dict:
88-
"""Serialize the start event and exclude the memory."""
89-
return {
90-
"user_msg": self.user_msg,
91-
"chat_history": self.chat_history,
92-
}
93-
94-
9583
class AgentWorkflowMeta(WorkflowMeta, ABCMeta):
9684
"""Metaclass for AgentWorkflow that inherits from WorkflowMeta."""
9785

@@ -304,7 +292,7 @@ async def _call_tool(
304292
return tool_output
305293

306294
@step
307-
async def init_run(self, ctx: Context, ev: AgentWorkflowStartEvent) -> AgentInput:
295+
async def init_run(self, ctx: Context, ev: StartEvent) -> AgentInput:
308296
"""Sets up the workflow and validates inputs."""
309297
await self._init_context(ctx, ev)
310298

@@ -557,11 +545,9 @@ def run(
557545
**kwargs: Any,
558546
) -> WorkflowHandler:
559547
return super().run(
560-
start_event=AgentWorkflowStartEvent(
561-
user_msg=user_msg,
562-
chat_history=chat_history,
563-
memory=memory,
564-
),
548+
user_msg=user_msg,
549+
chat_history=chat_history,
550+
memory=memory,
565551
ctx=ctx,
566552
stepwise=stepwise,
567553
checkpoint_callback=checkpoint_callback,

llama-index-core/llama_index/core/workflow/context.py

-18
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
T = TypeVar("T", bound=Event)
4040
EventBuffer = Dict[str, List[Event]]
4141

42-
# Only warn once about unserializable keys
43-
class UnserializableKeyWarning(Warning):
44-
pass
45-
46-
warnings.simplefilter("once", UnserializableKeyWarning)
47-
4842

4943
class Context:
5044
"""
@@ -58,10 +52,6 @@ class Context:
5852
Both `set` and `get` operations on global data are governed by a lock, and considered coroutine-safe.
5953
"""
6054

61-
# These keys are set by pre-built workflows and
62-
# are known to be unserializable in some cases.
63-
known_unserializable_keys = ("memory", )
64-
6555
def __init__(
6656
self,
6757
workflow: "Workflow",
@@ -135,14 +125,6 @@ def _serialize_globals(self, serializer: BaseSerializer) -> Dict[str, Any]:
135125
try:
136126
serialized_globals[key] = serializer.serialize(value)
137127
except Exception as e:
138-
if key in self.known_unserializable_keys:
139-
# Skip serialization of known unserializable keys
140-
warnings.warn(
141-
f"Skipping serialization of known unserializable key: {key} -- "
142-
"This is expected but will require this item to be set manually after deserialization.",
143-
category=UnserializableKeyWarning,
144-
)
145-
continue
146128
raise ValueError(f"Failed to serialize value for key {key}: {e}")
147129
return serialized_globals
148130

0 commit comments

Comments
 (0)