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

Support for LLM-Generated Subtasks #1

Open
yisrael-rosen opened this issue Dec 17, 2024 · 0 comments
Open

Support for LLM-Generated Subtasks #1

yisrael-rosen opened this issue Dec 17, 2024 · 0 comments

Comments

@yisrael-rosen
Copy link

Generated by Gemini experimental 1206 🤖

Summary

This issue proposes a new feature for the Enzu framework that would allow the LLM to dynamically create and assign subtasks to specialized agents during the execution of a synergy. This would enable more efficient task delegation, reduce context overload on the main agent, and support more complex and dynamic agent interactions.

Motivation

Currently, Enzu's task management is primarily static, with tasks defined beforehand and managed by Synergy or SynergyManager. While this approach works well for predefined workflows, it lacks the flexibility to handle situations where the specific steps required to complete a task are not known in advance or may change based on intermediate results.

Allowing the LLM to generate subtasks dynamically would provide several benefits:

  • Improved Efficiency: The LLM can delegate specific subtasks to specialized agents, leveraging their unique capabilities and reducing the workload on the main agent.
  • Reduced Context Overload: By offloading subtasks to other agents, the main agent's context can be kept focused on the overall goal, preventing information overload and improving performance.
  • Enhanced Flexibility: The system can adapt to changing requirements or unexpected situations by dynamically creating new subtasks as needed.
  • More Complex Interactions: Enables the creation of more sophisticated agent interactions, where agents can collaborate on subtasks and exchange information more effectively.

Proposed Solution

To implement this feature, we propose the following changes:

  1. Introduce a mechanism for creating new tasks during synergy execution: This could be achieved by:

    • Adding a dedicated tool that allows an agent to define a new task (description, assigned agent) and add it to the synergy.
    • Extending the Synergy struct with methods for dynamically adding new tasks and agents.
    • Enabling the SynergyManager to create new tasks based on input from agents and add them to the appropriate synergy.
  2. Enable agents to communicate with the LLM to request subtask creation: An agent, when faced with a complex task, could send a request to the LLM, providing the task description and available agents. The LLM would then analyze the task and suggest a breakdown into subtasks, each assigned to a specific agent.

  3. Implement a mechanism for returning subtask results to the requesting agent: Once a subtask is completed, the results should be returned to the agent that requested its creation. This could be achieved through a dedicated communication channel or by storing the results in a shared context accessible to all agents within the synergy.

Example Code Snippet (Illustrative)

// Add a method to Synergy for adding tasks dynamically
func (s *Synergy) AddTaskDynamically(task *Task) {
    s.tasks = append(s.tasks, task)
    // Potentially trigger an event or update to re-evaluate the task queue
}

// Example of an agent requesting subtask creation from the LLM
func (a *Agent) handleComplexTask(ctx context.Context, taskDescription string) (string, error) {
    // Prepare a request for the LLM
    request := fmt.Sprintf("I need to break down this task: '%s'. Available agents are: %v", 
                           taskDescription, a.synergy.GetAgents())

    // Send the request to the LLM and get a response
    llmResponse, err := executeWithLLM(ctx, a, request, a.logger)
    if err != nil {
        return "", err
    }

    // Parse the LLM's response to extract suggested subtasks
    subtasks, err := a.parseSubtasks(llmResponse)
    if err != nil {
        return "", err
    }

    // Create and add the subtasks to the synergy
    for _, subtask := range subtasks {
        newTask := enzu.NewTask(subtask.description, subtask.agent)
        a.synergy.AddTaskDynamically(newTask)
    }

    return "Subtasks created and added to the synergy", nil
}
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

No branches or pull requests

1 participant