Versions in this module Expand all Collapse all v0 v0.3.1 Aug 27, 2026 v0.3.0 Aug 27, 2026 Changes in this version + const END + const START + var ErrGraphClosed = errors.New("graph is closed") + var ErrGraphInvalid = errors.New("graph validation failed") + var ErrInterrupted = errors.New("execution interrupted") + var ErrNoRoute = errors.New("no valid next node") + var ErrNodePanic = errors.New("node panicked") + var ErrRecursionLimit = errors.New("recursion limit exceeded") + var ErrSubgraphInterrupted = errors.New("subgraph interrupted") + func RouteByMessageType(ctx context.Context, state *BaseState) (string, error) + func RouteByToolCalls(ctx context.Context, state *BaseState) (string, error) + type BaseState struct + func NewBaseState() *BaseState + func (bs *BaseState) Clone() *BaseState + func (bs *BaseState) CreateSnapshot() StateSnapshot + func (bs *BaseState) Delete(key string) + func (bs *BaseState) FromJSON(data []byte) error + func (bs *BaseState) Get(key string) (StateValue, bool) + func (bs *BaseState) GetAll() map[string]StateValue + func (bs *BaseState) GetHistory() *StateHistory + func (bs *BaseState) GetMetadata(key string) (interface{}, bool) + func (bs *BaseState) Keys() []string + func (bs *BaseState) MarshalJSON() ([]byte, error) + func (bs *BaseState) Merge(other *BaseState) + func (bs *BaseState) MergeWithSchema(other *BaseState, schema *StateSchema) + func (bs *BaseState) RestoreFromSnapshot(snapshot StateSnapshot) + func (bs *BaseState) Set(key string, value StateValue) + func (bs *BaseState) SetMetadata(key string, value interface{}) + func (bs *BaseState) ToJSON() ([]byte, error) + func (bs *BaseState) UnmarshalJSON(raw []byte) error + func (bs *BaseState) Update(schema *StateSchema, key string, value StateValue) + type Channel struct + Default func() StateValue + Key string + Reducer Reducer + type ConditionalEdge struct + Condition EdgeCondition + From string + ID string + Metadata map[string]interface{} + Routes map[string]string + type ConditionalRouter struct + func NewConditionalRouter(fallback string) *ConditionalRouter + func (cr *ConditionalRouter) AddRoute(condition string, router RouterFunction) + func (cr *ConditionalRouter) Route(ctx context.Context, state *BaseState) (string, error) + type Edge struct + Condition EdgeCondition + From string + ID string + Metadata map[string]interface{} + To string + type EdgeCondition func(ctx context.Context, state *BaseState) (string, error) + type ExecuteOptions struct + ResumeStep int + StartNode string + Stream chan<- *ExecutionResult + ThreadID string + type ExecutionResult struct + Attempts int + Duration time.Duration + Error error + ErrorMessage string + NodeID string + State *BaseState + Step int + Success bool + Timestamp time.Time + type Graph struct + Config *GraphConfig + Edges map[string]*Edge + EndNodes []string + ID string + Metadata map[string]interface{} + Name string + Nodes map[string]*Node + StartNode string + func NewGraph(name string) *Graph + func (g *Graph) AddConditionalEdges(from string, condition EdgeCondition, routes map[string]string) error + func (g *Graph) AddEdge(from, to string, condition EdgeCondition) *Edge + func (g *Graph) AddEndNode(nodeID string) error + func (g *Graph) AddNode(id, name string, fn NodeFunc) *Node + func (g *Graph) AddSubgraph(id, name string, sub *Graph, opts *SubgraphOptions) (*Node, error) + func (g *Graph) AddUpdateNode(id, name string, fn UpdateFunc) *Node + func (g *Graph) Close() + func (g *Graph) Execute(ctx context.Context, initialState *BaseState) (*BaseState, error) + func (g *Graph) ExecuteParallel(ctx context.Context, nodeIDs []string, state *BaseState) (map[string]*ExecutionResult, error) + func (g *Graph) ExecuteParallelUpdates(ctx context.Context, nodeIDs []string, state *BaseState) (*BaseState, error) + func (g *Graph) ExecuteWithOptions(ctx context.Context, initialState *BaseState, opts *ExecuteOptions) (*BaseState, error) + func (g *Graph) GetConditionalEdge(nodeID string) (*ConditionalEdge, bool) + func (g *Graph) GetCurrentState() *BaseState + func (g *Graph) GetExecutionHistory() []*ExecutionResult + func (g *Graph) GetNextNodes(ctx context.Context, currentNodeID string, state *BaseState) ([]string, error) + func (g *Graph) GetNodesByType(nodeType string) []*Node + func (g *Graph) GetTopology() map[string][]string + func (g *Graph) Interrupt() + func (g *Graph) IsEndNode(nodeID string) bool + func (g *Graph) IsRunning() bool + func (g *Graph) IsStartNode(nodeID string) bool + func (g *Graph) Reset() + func (g *Graph) Resume(ctx context.Context, ie *InterruptError) (*BaseState, error) + func (g *Graph) SetLogger(l *logrus.Logger) + func (g *Graph) SetStartNode(nodeID string) error + func (g *Graph) StateSchema() *StateSchema + func (g *Graph) Stream() <-chan *ExecutionResult + func (g *Graph) Subgraph(nodeID string) (*Graph, bool) + func (g *Graph) Subgraphs() map[string]*Graph + func (g *Graph) Validate() error + func (g *Graph) WithCheckpointer(saver StateSaver, threadID string) *Graph + func (g *Graph) WithStateSchema(schema *StateSchema) *Graph + type GraphConfig struct + EnableCheckpoints bool + EnableStreaming bool + InterruptAfter []string + InterruptBefore []string + MaxIterations int + ParallelExecution bool + RetryAttempts int + RetryDelay time.Duration + Timeout time.Duration + func DefaultGraphConfig() *GraphConfig + func (c *GraphConfig) Clone() *GraphConfig + type InterruptError struct + Before bool + NodeID string + State *BaseState + Step int + ThreadID string + func (e *InterruptError) Error() string + func (e *InterruptError) Is(target error) bool + type Node struct + Function NodeFunc + ID string + Metadata map[string]interface{} + Name string + Retry *RetryPolicy + type NodeFunc func(ctx context.Context, state *BaseState) (*BaseState, error) + type PanicError struct + Stack []byte + Value interface{} + Where string + func (e *PanicError) Error() string + func (e *PanicError) Unwrap() error + type Reducer func(existing, update StateValue) StateValue + type RetryPolicy struct + Backoff float64 + Delay time.Duration + MaxAttempts int + RetryIf func(error) bool + type RouterFunction func(ctx context.Context, state *BaseState) (string, error) + func RouteByCondition(conditionKey string, trueRoute string, falseRoute string) RouterFunction + func RouteByCounter(counterKey string, maxCount int, continueRoute string, exitRoute string) RouterFunction + func RouteByStateValue(key string, routes map[interface{}]string, defaultRoute string) RouterFunction + type StateHistory struct + func NewStateHistory(maxSize int) *StateHistory + func (sh *StateHistory) AddSnapshot(snapshot StateSnapshot) + func (sh *StateHistory) GetSnapshot(id string) (*StateSnapshot, error) + func (sh *StateHistory) GetSnapshots() []StateSnapshot + type StateManager struct + func NewStateManager() *StateManager + func (sm *StateManager) CreateState(id string) *BaseState + func (sm *StateManager) DeleteState(id string) + func (sm *StateManager) GetState(id string) (*BaseState, bool) + func (sm *StateManager) ListStates() []string + type StateSaver interface + SaveState func(ctx context.Context, threadID, nodeID string, step int, state *BaseState) error + type StateSchema struct + func NewStateSchema() *StateSchema + func (s *StateSchema) AddChannel(key string, reducer Reducer, def func() StateValue) *StateSchema + func (s *StateSchema) ApplyUpdates(state *BaseState, updates map[string]StateValue) + func (s *StateSchema) Default(key string) StateValue + func (s *StateSchema) Keys() []string + func (s *StateSchema) NewState() *BaseState + func (s *StateSchema) Reducer(key string) Reducer + type StateSnapshot struct + Data map[string]StateValue + ID string + Metadata map[string]interface{} + Timestamp time.Time + type StateValue interface + func AddMessages(existing, update StateValue) StateValue + func Append(existing, update StateValue) StateValue + func LastValue(existing, update StateValue) StateValue + func MergeMap(existing, update StateValue) StateValue + func SumFloat(existing, update StateValue) StateValue + func SumInt(existing, update StateValue) StateValue + type SubgraphOptions struct + InputKeys []string + Namespace string + OutputKeys []string + PropagateInterrupts bool + Schema *StateSchema + type UpdateFunc func(ctx context.Context, state *BaseState) (map[string]StateValue, error)