Skip to content

Commit b9071a9

Browse files
fix: restore orchestration when agent is served
A change introduced in 91c1394 to improve how the current dialog is passed to the orchestrator caused orchestration to stop working when the agent is served directly. In this scenario, current_dialog is always None because there is no peer agent to generate a dialog. Update __call__ to automatically build current_dialog from the agent's memory when it is None.
1 parent d61ddb9 commit b9071a9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/sdialog/agents.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,21 @@ def __call__(self,
313313
utterance = self._preprocessing_fn(utterance) if self._preprocessing_fn else utterance
314314
self.memory.append(HumanMessage(content=utterance))
315315

316+
# Create a temporary Dialog from memory if current_dialog is not provided
317+
# This allows orchestrators to work even when the agent is not served
318+
if current_dialog is None and len(self.memory) > 1:
319+
turns = []
320+
for msg in self.memory:
321+
if isinstance(msg, HumanMessage):
322+
speaker = "User"
323+
elif isinstance(msg, AIMessage):
324+
speaker = self.get_name()
325+
else:
326+
continue
327+
turns.append(Turn(speaker=speaker, text=msg.content))
328+
329+
current_dialog = Dialog(turns=turns)
330+
316331
if return_events:
317332
events = []
318333
if self._orchestrators:

0 commit comments

Comments
 (0)