Aggregate-Intellect/sherpa

[FEATURE] Flow Policy and Memory Management

Closed this issue · 1 comments

Description

Flow
To better control the flow of execution. We should create a flow policy that allows users to define the execution flow.

The flow contains three kinds of nodes:

  • Action node that performs an action
  • Decision node that makes a decision and chooses the desired next action based on the decision
  • Agent action node that calls another agent to complete some task, this is treated as a special kind of Action node
---
title: Flow Policy
---
classDiagram
    class FlowPolicy {
        name: str

    }

    class FlowNode {
        <<abstract>>
        name
    }

    class ActionNode {
    }

    class Edge{
    
    }

    class DecisionNode {
        condition
    }

    class Action {

    }

    class AgentAction{
        agent: Agent
    }
    
    class Start {

    }

    class Stop {

    }

    FlowNode <|-- DecisionNode
    FlowNode <|-- ActionNode
    FlowNode <|-- Start
    FlowNode <|-- Stop
    Action <|-- AgentAction

    FlowPolicy "1" -- "*" FlowNode
    FlowPolicy "1" -- "*" Edge
    FlowPolicy "1" -- "1" Start
    ActionNode "*" -- "1" Action

    Edge "outgoingEdge *" --  "1 source" FlowNode
    Edge "incomingEdge *" -- "1 target" FlowNode
Loading

Each action can optionally depend on the output from previous actions, by default, it is the most immediate one or no dependency at all.

Memory management
The following information needs to be stored when the flow is executed, the storage is a key-value map but can also be queried with other methods (e.g. semantic search):

  1. Current execution path (sequence of nodes)
  2. Output of each node (Stored in a datastore)
  3. Optionally, the above two things can be persisted
    image

Closed as this is replaced by #406