Skip to content
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

feat(core): add conditional callbacks #259

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

Archento
Copy link
Member

@Archento Archento commented Mar 13, 2024

Based on feedback from the community and the opened discussion #249.

Adds conditional functionality to agents callbacks by providing the following capabilities without breaking backwards compatibility:

  • add agent interface to get/set the current agent state as str
  • add desired state as str to .on_interval() handler to only trigger that function based on the current agent state
  • add desired state as str to .on_message() handler to only react to messages based on the current agent state
  • decorators without the explicit mention of a state will act as usual

If desired we can add an example of state management

@Archento Archento added the enhancement New feature or request label Mar 13, 2024
@Archento Archento self-assigned this Mar 13, 2024
@Archento Archento changed the title feat: stateful agent feat: conditional callbacks Mar 14, 2024
await _send_error_message(
context,
sender,
ErrorMessage(error="Agent not in correct state to handle message"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we support custom error messages the developer can provide with the decorator?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently if an agent has no handler for a message, it is simply ignored, so I kind of think we should treat being in wrong state to handle a message the same as not having a handler for that message. So for consistency with the current setup, we would ignore that case. However, I can see the case for sending error messages back in both cases, because at the moment I don't think the sending agent gets any feedback when sending an invalid or incorrect message to an agent.

@Archento Archento changed the title feat: conditional callbacks feat(core): conditional callbacks Mar 20, 2024
@Archento Archento changed the title feat(core): conditional callbacks feat(core): add conditional callbacks Mar 20, 2024
Copy link
Contributor

@jrriehl jrriehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the idea and the implementation looks good and backwards compatible from the user's side. But given that this is a fundamental change to the framework, let's leave this open for a while longer for others to weigh in on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants