camel icon indicating copy to clipboard operation
camel copied to clipboard

feat(agents): Implement conditional message recording in chat agent

Open coolbeevip opened this issue 9 months ago • 0 comments

Description

Enhance the flexibility of the ChatAgent memory by introducing a record_message_condition parameter. This allows for more granular control over the storage of messages in business logic.

  1. Added a record_message_condition parameter to the step method.
  2. Moved the record_input_message method to execute after the model's result, allowing the record_message_condition return value to decide if messages should be saved.
  3. Controlled the storage of tool records through record_message_condition.
  4. Added some test case

Fixes #1889

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • [x] I have read the CONTRIBUTION guide (required)
  • [x] I have linked this PR to an issue using the Development section on the right sidebar or by adding Fixes #issue-number in the PR description (required)
  • [ ] I have checked if any dependencies need to be added or updated in pyproject.toml and uv lock
  • [ ] I have updated the tests accordingly (required for a bug fix or a new feature)
  • [ ] I have updated the documentation if needed:
  • [ ] I have added examples if this is a new feature

If you are unsure about any of these, don't hesitate to ask. We are here to help!

coolbeevip avatar Mar 19 '25 16:03 coolbeevip