Skip to content

Commit

Permalink
Remove BaseRuntime.delete()
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLuo committed Jan 13, 2025
1 parent ddee4b7 commit 8fae04d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
7 changes: 1 addition & 6 deletions coagent/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .discovery import Discovery
from .exceptions import BaseError
from .messages import StopIteration, Error
from .factory import Factory, DeleteAgent
from .factory import Factory
from .types import (
AgentSpec,
Channel,
Expand Down Expand Up @@ -69,11 +69,6 @@ async def deregister(self, *names: str) -> None:
def channel(self) -> Channel:
return self._channel

async def delete(self, addr: Address) -> None:
factory_addr = Address(name=addr.name)
msg = DeleteAgent(session_id=addr.id).encode()
await self._channel.publish(factory_addr, msg, probe=False)


class BaseChannel(Channel):
async def publish_multi(
Expand Down
12 changes: 4 additions & 8 deletions coagent/cos/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
)
from coagent.core.messages import Cancel
from coagent.core.exceptions import BaseError
from coagent.core.factory import DeleteAgent
from coagent.core.types import Runtime
from coagent.core.util import clear_queue

Expand Down Expand Up @@ -122,23 +121,20 @@ async def event_stream() -> AsyncIterator[str]:
# Disconnected from the client.

# Delete the corresponding agent.
factory_addr = Address(name=addr.name)
delete_msg = DeleteAgent(session_id=addr.id).encode()
await self._runtime.channel.publish(
factory_addr, delete_msg, probe=False
)
await agent.delete()

raise

return EventSourceResponse(event_stream())

async def publish(self, request: Request):
data: dict = await request.json()
addr = Address.decode(data["addr"])
msg = RawMessage.decode(data["msg"])

try:
msg = RawMessage.decode(data["msg"])
await self._update_message_header_extensions(msg, request)

addr = Address.decode(data["addr"])
resp: RawMessage | None = await self._runtime.channel.publish(
addr=addr,
msg=msg,
Expand Down

0 comments on commit 8fae04d

Please sign in to comment.