Documentation
¶
Overview ¶
Example ¶
ctx := context.Background()
registry := map[string]agent.Agent{
"planner": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
if _, err := tm.Exec(ctx, "test-conv", "deep-research-task", &proto.AgentStart{
AgentId: "deep-research",
Messages: inputs,
}, o); err != nil {
return
}
if _, err := tm.Exec(ctx, "test-conv", "pub-med-lookup-task", &proto.AgentStart{
AgentId: "pub-med-index",
Messages: inputs,
}, o); err != nil {
return
}
}),
}
tm := DefaultExecutor(memoryEventLog(), registry)
if _, err := tm.Exec(ctx, "test-conv", "test", &proto.AgentStart{
AgentId: "planner",
Messages: []*proto.Message{text("user", "Hello, I'd like to research cancer treatment options.")},
}, nil); err != nil {
log.Fatal(err)
}
Index ¶
- func AgentExecutor(eventLog EventLog, registry map[string]agent.Agent) agent.Executor
- func AgentFunc(fn func(input []*proto.Message, tm agent.Executor, o agent.OutputHandler)) agent.Agent
- func DefaultExecutor(eventLog EventLog, registry map[string]agent.Agent) agent.Executor
- type EventLog
- type EventLogBuilder
- type SQLiteEventLog
- func (l *SQLiteEventLog) Append(ctx context.Context, event *proto.ConversationEvent) (int32, error)
- func (l *SQLiteEventLog) AppendExec(ctx context.Context, event *proto.ExecutionEvent) error
- func (l *SQLiteEventLog) Close() error
- func (l *SQLiteEventLog) DeleteEvents(ctx context.Context, conversationID string) error
- func (l *SQLiteEventLog) Events(ctx context.Context, conversationID string) ([]*proto.ConversationEvent, error)
- func (l *SQLiteEventLog) ExecEvents(ctx context.Context, execID string) ([]*proto.ExecutionEvent, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentExecutor ¶
AgentExecutor returns an Executor suitable for invoking sub-agents from within a planner or another agent's Connect method.
Unlike DefaultExecutor (which is the controller's top-level conversation runner), AgentExecutor:
- Does NOT load conversation history from the event log; the caller passes the relevant messages in start.Messages.
- Does NOT short-circuit on WaitsForConfirmation or COMPLETED cache.
- DOES write execution-level logs (pending, outputs, completed) for observability, but omits the WaitsForConfirmation/COMPLETED guards that DefaultExecutor uses.
- Returns STATE_PENDING when the sub-agent's last output is an unanswered confirmation question.
Types ¶
type EventLog ¶
type EventLog interface {
// Append adds a conversation event to the end of the log.
Append(ctx context.Context, event *proto.ConversationEvent) (int32, error)
// AppendExec adds an execution event to the end of the log.
AppendExec(ctx context.Context, event *proto.ExecutionEvent) error
// Events returns all events for the conversation.
Events(ctx context.Context, conversationID string) ([]*proto.ConversationEvent, error)
// ExecEvents returns all events for a specific execution ID.
ExecEvents(ctx context.Context, execID string) ([]*proto.ExecutionEvent, error)
// DeleteEvents deletes all events for a specific conversation ID.
DeleteEvents(ctx context.Context, conversationID string) error
// Close releases the underlying resources and closes the log.
Close() error
}
EventLog is the persistent, append-only record of all actions taken in an exec. Every entry is an atomic step: replaying the log in order brings the executor back to a consistent state from which execution can resume.
type EventLogBuilder ¶
type SQLiteEventLog ¶
type SQLiteEventLog struct {
// contains filtered or unexported fields
}
SQLiteEventLog is a durable EventLog that persists events in a SQLite database. It is safe for concurrent use.
func OpenSQLiteEventLog ¶
func OpenSQLiteEventLog(path string) (*SQLiteEventLog, error)
OpenSQLiteEventLog opens (or creates) a SQLite database at path and initializes the event log schema.
func (*SQLiteEventLog) Append ¶
func (l *SQLiteEventLog) Append(ctx context.Context, event *proto.ConversationEvent) (int32, error)
Append serializes the event to JSON and inserts it into the database.
func (*SQLiteEventLog) AppendExec ¶
func (l *SQLiteEventLog) AppendExec(ctx context.Context, event *proto.ExecutionEvent) error
AppendExec inserts an execution event into the database.
func (*SQLiteEventLog) Close ¶
func (l *SQLiteEventLog) Close() error
Close releases the database connection.
func (*SQLiteEventLog) DeleteEvents ¶
func (l *SQLiteEventLog) DeleteEvents(ctx context.Context, conversationID string) error
DeleteEvents deletes all events for a specific conversation ID and its child executions.
func (*SQLiteEventLog) Events ¶
func (l *SQLiteEventLog) Events(ctx context.Context, conversationID string) ([]*proto.ConversationEvent, error)
Events retrieves all events from the database for a conversation, ordered by seq and execution order.
func (*SQLiteEventLog) ExecEvents ¶
func (l *SQLiteEventLog) ExecEvents(ctx context.Context, execID string) ([]*proto.ExecutionEvent, error)
ExecEvents retrieves all events from the database for a specific execution ID.