kyegomez / swarms

The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework Join our Community: https://discord.com/servers/agora-999382051935506503
https://docs.swarms.world
GNU Affero General Public License v3.0
1.81k stars 248 forks source link

Enhance Agent Logging: Comprehensive Step, Tool, and Memory Tracking in JSON format #615

Closed sambhavnoobcoder closed 3 weeks ago

sambhavnoobcoder commented 4 weeks ago

Problem

The current Agent class lacks detailed logging of each step, tool usage, and memory consumption. This makes it difficult for users to debug and analyze the agent's behavior, especially when dealing with complex tasks.

Solution

We've implemented comprehensive logging for the Agent class, capturing detailed information about each step, tool usage, and memory consumption. The logging system now supports both string and JSON output formats, allowing users to choose the most suitable format for their needs.

Key changes include:

  1. Enhanced step logging in the log_step_metadata method
  2. Detailed tool usage tracking
  3. Memory usage monitoring for both short-term and long-term memory
  4. Option to switch between string and JSON output formats
  5. Updated documentation to reflect new logging capabilities
  6. New unit tests and integration tests to ensure logging functionality

Impact

These changes significantly improve the transparency and debuggability of the Agent class. Users can now:

Final Results

With these changes, users can now:

  1. Get detailed logs of each step in the agent's process
  2. Track tool usage and performance
  3. Monitor memory consumption
  4. Choose between string and JSON output formats
  5. Easily debug and analyze agent behavior

The enhanced logging system provides valuable insights into the agent's decision-making process, making it easier for developers to optimize and troubleshoot their AI applications.

Videos And Screenshots

You can find the video of the code explaination , walkthrough , demos , unittests etc here : https://drive.google.com/file/d/1IsL288KWy5IyZ6bKJiEKpWyDAbNomFvH/view?usp=sharing

A small glimpse of all testcases successfully passing including the integration test is as follows :

Screenshot 2024-10-28 at 12 00 51 AM

The first 5 here are indications of successful unittests and the 6th is the successful integration test .

Additional Notes


📚 Documentation preview 📚: https://swarms--615.org.readthedocs.build/en/615/