Skip to content
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

Deterministic task chaining - @anthonydevs17: Pause/Resume/Stop features #207

Open
wants to merge 40 commits into
base: workflows-v2
Choose a base branch
from

Conversation

ernestocarrasco
Copy link

  • Add DeterministicExecutionStrategy to handle sequential, task dependencies and parallel workflow processing.
  • Include Pause/Resume and Stop functionalities

anthonydevs17 and others added 30 commits January 3, 2025 22:51
- Added a 'Stop Workflow' button in AgentsBoardDebugger component.
- Introduced a stop method in the Team class to halt the workflow and update the state.
- Updated ReactChampionAgent to handle the STOPPED status during workflow execution.
- Enhanced workflowController to clear the task queue when the workflow is stopped.
… functionalities

- Added handlePauseResume and handleStop methods in AgentWithToolPreviewer for managing team workflow states.
- Introduced new buttons for pause/resume and stop actions in the UI, with appropriate disabling logic based on workflow status.
- Updated Team class to handle stopping workflows more robustly, including abort handling in ReactChampionAgent.
- Enhanced error handling for task abortion and logging for better debugging and user feedback.
- Introduced AbortError class to manage operation interruptions effectively.
- Adjusted the table formatting in README.md for the tools package to enhance clarity and consistency.
- Ensured proper alignment of tool descriptions and documentation links for improved user experience.
…esume, and stop methods

- Refactored Team class methods (pause, resume, stop) to utilize new workflow management functions directly from the store, improving code clarity and reducing redundancy.
- Updated ReactChampionAgent to track the last feedback message and handle task execution more effectively, including abort handling.
- Introduced new error classes (StopAbortError, PauseAbortError) for better error management during workflow interruptions.
- Enhanced task logging for aborted tasks, capturing relevant statistics and error details for improved debugging.
- Integrated workflow action enums to standardize workflow control actions across the application.
…edbackMessage fields

- Added `currentIterations` and `lastFeedbackMessage` fields to various agent instances across multiple test snapshots, enhancing the state tracking of agents during workflows.
- Ensured consistency in the agent configurations for improved testing accuracy and reliability.
- Updated snapshots for `customLLMs`, `llmProxy`, `outputSchemaTeam`, `productSpecTeam`, `resumeCreationTeam`, `sportNewsTeam`, and `tripPlanningTeam` to reflect these changes.
- Cleaned up the README.md by removing an unnecessary newline before the Compatibility section, improving the overall formatting and readability of the document.
…d refactor task management

- Added new ESLint rules to disable focused and disabled tests in Jest.
- Updated Jest configuration to specify a test match pattern.
- Introduced a new dependency, `dependency-graph`, in package.json and package-lock.json.
- Refactored task management in the application by adding a TaskManager for better task lifecycle handling.
- Enhanced task and team store functionalities to support new task status updates and flow types.
- Removed the workflow controller as part of the task management refactor.

Related GH Issue: kaiban-ai#153
…LMEnd method

- Eliminated the unnecessary check for PAUSED workflow status in the handleLLMEnd method of ReactChampionAgent, streamlining the task handling process.
- This change enhances the agent's responsiveness during task execution by allowing it to proceed without being blocked by the workflow status.
…status management

- Introduced a new `handleAgentTaskPaused` method to manage agent status when tasks are paused, improving workflow control during interruptions.
- Updated `handleTaskAborted` and `handleTaskPaused` methods to log task status changes and relevant error details, enhancing debugging capabilities.
- Refactored task status management to include a new PAUSED state for both agents and tasks, allowing for better tracking of workflow interruptions.
- Enhanced error handling in the workflow loop to ensure proper task management during pauses, improving overall system reliability.
- Updated taskSubscriber.js to include the PAUSED state in the subscribeTaskStatusUpdates function, enhancing task status management.
- This change aligns with recent enhancements to workflow control, allowing for better tracking of tasks during interruptions.
…orkflow' into 153-tasks-chaining-sequential-hierarchy
- Integrated ChatMessageHistory into agent instances for improved interaction tracking.
- Updated agent status management to reset interactions history and feedback upon workflow reset.
- Added functionality to start the task queue if paused, ensuring smoother workflow execution.
- Removed redundant clearAgentLoopState method from workflow loop store, streamlining state management.
- Improved overall task handling and agent responsiveness during workflow interruptions.
…arious workflows

- Enhanced snapshot files for `llmProxy`, `outputSchemaTeam`, `productSpecTeam`, `resumeCreationTeam`, `sportNewsTeam`, and `tripPlanningTeam` to include comprehensive `lastFeedbackMessage` fields.
- Updated messages to reflect specific tasks and expected outputs, improving clarity and context for each workflow scenario.
- Ensured consistency in agent configurations across multiple test snapshots, enhancing the accuracy of state tracking during workflows.
…management

- Introduced workOnTaskResume method in Agent and BaseAgent classes to handle task resumption.
- Implemented workOnTaskResume in ReactChampionAgent to manage task execution with last feedback context.
- Updated teamStore to support task resumption in the workflow controller, enhancing task handling during workflow interruptions.
- Improved overall agent state management and task queue handling for better responsiveness and control.
- Introduce new execution strategies: DeterministicExecutionStrategy and ManagerLLMStrategy
- Add support for parallel task execution with new task management methods
- Update Team and Task constructors to support new workflow configuration options
- Enhance task status tracking with dedicated executing and pending task sets
- Simplify workflow execution strategy selection logic
- Update DeterministicExecutionStrategy to improve task scheduling and parallel execution
- Modify teamStore to simplify task status management and remove redundant state updates
- Add comprehensive test cases for task execution order, parallel processing, and state transitions
- Update jest configuration to focus on specific test files
- Improve logging and debugging for workflow execution
- Modify jest configuration to skip certain test cases
- Update event planning team test snapshots with new AI-generated content
- Adjust logging and debugging settings in test utilities
- Remove commented debug logging in moscaFetch utility
- Simplify test configurations for trip planning and output schema teams
- Add detailed test cases for pause and resume workflow in event planning and trip planning teams
- Update workflow loop store to handle pause, resume, and stop operations more robustly
- Modify task store to support pausing and resuming tasks with correct status transitions
- Enhance execution strategy to respect workflow status during task scheduling
- Remove task queue-related checks and simplify workflow state management
@ernestocarrasco ernestocarrasco changed the title Deterministic task chaining - Pause/Resume - Stop Deterministic task chaining - @anthonydevs17: Pause/Resume/Stop features Feb 11, 2025
…tion

- Introduce optional referenceId parameter in Task constructor
- Modify execution strategies to use referenceId for task dependency resolution
- Update test files and snapshots to use referenceId instead of id for task references
- Refactor dependency tracking in DeterministicExecutionStrategy to use referenceId
- Remove deprecated HierarchyExecutionStrategy and SequentialExecutionStrategy files

Related GH Issue: kaiban-ai#153
src/index.js Outdated
logLevel,
inputs = {},
env = null,
managerWithLLM = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using this?

get().updateTaskStatus(tasks[0].id, TASK_STATUS_enum.DOING);
// init task queue
get().taskQueue = new PQueue({
concurrency: strategy.getConcurrencyForTaskQueue(get()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just having the raw number here? 1. It is hardcoded anyway inside the getConcurrencyForTaskQueue function


if (strategy) {
strategy
.executeFromChangedTasks(
Copy link
Contributor

@darielnoel darielnoel Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ummm... This looks a bit complicated to understand.

changedTaskIdsWithPreviousStatus

Is not the name perse, but this way of passing the ids of changed tasks....

const firstTask = tasks[0];

// Update task status and execute it
teamStoreState.updateStatusOfMultipleTasks(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems generic updateStatusOfMultipleTasks.... stores should have specific methods.

import WorkflowExecutionStrategy from './workflowExecutionStrategy';

class ManagerLLMStrategy extends WorkflowExecutionStrategy {
executeFromChangedTasks(_teamStore, _changedTaskIds) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems a bit complex.... Why not being more direct...

Like this managers just subscribing to the tasks states, and them doing the calculations to work on specific tasks etc?

return acc;
}, []);

if (changedTaskIdsWithPreviousStatus.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I will do is habing this subscriptions at the execution manager level... and let each execution to do their thing.

workflowStatus === WORKFLOW_STATUS_enum.STOPPING
) {
return {
result: parsedResultWithFinalAnswer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we passing the parsedResultWithFinalAnswerHere if it is false from the while condition?

description,
expectedOutput,
agent,
dependencies = [],
Copy link
Contributor

@darielnoel darielnoel Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add all this new definitions to the TS types definitions

@@ -78,4 +78,36 @@ const getParsedJSON = (str) => {
}
};

export { getApiKey, replaceAgentAttributes, getParsedJSON };
/**
Copy link
Contributor

@darielnoel darielnoel Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird... proxy-based clone of a BaseAgent Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants