cognitive

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cognitive defines cognitive patterns that drive multi-turn inference loops. A cognitive pattern decides when to stop looping based on the state of the conversation — for example, ReAct loops while tool results are pending, and stops when the assistant produces a final response.

At present the package provides a single concrete pattern:

  • ReAct — implements the ReAct feedback loop via Run(ctx, state.State).

Cognitive patterns are conduit-agnostic and stateless. They receive state.State as a parameter and return it, without embedding it. The caller (typically application-level code) is responsible for IO wiring: reading conduit events, appending user messages, routing output events to a conduit, and managing status.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTurnProcessor

func NewTurnProcessor() session.TurnProcessor

NewTurnProcessor returns a session.TurnProcessor that runs the ReAct cognitive pattern. It creates a temporary ReAct with the session's loop.Step and the Manager's provider for each turn.

Types

type ReAct

type ReAct struct {
	Step     *loop.Step
	Provider provider.Provider
}

ReAct is a cognitive pattern that implements the ReAct feedback loop: it repeatedly invokes Step.Turn() while the last turn in state is not from the assistant (indicating pending tool results), driving the assistant to reason, act, and observe until no more tool calls remain.

func (*ReAct) Run

func (r *ReAct) Run(ctx context.Context, st state.State) (state.State, error)

Run executes the ReAct feedback loop starting from the given state. It returns when the last turn is from the assistant (no pending tool calls) or when the context is cancelled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL