AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

feat(agent): Update component ordering

Open kcze opened this issue 9 months ago • 4 comments

User description

Background

Refactor https://github.com/Significant-Gravitas/AutoGPT/pull/7106 is causing many problems with circular imports. Static run_after inside component classes needlessely couples components to each other and hides ordering from the developer. And it's only useful for internal components as the exact type needs to be known.

Changes 🏗️

Removed usage of static run_after field and introduced run_after method that allows defining ordering at the agent level (local & clear). This also allows user to order specific components (without defining order for all components).

  • Introduced run_after method in ComponentAgent
  • Updated relevant code and docs
  • Added code comments

PR Quality Scorecard ✨

  • [x] Have you used the PR description template?   +2 pts
  • [x] Is your pull request atomic, focusing on a single change?   +5 pts
  • [ ] Have you linked the GitHub issue(s) that this PR addresses?   +5 pts
  • [ ] Have you documented your changes clearly and comprehensively?   +5 pts
  • [x] Have you changed or added a feature?   -4 pts
    • [x] Have you added/updated corresponding documentation?   +4 pts
    • [ ] Have you added/updated corresponding integration tests?   +5 pts
  • [ ] Have you changed the behavior of AutoGPT?   -5 pts
    • [ ] Have you also run agbenchmark to verify that these changes do not regress performance?   +10 pts

PR Type

Enhancement, Documentation


Description

  • Introduced a dynamic run_after method to replace static ordering in components, enhancing flexibility and clarity in component execution order.
  • Updated agent initialization in agent.py to use the new dynamic run_after method for WatchdogComponent and ContextComponent.
  • Removed outdated static run_after lists from WatchdogComponent and EventHistoryComponent.
  • Documentation in README.md updated to guide on using the new dynamic ordering method and to warn about potential circular dependencies.

Changes walkthrough 📝

Relevant files
Enhancement
agent.py
Implement dynamic component ordering in Agent initialization

autogpts/autogpt/autogpt/agents/agent.py

  • Replaced static run_after with dynamic run_after method calls for
    WatchdogComponent and ContextComponent.
  • +4/-2     
    base.py
    Refine component collection and fix comment typo                 

    autogpts/autogpt/autogpt/agents/base.py

  • Fixed typo in a comment.
  • Updated component collection logic to prevent revisiting components.
  • +3/-4     
    components.py
    Add dynamic ordering method to AgentComponent                       

    autogpts/autogpt/autogpt/agents/components.py

  • Added run_after method to dynamically set component execution order.
  • Removed static run_after list.
  • +17/-2   
    watchdog.py
    Remove static ordering from WatchdogComponent                       

    autogpts/autogpt/autogpt/agents/features/watchdog.py

    • Removed static run_after list from WatchdogComponent.
    +0/-3     
    event_history.py
    Remove static ordering from EventHistoryComponent               

    autogpts/autogpt/autogpt/components/event_history.py

    • Removed static run_after list from EventHistoryComponent.
    +0/-3     
    Documentation
    README.md
    Update README to document dynamic component ordering         

    autogpts/autogpt/autogpt/commands/README.md

  • Updated documentation to reflect dynamic component ordering.
  • Added warnings about circular dependencies.
  • +18/-9   

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    kcze avatar May 11 '24 20:05 kcze

    Deploy Preview for auto-gpt-docs canceled.

    Name Link
    Latest commit ffd63775ae3eb46505ea025f70ae567aeec4c9cc
    Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/663fd99edaac5800083eb939

    netlify[bot] avatar May 11 '24 20:05 netlify[bot]

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Description updated to latest commit (https://github.com/Significant-Gravitas/AutoGPT/commit/ffd63775ae3eb46505ea025f70ae567aeec4c9cc)

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves changes across multiple files with modifications to the core functionality of component ordering. Understanding the impact of these changes on the system's behavior and ensuring no side effects or circular dependencies require careful review.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: The new run_after method implementation allows setting up dependencies, but there's no check for circular dependencies which could lead to infinite loops or stack overflow errors during component initialization.

    Compatibility Issue: The removal of the static run_after list and introduction of the instance method might break existing code if external scripts or modules depend on the old static list.

    🔒 Security concerns

    No

    Codecov Report

    All modified and coverable lines are covered by tests :white_check_mark:

    Project coverage is 44.07%. Comparing base (b0cbf71) to head (ffd6377). Report is 7 commits behind head on master.

    Additional details and impacted files
    @@            Coverage Diff             @@
    ##           master    #7148      +/-   ##
    ==========================================
    - Coverage   44.68%   44.07%   -0.62%     
    ==========================================
      Files         133      133              
      Lines        6315     6319       +4     
      Branches      823      825       +2     
    ==========================================
    - Hits         2822     2785      -37     
    - Misses       3382     3424      +42     
    + Partials      111      110       -1     
    
    Flag Coverage Δ
    Linux ?
    Windows 42.82% <100.00%> (+0.05%) :arrow_up:
    autogpt-agent 44.07% <100.00%> (-0.59%) :arrow_down:
    macOS 44.04% <100.00%> (+0.05%) :arrow_up:

    Flags with carried forward coverage won't be shown. Click here to find out more.

    :umbrella: View full report in Codecov by Sentry.
    :loudspeaker: Have feedback on the report? Share it here.

    codecov[bot] avatar May 11 '24 20:05 codecov[bot]

    This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

    github-actions[bot] avatar May 15 '24 22:05 github-actions[bot]