-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleaned up task execution to now have separate paths for async and sync execution. Updating all kickoff functions to return CrewOutput. WIP. Waiting for Joao feedback on async task execution with task_output * Consistently storing async and sync output for context * outline tests I need to create going forward * Major rehaul of TaskOutput and CrewOutput. Updated all tests to work with new change. Need to add in a few final tricky async tests and add a few more to verify output types on TaskOutput and CrewOutput. * Encountering issues with callback. Need to test on main. WIP * working on tests. WIP * WIP. Figuring out disconnect issue. * Cleaned up logs now that I've isolated the issue to the LLM * more wip. * WIP. It looks like usage metrics has always been broken for async * Update parent crew who is managing for_each loop * Merge in main to bugfix/kickoff-for-each-usage-metrics * Clean up code for review * Add new tests * Final cleanup. Ready for review. * Moving copy functionality from Agent to BaseAgent * Fix renaming issue * Fix linting errors * use BaseAgent instead of Agent where applicable * Fixing missing function. Working on tests. * WIP. Needing team to review change * Fixing issues brought about by merge * WIP: need to fix json encoder * WIP need to fix encoder * WIP * WIP: replay working with async. need to add tests * Implement major fixes from yesterdays group conversation. Now working on tests. * The majority of tasks are working now. Need to fix converter class * Fix final failing test * Fix linting and type-checker issues * Add more tests to fully test CrewOutput and TaskOutput changes * Add in validation for async cannot depend on other async tasks. * WIP: working replay feat fixing inputs, need tests * WIP: core logic of seq and heir for executing tasks added into one * Update validators and tests * better logic for seq and hier * replay working for both seq and hier just need tests * fixed context * added cli command + code cleanup TODO: need better refactoring * refactoring for cleaner code * added better tests * removed todo comments and fixed some tests * fix logging now all tests should pass * cleaner code * ensure replay is delcared when replaying specific tasks * ensure hierarchical works * better typing for stored_outputs and separated task_output_handler * added better tests * added replay feature to crew docs * easier cli command name * fixing changes * using sqllite instead of .json file for logging previous task_outputs * tools fix * added to docs and fixed tests * fixed .db * fixed docs and removed unneeded comments * separating ltm and replay db * fixed printing colors * added how to doc --------- Co-authored-by: Brandon Hancock <brandon@brandonhancock.io>
- Loading branch information
1 parent
7696b45
commit 67b04b3
Showing
25 changed files
with
6,380 additions
and
197 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ test.py | |
rc-tests/* | ||
*.pkl | ||
temp/* | ||
.vscode/* | ||
.vscode/* | ||
crew_tasks_output.json |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
title: Replay Tasks from Latest Crew Kickoff | ||
description: Replay tasks from the latest crew.kickoff(...) | ||
--- | ||
|
||
## Introduction | ||
CrewAI provides the ability to replay from a task specified from the latest crew kickoff. This feature is particularly useful when you've finished a kickoff and may want to retry certain tasks or don't need to refetch data over and your agents already have the context saved from the kickoff execution so you just need to replay the tasks you want to. | ||
|
||
## Note: | ||
You must run `crew.kickoff()` before you can replay a task. Currently, only the latest kickoff is supported, so if you use `kickoff_for_each`, it will only allow you to replay from the most recent crew run. | ||
|
||
Here's an example of how to replay from a task: | ||
|
||
### Replaying from specific task Using the CLI | ||
To use the replay feature, follow these steps: | ||
|
||
1. Open your terminal or command prompt. | ||
2. Navigate to the directory where your CrewAI project is located. | ||
3. Run the following command: | ||
|
||
To view latest kickoff task_ids use: | ||
```shell | ||
crewai log-tasks-outputs | ||
``` | ||
|
||
Once you have your task_id to replay from use: | ||
```shell | ||
crewai replay -t <task_id> | ||
``` | ||
|
||
|
||
### Replaying from a task Programmatically | ||
To replay from a task programmatically, use the following steps: | ||
|
||
1. Specify the task_id and input parameters for the replay process. | ||
2. Execute the replay command within a try-except block to handle potential errors. | ||
|
||
```python | ||
def replay_from_task(): | ||
""" | ||
Replay the crew execution from a specific task. | ||
""" | ||
task_id = '<task_id>' | ||
inputs = {"topic": "CrewAI Training"} # this is optional, you can pass in the inputs you want to replay otherwise uses the previous kickoffs inputs | ||
try: | ||
YourCrewName_Crew().crew().replay_from_task(task_id=task_id, inputs=inputs) | ||
|
||
except Exception as e: | ||
raise Exception(f"An error occurred while replaying the crew: {e}") |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import subprocess | ||
import click | ||
|
||
|
||
def replay_task_command(task_id: str) -> None: | ||
""" | ||
Replay the crew execution from a specific task. | ||
Args: | ||
task_id (str): The ID of the task to replay from. | ||
""" | ||
command = ["poetry", "run", "replay", task_id] | ||
|
||
try: | ||
result = subprocess.run(command, capture_output=False, text=True, check=True) | ||
if result.stderr: | ||
click.echo(result.stderr, err=True) | ||
|
||
except subprocess.CalledProcessError as e: | ||
click.echo(f"An error occurred while replaying the task: {e}", err=True) | ||
click.echo(e.output, err=True) | ||
|
||
except Exception as e: | ||
click.echo(f"An unexpected error occurred: {e}", err=True) |
This file contains 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
This file contains 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
Oops, something went wrong.