-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Agents to send messages to themselves. #1215
Conversation
5ecb943
to
5e7862f
Compare
@totorigolo did you randomly think to do this? Haha, @mkawalec just opened a PR to do the same #1214 🤣 Can you two sort out which API is preferred? |
:D I personally prefer |
@totorigolo I like that this unifies the API between agents and components. My vote is on this implementation over my PR :) |
@jstarry I had a tab opened in my browser since like two days, in order to test that it works as expected. But yes, this just came as a need while using agents 🙂 And I just discovered about this issue hunt thingy. @mkawalec add/improve an example in a PR and it's yours 😉 About the naming, since there are two message types that you could send to agents ( Talking about the consistency, what about making it a trait, implemented for |
Haha impeccable timing ;) If the trait is just for enforcing consistency, I don't think it's necessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop the batch method unless you can share a good usecase for it!
yew/src/agent/link.rs
Outdated
@@ -160,6 +176,15 @@ where | |||
.expect("agent was not created to process messages") | |||
.update(msg); | |||
} | |||
AgentLifecycleEvent::MessageBatch(batch) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesnt look like this adds much value. It's nice to have message batching for components to reduce renders, but not needed for agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it for consistency, never used it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, AgentScope
's send
function does some work for each message: cloning, boxing, pushing in a vec so potentially allocating, locking using Rc<RefCell<()>>
. If sending a batch is really needed, this should offer a nice boost. But on the other hand, it's easy to implement if needed, knowing that it's already possible to alternatively send a Msg::Batch(vec![...])
.
@totorigolo I'll add the example I had in the other PR in a separate PR once this is merged. |
Add methods on
AgentLink
to allow sending messages to itself, as ComponentLink can do. What do you think? 🙂Related to: #1209