Skip to content

Commit

Permalink
Update logged events, add message id to send message (#4868)
Browse files Browse the repository at this point in the history
* Update logged events

* add message_id

* serialize payload for log

* fix pytest warning

* serialization

* fix test

* lock

* fix warning and test
  • Loading branch information
jackgerrits authored Dec 31, 2024
1 parent d2a74de commit e6ac2f3
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 138 deletions.
2 changes: 2 additions & 0 deletions python/packages/autogen-core/src/autogen_core/_agent_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ async def send_message(
*,
sender: AgentId,
cancellation_token: CancellationToken | None = None,
message_id: str | None = None,
) -> Any:
return await self._runtime.send_message(
message,
recipient=self._agent,
sender=sender,
cancellation_token=cancellation_token,
message_id=message_id,
)

async def save_state(self) -> Mapping[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async def send_message(
*,
sender: AgentId | None = None,
cancellation_token: CancellationToken | None = None,
message_id: str | None = None,
) -> Any:
"""Send a message to an agent and get a response.
Expand Down
2 changes: 2 additions & 0 deletions python/packages/autogen-core/src/autogen_core/_base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ async def send_message(
recipient: AgentId,
*,
cancellation_token: CancellationToken | None = None,
message_id: str | None = None,
) -> Any:
"""See :py:meth:`autogen_core.AgentRuntime.send_message` for more information."""
if cancellation_token is None:
Expand All @@ -131,6 +132,7 @@ async def send_message(
sender=self.id,
recipient=recipient,
cancellation_token=cancellation_token,
message_id=message_id,
)

async def publish_message(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async def send_message(
recipient: AgentId,
*,
cancellation_token: CancellationToken | None = None,
message_id: str | None = None,
) -> Any: ...

async def publish_message(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class MessageHandlerContext:
def __init__(self) -> None:
raise RuntimeError(
"MessageHandlerContext cannot be instantiated. It is a static class that provides context management for agent instantiation."
"MessageHandlerContext cannot be instantiated. It is a static class that provides context management for message handling."
)

_MESSAGE_HANDLER_CONTEXT: ClassVar[ContextVar[AgentId]] = ContextVar("_MESSAGE_HANDLER_CONTEXT")
Expand Down
Loading

0 comments on commit e6ac2f3

Please sign in to comment.