state.go

Overview

This file defines the internal state representation and interface for agents within the system. It encapsulates the state details of an agent including its type and configuration, and provides a mechanism to access this internal state. The design supports various predefined agent types and allows for extensibility through a generic configuration field.

The primary purpose of this file is to provide a minimal yet extensible abstraction of agent state management, enabling other components to interact with agent metadata and configuration in a uniform way.


Types and Interfaces

Agent Interface

type Agent interface {
	internal() *State
}

State Struct

type State struct {
	AgentType Type
	Config    any
}

Type Alias and Constants

type Type string
const (
	TypeLLMAgent        Type = "LLMAgent"
	TypeLoopAgent       Type = "LoopAgent"
	TypeSequentialAgent Type = "SequentialAgent"
	TypeParallelAgent   Type = "ParallelAgent"
	TypeCustomAgent     Type = "CustomAgent"
)

Functions

Reveal

func Reveal(a Agent) *State { return a.internal() }
var agent Agent = &State{
	AgentType: TypeLLMAgent,
	Config:    someConfig,
}

state := Reveal(agent)
fmt.Println(state.AgentType) // Output: LLMAgent

Implementation Details


Interaction with Other System Components


Diagram: Agent State Structure

classDiagram
class Agent {
<<interface>>
+internal()
}
class State {
+AgentType: Type
+Config: any
+internal()
}
class Type
Agent <|.. State
State o-- Type : AgentType