Documentation
¶
Overview ¶
Package model is CSF's contract with a brain: an agent loop over a large model behind an inference provider or API. The brain is external; CSF ships this contract and a deterministic stub (ipc/model/stub), and each provider lives in its own subpackage, ipc/model/<provider>, because reaching a model crosses a process or network boundary.
Given context, a brain proposes actions. A language model's proposal is not permission to execute it: admission, checks and execution belong to the caller.
Index ¶
- Constants
- Variables
- func AddressKey(provider string, tier io.Tier, parts ...string) string
- type AmbiguousProposalError
- type IAgentAddress
- type IBrain
- type InProcessTier
- type IpcTier
- type NetTier
- type Proposal
- type TurnReport
- func (report *TurnReport) Diagnostics(stderr []byte)
- func (report *TurnReport) Event(direction string, kind string, raw json.RawMessage)
- func (report *TurnReport) Finished(events int, err error)
- func (report *TurnReport) Malformed(line int, size int, err error)
- func (report *TurnReport) Started(executable string, resume bool, inputs int)
Constants ¶
const ( // DirectionIn marks an event the turn executor was given. DirectionIn = "in" // DirectionOut marks an event the turn executor reported. DirectionOut = "out" // EventTypeMalformed names, in the report only, an output line that was // not an event. EventTypeMalformed = "malformed" )
Report vocabulary: the slog message and attribute keys every turn executor's turn report writes, so one run's log reads the same whichever executor ran the turn.
Variables ¶
var ErrNoProposal = errors.New("brain proposed no action")
ErrNoProposal reports that a brain answered without proposing any action.
Functions ¶
Types ¶
type AmbiguousProposalError ¶
AmbiguousProposalError reports more proposed actions than the caller can admit for one decision.
func (*AmbiguousProposalError) Error ¶
func (failure *AmbiguousProposalError) Error() string
type IAgentAddress ¶
type IAgentAddress interface {
// Provider names the provider that owns this address type.
Provider() string
// Key identifies the session uniquely across providers and tiers. It is
// the address's stable identity in registries, inboxes and logs.
Key() string
// Tier is how far a message to this address travels from the runtime
// that holds the inbox.
Tier() io.Tier
// contains filtered or unexported methods
}
IAgentAddress is where one agent's live conversation session receives messages. Each provider declares its own address types beside its brain, under ipc/model/<provider>, because what identifies a session is the provider's to say: a Claude Code session is a session identifier plus the local socket it is reached on, a Copilot session is a session identifier reached through the Copilot provider.
The tier is part of the address's TYPE, not a field: every address type embeds exactly one of InProcessTier, IpcTier or NetTier, and the interface is closed by an unexported method only those three markers carry. That makes it a sealed sum type over the three tiers: an address that a caller built as in-process cannot be routed through a socket, because no value of its type answers any other tier.
type IBrain ¶
type IBrain[Context any, Action any] interface { // Propose returns the actions the brain proposes for decision. A proposal // is never permission to execute it. Propose(ctx context.Context, decision Context) (*Proposal[Action], error) }
IBrain is an agent loop over a large model behind an inference provider. Context is the information supplied for one decision; Action is what the brain may propose. Both are type parameters, so a caller never holds an untyped value at this boundary.
type InProcessTier ¶
type InProcessTier struct{}
InProcessTier marks an address whose session runs in the same runtime: a direct call or a channel reaches it, with no capability.
type IpcTier ¶
type IpcTier struct{}
IpcTier marks an address whose session runs in another process on the same machine, reached through an ipc capability (a unix socket, or loopback through ipc/net).
type NetTier ¶
type NetTier struct{}
NetTier marks an address whose session runs on another machine, reached through ipc/net.
type Proposal ¶
type Proposal[Action any] struct { // Provider names the inference provider that produced the proposal. Provider string // Actions are the proposed actions in the order the brain gave them. Actions []Action }
Proposal is a brain's answer for one decision. It is data, not an authorization: the caller decides whether any action is admitted.
type TurnReport ¶
type TurnReport struct {
// contains filtered or unexported fields
}
TurnReport writes one turn's structured log: a trace per turn, a span per event. When the caller's context already carries a trace, the turn is a child span of it; otherwise the turn starts a new W3C trace. One goroutine at a time writes a report.
func NewTurnReport ¶
func NewTurnReport(ctx context.Context, logger *slog.Logger, provider string, session uuid.UUID, turn int) (*TurnReport, error)
NewTurnReport opens the report of turn on session for provider.
func (*TurnReport) Diagnostics ¶
func (report *TurnReport) Diagnostics(stderr []byte)
Diagnostics reports what the executor's process wrote to standard error, if anything.
func (*TurnReport) Event ¶
func (report *TurnReport) Event(direction string, kind string, raw json.RawMessage)
Event reports one event in or out under a span of its own. Progress ticks are thinned to one per progressInterval; the latest thinned tick is written before the next other event and before the turn's end, so the final running total is always in the log.
func (*TurnReport) Finished ¶
func (report *TurnReport) Finished(events int, err error)
Finished reports the turn's end: how many events it carried and, for a failed turn, why.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package claudecode is the Claude Code provider: a Claude Code session is an agent loop in its own process on the operator's machine.
|
Package claudecode is the Claude Code provider: a Claude Code session is an agent loop in its own process on the operator's machine. |
|
Package copilot is the first inference provider behind CSF's brain contract: the GitHub Copilot agent loop, reached through the existing Copilot adapter's generated Workbench client (services/copilot-adapter/gen/api).
|
Package copilot is the first inference provider behind CSF's brain contract: the GitHub Copilot agent loop, reached through the existing Copilot adapter's generated Workbench client (services/copilot-adapter/gen/api). |
|
Package copilotcli is the GitHub Copilot CLI provider: CopilotCLIExecutor drives the Copilot command line as a turn executor for one session CSF owns.
|
Package copilotcli is the GitHub Copilot CLI provider: CopilotCLIExecutor drives the Copilot command line as a turn executor for one session CSF owns. |
|
Package jev asks JEV-9B typed decisions.
|
Package jev asks JEV-9B typed decisions. |
|
Package llamacpp reaches a llama.cpp server started with --reranking: a cross-encoder that scores how well each document answers one query.
|
Package llamacpp reaches a llama.cpp server started with --reranking: a cross-encoder that scores how well each document answers one query. |
|
Package ollama is the local model provider behind CSF's brain contract: an Ollama server, on this host or a neighbour, reached over its HTTP API through the http capability the constructor receives.
|
Package ollama is the local model provider behind CSF's brain contract: an Ollama server, on this host or a neighbour, reached over its HTTP API through the http capability the constructor receives. |
|
Package stub is the brain that needs no model: it answers every decision with the same canned proposal, so the harness runs and its specs pass with no inference provider, network or credential at all.
|
Package stub is the brain that needs no model: it answers every decision with the same canned proposal, so the harness runs and its specs pass with no inference provider, network or credential at all. |