feat: Implement UserFeedback tool with corresponding test (Closes #532)
### Description
This pull request introduces a new `UserFeedbackTool` that allows an agent to pause its execution and proactively ask the human user for input or guidance. This provides a more dynamic and interactive way to run agents, bridging the gap between fully autonomous operation and step-by-step approval. A user can now steer the agent if it gets stuck or needs clarification on a complex task.
### Related Issues
#532
### Solution and Design
The solution involves creating a new, self-contained tool within the existing framework:
- A new class `UserFeedbackTool` is created in `superagi/tools/user_feedback_tool.py`.
- The tool's `_execute` method utilizes Python's built-in `input()` function to display a prompt in the console and wait for the user to respond.
- The text entered by the user is captured and returned as the tool's output, which can then be used by the agent in its next step.
- The tool is registered in `superagi/tools/__init__.py` to make it available for selection by the agent.
### Test Plan
A unit test has been added to ensure the tool's functionality is working as expected and does not break in the future.
- A new test file was created: `tests/tools/test_user_feedback_tool.py`.
- The test uses `unittest.mock.patch` to simulate a user typing into the console. This allows the test to run automatically without requiring real-time human interaction.
- It asserts that the tool's output string correctly contains the simulated user input.
### Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Docs update
### Checklist
- [x] My pull request is atomic and focuses on a single change.
- [x] I have read the contributing guide and my code conforms to the guidelines.
- [x] I have documented my changes clearly and comprehensively.
- [x] I have added the required tests.
合并状态:未合并 0 条评论