-
-
Notifications
You must be signed in to change notification settings - Fork 717
[IMPR/FEAT-AGENT][Added Cursor-like ReAct framework(Reason+Act+Observe] to agents once max_loops is set to "auto" #1182
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
Open
IlumCI
wants to merge
7
commits into
kyegomez:master
Choose a base branch
from
IlumCI:cursor-agent
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added REACT workflow tools for automated task management, including functions for action execution, subtask completion, and objective completion. Updated the REACT workflow execution method to integrate these tools and handle responses accordingly.
| f"Error in REACT workflow loop {loop_count}: {e}" | ||
| ) | ||
| attempt += 1 | ||
| if attempt >= self.retry_attempts: |
Check failure
Code scanning / Pyre
Unsupported operand Error
Unsupported operand [58]: >= is not supported for operand types int and Optional[int].
| logger.error(f"Error in REACT workflow: {error}") | ||
| # Restore original tools and context_length on error | ||
| if hasattr(self, "tools_list_dictionary"): | ||
| self.tools_list_dictionary = original_tools |
Check failure
Code scanning / Pyre
Uninitialized local Error
Uninitialized local [61]: Local variable original_tools is undefined, or not always defined.
| if hasattr(self, "tools_list_dictionary"): | ||
| self.tools_list_dictionary = original_tools | ||
| if hasattr(self, "context_length"): | ||
| self.context_length = original_context_length |
Check failure
Code scanning / Pyre
Uninitialized local Error
Uninitialized local [61]: Local variable original_context_length is undefined, or not always defined.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR implements a REACT (Reason, Act, Observe) workflow for the Agent class when max_loops is set to "auto". This brings structured reasoning and action capabilities similar to how modern AI coding assistants like Cursor handle complex, multi-step tasks.
Issue: #1178
The REACT workflow enables agents to:
Key Changes:
How REACT Works:
REACT (Reason, Act, Observe) is a reasoning framework that combines:
This creates a feedback loop where the agent can iteratively refine its approach based on the results of previous actions.
How Cursor Uses REACT:
Cursor uses a REACT-like workflow to handle complex coding tasks:
This allows Cursor to handle multi-file edits, complex refactorings, and multi-step debugging tasks systematically.
How Swarms Now Uses REACT:
When max_loops="auto" is set, Swarms agents now follow this workflow:
graph TD A[User Task] --> B{max_loops = 'auto'?} B -->|Yes| C[REACT Workflow] B -->|No| Z[Standard Loop] C --> D[Create Plan] D --> E[Generate Step-by-Step Plan] E --> F[Store Plan in Memory] F --> G[REACT Loop Start] G --> H[Think: Analyze Current Subtask] H --> I[Act: Use action tool] I --> J[Observe: Review Results] J --> K{Subtask Complete?} K -->|Yes| L[Call subtask_complete tool] K -->|No| H L --> M{All Subtasks Done?} M -->|No| G M -->|Yes| N[Call objective_complete tool] N --> O[Return Full History] O --> P[End] style C fill:#e1f5ff style D fill:#fff4e1 style G fill:#e8f5e9 style N fill:#f3e5f5Plan Creation Phase:
Execution Phase:
Completion Phase:
Key Features:
Technical Implementation:
Code Examples:
Dependencies:
Tag maintainer:
@kyegomez
Twitter handle:
https://x.com/IlumTheProtogen
Testing:
Backward Compatibility:
📚 Documentation preview 📚: https://swarms--1182.org.readthedocs.build/en/1182/