interaction

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package interaction composes chat models, tools, and delegates into managed Programs with Input and Output. Compile requires the Runtime's immutable Compiler, an implementation Revision, and explicit configuration. The Compiler freezes configuration and exact child bindings into the Program identity.

Each Execution owns its conversation and decision progress. Its definition retains immutable tool declarations, validators, and classifiers; only the dispatcher holds executable models and tools. Every model request, including its advertised tools, is frozen in an Effect before external work starts. ModelCallFromEffect and ToolCallFromEffect decode committed intent; ModelSettlementFromRecord and ToolSettlementFromRecord decode its settlement. Transient streaming deltas do not establish durable results. A model call publishes ModelResponseDelta values and a tool call publishes the progress its Tool reports; ParseModelResponseDelta and ParseToolProgress decode them.

Ordinary tool calls are direct dispatcher Effects. Their first EffectID is the logical reference across continuation Effects and result projections. Every attempt receives an opaque tool.IdempotencyKey digested from it, so external systems can deduplicate replayed work without learning process structure. ToolInvocation.IdempotencyKey gives Hosts the same key when they reconcile an Unknown call. A tool.InputRequest opens a local Wait; each later question receives a new WaitKey so an old answer retry cannot answer a new question. PendingToolInputs lists those waits from a run.TreeInspection, their only record. The process and WaitKey own answer routing; tool call names and model call IDs do not.

Delegate calls use Spawn and consume the child's Exit. An Exit establishes that the entire subtree drained, including uncertain external work. Delegates and tools retain results in model proposal order even when they complete out of order. Tool concurrency and resource classification bound admission; completed siblings need not wait for unrelated tools before freeing a slot. A whole proposal is validated before any of its calls execute.

A definite tool.Failure becomes model-visible feedback. Ordinary errors, invalid external results, and panics remain Unknown because they cannot prove that external work did not happen. Hosts investigate and submit a settlement through run.Handle.ResolveUnknownEffect. SettleToolResult, SettleModelResult, and SettlePreparedContext preserve the interaction's typed result contract. Tool recovery accepts the complete tool.Result, including an input request whose external receipt was lost before its question reached the Log. An interrupted call is redispatched only when its Tool declares tool.Definition.Effect; every other interrupted call settles Unknown. Runtime failures are recorded separately from opaque dispatcher outcomes.

NewSteerSignal accepts unaddressed steering at a safe conversation boundary. Steering received during model or tool work applies before the next model request; it neither cancels that work nor answers a tool's addressed Wait. Completion validators and context policies execute in discardable Steps and must be deterministic, bounded, side-effect-free, and cancellation-aware. External context processing belongs in its dispatcher Effect instead.

HistoryProjection reads settled tool rounds and delegate attributions from the complete history that run.Runtime.History reads, because a checkpoint does not keep settled rounds. It owns no acknowledgment, execution, persistence, or retry policy.

Index

Constants

View Source
const (
	ToolOutcomeInvalid       ToolOutcome = ""
	ToolOutcomeSucceeded                 = ToolOutcome(ResultSucceeded)
	ToolOutcomeFailed                    = ToolOutcome(ResultFailed)
	ToolOutcomeRejected                  = ToolOutcome(ResultRejected)
	ToolOutcomeInputRequired ToolOutcome = "input_required"
	// ToolOutcomeDispatchFailed means dispatch failed definitely; no result
	// reached the model.
	ToolOutcomeDispatchFailed ToolOutcome = "dispatch_failed"
	ToolOutcomeUnknown        ToolOutcome = "unknown"
)
View Source
const DefaultMaxStreamDeltaBytes = 64 << 20

DefaultMaxStreamDeltaBytes keeps stream admission bounded independently of the final settlement size, including streams that never finish.

Variables

View Source
var (
	ErrInvalidResult            = errors.New("interaction: invalid result")
	ErrInvalidModelSettlement   = errors.New("interaction: invalid model settlement")
	ErrInvalidToolAdvertisement = errors.New("interaction: invalid tool advertisement")
	ErrInvalidPendingToolInput  = errors.New("interaction: invalid pending tool input")
	ErrInvalidDefinitionConfig  = errors.New("interaction: invalid definition configuration")
	ErrInvalidDispatcherConfig  = errors.New("interaction: invalid dispatcher configuration")
	ErrInvalidToolSet           = errors.New("interaction: invalid tool set")
	ErrInvalidDelegate          = errors.New("interaction: invalid delegate")
	ErrInvalidInput             = errors.New("interaction: invalid input")
)

These sentinels belong to construction, domain values, dispatcher operations, and Tool control flow rather than Steps, so they carry no Failure classification.

View Source
var (
	ErrInvalidSteer = run.NewClassifiedError(
		run.FailureKindContract,
		"interaction.signal.invalid",
		"interaction: invalid steer",
	)
	ErrInvalidExecutionState = run.NewClassifiedError(
		run.FailureKindContract,
		"interaction.state.invalid",
		"interaction: invalid execution state",
	)
	ErrInvalidProtocol = run.NewClassifiedError(
		run.FailureKindContract,
		"interaction.protocol.invalid",
		"interaction: invalid protocol payload",
	)
	// ErrInvalidModelResponse rejects the whole Step, so a structurally valid
	// response that violates Interaction constraints never enters its state.
	ErrInvalidModelResponse = run.NewClassifiedError(
		run.FailureKindExternal,
		"interaction.model.invalid_response",
		"interaction: invalid model response",
	)
)

Execution sentinels own the Failure persisted when they reach Step. Wrapping one is the only way a Step error acquires its classification. Protocol and restored-state errors stay distinct because their recovery responsibilities differ.

View Source
var ErrModelResponseTooLarge = errors.New("interaction: model response exceeds byte limit")

ErrModelResponseTooLarge rejects a canonical settlement that exceeds its budget. Complete generation remains observable, but its Effect stays unknown. Oversize replacement context fails before the model is called.

View Source
var ErrModelStreamTooLarge = errors.New("interaction: encoded model response deltas exceed stream byte limit")

ErrModelStreamTooLarge stops consumption before an encoded delta exceeds the stream admission budget. Observed generation cannot establish non-execution.

Functions

func Compile added in v0.60.0

func Compile(compiler *run.Compiler, cfg Config) (run.Program[Input, Output], error)

Compile freezes the real model loop, binds its child programs and checks its Go input/output against the same schemas used at dispatch and recovery.

func DelegateChildKey

func DelegateChildKey(modelCallSequence uint64, toolCall chat.ToolCall) (run.ChildKey, error)

func NewSteerSignal

func NewSteerSignal(id run.SignalID, messages ...chat.Message) (run.Signal, error)

NewSteerSignal wraps user messages as an unaddressed Signal. The mailbox makes steering deduplicated, ordered, and log-visible, so a resumed Process sees the same guidance. Steering admitted before a Tool input wait remains pending until the Tool batch settles, including admission during the Step that enters Waiting.

func ParseToolProgress added in v0.60.0

func ParseToolProgress(payload json.RawMessage) (tool.Progress, error)

ParseToolProgress decodes one Delta a tool call Effect published. Like a model response Delta it is observational and never restores a call.

func SettleModelResult added in v0.60.0

func SettleModelResult[I, O any](program run.Program[I, O], request run.EffectRequest, response *chat.Response) (run.Settlement, error)

SettleModelResult validates an investigated model response against the exact bound program and original effect. The effective input is already frozen.

func SettlePreparedContext added in v0.60.0

func SettlePreparedContext[I, O any](program run.Program[I, O], request run.EffectRequest, messages []chat.Message) (run.Settlement, error)

SettlePreparedContext validates investigated messages for a context effect without repeating the processor or the model.

func SettleToolResult added in v0.60.0

func SettleToolResult[I, O any](program run.Program[I, O], request run.EffectRequest, result tool.Result, disposition ResultDisposition, advertised []string) (run.Settlement, error)

SettleToolResult takes advertised as the Tool identities its AdvertisingTool returned for this result, exactly as live dispatch reads them.

Types

type AdvertisingTool added in v0.60.0

type AdvertisingTool interface {
	AdvertiseDeferred(ctx context.Context, invocation tool.Invocation, result tool.Result) ([]string, error)
}

AdvertisingTool is a Tool that reveals already-bound deferred Tools to the model after it runs under an Interaction. When a managed call settles with a successful result, the Interaction calls AdvertiseDeferred with that call's invocation and result and makes the returned deferred Tool names visible from the next model call onward. The capability lives in the Tool's type, not in the call context: a Tool that does not implement it never advertises, the same Tool run outside an Interaction has no advertising authority, and a rejected, failed, or input-pending call never reaches AdvertiseDeferred, so its declaration cannot commit. Advertising adds visibility only, never executable authority. Names must be exact deferred Tool names; the Interaction normalizes order and duplicates and rejects any name that is not a bound deferred Tool. AdvertiseDeferred is a bounded, deterministic, side-effect-free projection of invocation and result. External work belongs in Tool.Call. A declaration defect fails the Interaction without retracting its already completed call.

type Artifact

type Artifact struct {
	// contains filtered or unexported fields
}

Artifact is one successful, schema-validated Delegate output, identified by its exact Delegate binding rather than a Go type.

func (Artifact) DelegateName

func (a Artifact) DelegateName() string

func (Artifact) ModelCallSequence added in v0.60.0

func (a Artifact) ModelCallSequence() uint64

ModelCallSequence identifies the model call within this Interaction Process. Together with ToolCallID it identifies an Artifact across snapshot restoration.

func (Artifact) Output

func (a Artifact) Output() run.Payload

Output is already validated against the exact Delegate Descriptor. Its Payload owns typed decoding, without a separate Artifact conversion rule.

func (Artifact) ToolCallID added in v0.60.0

func (a Artifact) ToolCallID() string

type CompletionCandidate

type CompletionCandidate struct {
	// contains filtered or unexported fields
}

CompletionCandidate is the immutable model context and semantic output proposed by an Interaction together with all successful Delegate Artifacts available at that boundary.

func (CompletionCandidate) Artifacts

func (c CompletionCandidate) Artifacts() []Artifact

Artifacts returns an independently owned slice of successful Delegate outputs in original model ToolCall order across model calls. Each Artifact is immutable.

func (CompletionCandidate) Output

func (c CompletionCandidate) Output() Output

Output returns an independently owned candidate Output.

func (CompletionCandidate) WorkingContext

func (c CompletionCandidate) WorkingContext() *chat.Request

WorkingContext returns an independently owned copy of the model context preceding this candidate. It is Interaction state, not Host conversation or transcript history, and it does not yet contain the candidate Output.

type CompletionDecision

type CompletionDecision struct {
	Accepted bool
	Feedback string
}

CompletionDecision is the explicit result of a CompletionValidator. Accepted=true requires empty Feedback. Accepted=false requires concise, non-empty Feedback that will be appended as a user message before the next model call.

func (CompletionDecision) Valid

func (c CompletionDecision) Valid() bool

type CompletionValidator

type CompletionValidator func(ctx context.Context, candidate CompletionCandidate) (CompletionDecision, error)

CompletionValidator decides whether a model or direct-Tool candidate is a valid semantic completion. It must be bounded, deterministic and side-effect-free: no I/O, clock, randomness, shared mutation or goroutines. A rejected candidate must return actionable Feedback; a finite MaxModelCalls remains the hard bound on retry rounds. Evaluation requiring external work belongs in a managed child Process, not this callback. Computation must honor cancellation of the current Step context.

type ConcurrentTool

type ConcurrentTool interface {
	// ConcurrencyPolicy returns an immutable classifier, frozen at ToolSet
	// construction. It must not retain the Tool or any execution backend,
	// including through a bound method or closure. Nil requires exclusive calls.
	// The classifier receives an admitted invocation and must be deterministic,
	// bounded, side-effect-free, concurrent-safe, and not retain its input.
	// Its identity and captured configuration belong in the ToolSet Revision.
	ConcurrencyPolicy() func(tool.Invocation) (key string, concurrent bool)
}

ConcurrentTool supplies an independent scheduling policy for calls within one model-requested batch. Tools without a policy, or calls returning concurrent=false, execute alone. A non-empty key names a mutually exclusive resource: calls with the same key in that batch never overlap. Cross-Process resource coordination remains the Tool owner's job.

Each call keeps its own Effect and may wait for external input while siblings continue. The limit counts a waiting call as active until its Tool result is complete. Pure scheduling declarations may be reevaluated during recovery.

type Config added in v0.60.0

type Config struct {
	// CompletionValidator optionally verifies a proposed final semantic output
	// against the current WorkingContext and accumulated typed Delegate
	// Artifacts. It is a pure Strategy callback whose identity must be covered
	// by Revision. Nil accepts every otherwise valid completion.
	CompletionValidator CompletionValidator
	ContextPolicy       ContextPolicy
	// ContextProcessor, when set, prepares every model context as an external
	// Effect before the model call.
	ContextProcessor ContextProcessor
	Name             string
	Description      string
	Revision         string
	Model            ModelSource
	// Tools freezes tool admission and execution policy.
	Tools ToolSet
	// MaxModelCalls bounds model Effects in one Interaction. Its zero value is
	// unlimited; a finite zero is rejected because an Interaction needs a model call.
	MaxModelCalls            run.Quota
	RequiredToolCapabilities run.CapabilitySet
	// MaxConcurrentToolCalls bounds active calls declared safe to overlap.
	// Zero means one; calls without a concurrency declaration execute alone.
	MaxConcurrentToolCalls int
	// MaxResponseBytes bounds each prepared-context and model-result
	// settlement. Zero uses the runtime payload limit; a limit below the
	// smallest complete model response is rejected.
	MaxResponseBytes int
	// Delegates is the frozen model-visible manifest of exact child Programs.
	// Names must be unique and must not collide with ordinary Tools.
	Delegates []Delegate
}

Config describes one Interaction. Cumulative quotas default to unlimited; the Host retains cancellation and capacity controls.

type ContextFailure added in v0.60.0

type ContextFailure struct{ Cause error }

ContextFailure reports a definite rejection by a context processor; an ordinary transport error cannot establish this guarantee.

func (*ContextFailure) Error added in v0.60.0

func (c *ContextFailure) Error() string

func (*ContextFailure) Unwrap added in v0.60.0

func (c *ContextFailure) Unwrap() error

type ContextInvocation added in v0.60.0

type ContextInvocation struct {
	Effect   run.EffectRequest
	Sequence uint64
}

ContextInvocation identifies preparation for a model call. Its Effect is the preparation's own logical operation, not the subsequent model operation.

type ContextPolicy added in v0.60.0

type ContextPolicy func(ctx context.Context, input Input) ([]chat.Message, error)

ContextPolicy is a deterministic, bounded local transformation. It must not perform I/O or retain input. Use ContextProcessor for retrieval or model-based summaries.

type ContextProcessor added in v0.60.0

type ContextProcessor interface {
	PrepareContext(ctx context.Context, invocation ContextInvocation, request *chat.Request) ([]chat.Message, error)
}

ContextProcessor prepares the complete message sequence as a separately committed external effect. An error leaves the effect Unknown unless it is a ContextFailure proving a definite outcome.

type Delegate

type Delegate struct {
	// contains filtered or unexported fields
}

Delegate is an immutable, model-visible binding to one exact managed child Program. It is a composition value owned by Interaction, not an executable Tool or a second Process-start entry point.

func NewDelegate

func NewDelegate(config DelegateConfig) (Delegate, error)

NewDelegate fixes the target at construction; model selection cannot change its Program, budget, or capabilities.

func (Delegate) Valid

func (d Delegate) Valid() bool

type DelegateAttribution added in v0.60.0

type DelegateAttribution struct {
	// contains filtered or unexported fields
}

func (DelegateAttribution) ChildKey added in v0.60.0

func (d DelegateAttribution) ChildKey() run.ChildKey

func (DelegateAttribution) ModelCallSequence added in v0.60.0

func (d DelegateAttribution) ModelCallSequence() uint64

func (DelegateAttribution) ProcessID added in v0.60.0

func (d DelegateAttribution) ProcessID() run.ProcessID

func (DelegateAttribution) Reference added in v0.60.0

func (d DelegateAttribution) Reference() (run.EffectID, bool)

func (DelegateAttribution) ToolCall added in v0.60.0

func (d DelegateAttribution) ToolCall() chat.ToolCall

func (DelegateAttribution) ToolCallIndex added in v0.60.0

func (d DelegateAttribution) ToolCallIndex() uint32

func (DelegateAttribution) Valid added in v0.60.0

func (d DelegateAttribution) Valid() bool

type DelegateConfig

type DelegateConfig struct {
	// Name is the provider-compatible model Tool name.
	Name string

	Description string

	Child run.ChildBinding
}

DelegateConfig exposes one exact child Program as a model-selectable Interaction capability. Name and Description are written for the model; lifecycle identity and resource authority remain frozen Framework values.

type DirectResultTool

type DirectResultTool interface {
	// ReturnsDirectResult is read once by NewToolSet; it must not depend on
	// mutable state or perform I/O.
	ReturnsDirectResult() bool
}

DirectResultTool is an optional Tool capability declaring that a successful model-requested batch containing only such tools returns its ordered results directly instead of making another model call. The declaration is frozen by NewToolSet; a panic or capability-resolution error rejects construction.

type HistoryProjection added in v0.61.0

type HistoryProjection struct {
	// contains filtered or unexported fields
}

HistoryProjection reads one interaction Program's settled tool rounds and delegate attributions from the complete history that run.Runtime.History returns. A checkpoint does not keep settled rounds, so every read validates and folds the whole caller-owned Log, exactly as the first read did.

Strictly decoding committed model requests dominates that fold and grows with the conversation, so the projection remembers what each dispatcher Effect of its latest successfully projected history decoded to, keyed by EffectID and its exact canonical payload. A host re-reading a growing history after each commit therefore decodes every committed request once. The projection retains those payloads until its next successful read. It is safe for concurrent use and owns no acknowledgment, execution, persistence or retry policy.

func NewHistoryProjection added in v0.61.0

func NewHistoryProjection[I, O any](program run.Program[I, O]) (*HistoryProjection, error)

NewHistoryProjection binds a projection to a compiled interaction Program. Programs with the same Go types but another definition are rejected.

func (*HistoryProjection) DelegateAttributions added in v0.61.0

func (h *HistoryProjection) DelegateAttributions(log run.Log) ([]DelegateAttribution, error)

DelegateAttributions returns the started delegate children and the proposed calls that own them.

func (*HistoryProjection) SettledResults added in v0.61.0

func (h *HistoryProjection) SettledResults(log run.Log) ([]RoundResults, error)

SettledResults returns the rounds with at least one settled call. Only committed intents establish references. Locally rejected proposals that never emitted an effect are not presented as externally executed operations.

type Input

type Input struct {
	Messages []chat.Message `json:"messages"`

	Options chat.Options `json:"options,omitzero"`
}

Input excludes executable Tools: the Program fixes their ToolSet authority.

func (Input) Validate

func (i Input) Validate() error

type ModelCallIntent added in v0.61.0

type ModelCallIntent struct {
	Sequence uint64
	Request  *chat.Request
}

Sequence comes from the committed intent; observers must not reconstruct it from a filtered history or use a presentation ordinal as a child identity.

func ModelCallFromEffect added in v0.61.0

func ModelCallFromEffect(effect run.Effect) (ModelCallIntent, bool, error)

type ModelOutcome added in v0.60.0

type ModelOutcome string

ModelOutcome belongs to the complete model invocation, including middleware. Failed does not establish token use.

const (
	ModelOutcomeInvalid     ModelOutcome = ""
	ModelOutcomeSucceeded   ModelOutcome = "succeeded"
	ModelOutcomeFailed      ModelOutcome = "failed"
	ModelOutcomeNotExecuted ModelOutcome = "not_executed"
	ModelOutcomeUnknown     ModelOutcome = "unknown"
)

func (ModelOutcome) Valid added in v0.60.0

func (m ModelOutcome) Valid() bool

type ModelResponseDelta

type ModelResponseDelta struct {
	// contains filtered or unexported fields
}

ModelResponseDelta is one validated provider-neutral streaming increment. It is observational and never a source for final Output or restoration.

func ParseModelResponseDelta

func ParseModelResponseDelta(payload json.RawMessage) (ModelResponseDelta, error)

func (ModelResponseDelta) ResponseDelta added in v0.13.0

func (m ModelResponseDelta) ResponseDelta() *chat.ResponseDelta

ResponseDelta returns an independently owned transport increment.

type ModelSettlement added in v0.60.0

type ModelSettlement struct {
	Outcome  ModelOutcome   `json:"outcome"`
	Response *chat.Response `json:"response,omitzero"`
	Failure  string         `json:"failure,omitzero"`
}

ModelSettlement is a detached projection of the committed Effect settlement. Response retains generation even when postprocessing failed or is uncertain; its presence cannot prove middleware success. Only NotExecuted establishes that no provider work ran.

func ModelSettlementFromRecord added in v0.61.0

func ModelSettlementFromRecord(record run.EffectSettled) (ModelSettlement, error)

ModelSettlementFromRecord projects the committed settlement of a model call, including one the runtime left Unknown because Dispatch returned an error.

func (ModelSettlement) Validate added in v0.60.0

func (m ModelSettlement) Validate() error

type ModelSource added in v0.60.0

type ModelSource interface {
	// contains filtered or unexported methods
}

ModelSource is how an Interaction obtains each model response. CallModel and StreamModel are its only forms, so a configuration names exactly one way to reach the model and carries only the settings that way uses.

func CallModel added in v0.60.0

func CallModel(model chat.Model) ModelSource

CallModel obtains each response from one complete model call.

func StreamModel added in v0.60.0

func StreamModel(config StreamModelConfig) ModelSource

StreamModel obtains each response by accumulating a stream whose deltas the Runtime publishes as they arrive.

type Output

type Output struct {
	ModelResponse *chat.Response `json:"model_response,omitzero"`

	// DirectToolResults preserves model ToolCall order.
	DirectToolResults []chat.ToolResult `json:"direct_tool_results,omitempty"`

	// ModelCalls is the number of model Effects issued by this Interaction.
	ModelCalls uint64 `json:"model_calls"`
}

Output is the final semantic Interaction result. Exactly one completion is present: ModelResponse when the model produced a final response without requesting another tool round, or DirectToolResults when every call in one model-requested batch targeted a DirectResultTool and returned successfully. ModelResponse is accumulated independently of best-effort stream Delta delivery, so it remains complete after delta loss or snapshot restoration.

func (Output) Validate

func (o Output) Validate() error

type PendingToolInput

type PendingToolInput struct {
	// contains filtered or unexported fields
}

Continuation state remains private to the dispatcher; only the committed question and its answer contract cross the input boundary.

func PendingToolInputs added in v0.16.0

func PendingToolInputs[I, O any](program run.Program[I, O], inspection run.TreeInspection) []PendingToolInput

PendingToolInputs lists the tool questions awaiting an answer. Every Wait an interaction opens is a tool question, so the committed waits are the one complete record of them and need no history.

func (PendingToolInput) ProcessID added in v0.16.0

func (p PendingToolInput) ProcessID() run.ProcessID

func (PendingToolInput) Prompt

func (p PendingToolInput) Prompt() json.RawMessage

func (PendingToolInput) ResponseSchema

func (p PendingToolInput) ResponseSchema() json.RawMessage

func (PendingToolInput) ResponseSignal

func (p PendingToolInput) ResponseSignal(id run.SignalID, response json.RawMessage) (run.Signal, error)

ResponseSignal addresses response to this question after checking it with the committed Wait's own admission rule.

func (PendingToolInput) Valid

func (p PendingToolInput) Valid() bool

func (PendingToolInput) WaitKey added in v0.60.0

func (p PendingToolInput) WaitKey() run.WaitKey

type ResultDisposition added in v0.60.0

type ResultDisposition string
const (
	ResultInvalid   ResultDisposition = ""
	ResultSucceeded ResultDisposition = "succeeded"
	ResultFailed    ResultDisposition = "failed"
	ResultRejected  ResultDisposition = "rejected"
)

func (ResultDisposition) String added in v0.60.0

func (r ResultDisposition) String() string

func (ResultDisposition) Valid added in v0.60.0

func (r ResultDisposition) Valid() bool

type ResultEntry added in v0.60.0

type ResultEntry struct {
	Reference     run.EffectID      `json:"reference"`
	ToolCallIndex uint32            `json:"tool_call_index"`
	Call          chat.ToolCall     `json:"call"`
	Result        chat.ToolResult   `json:"result"`
	Disposition   ResultDisposition `json:"disposition"`
}

type RoundResults added in v0.60.0

type RoundResults struct {
	// contains filtered or unexported fields
}

A sparse round preserves the provider's indexes. Missing outcomes never authorize retry, and an input request does not establish a final result.

func (RoundResults) CallCount added in v0.60.0

func (r RoundResults) CallCount() uint32

func (RoundResults) Complete added in v0.60.0

func (r RoundResults) Complete() bool

func (RoundResults) Digest added in v0.60.0

func (r RoundResults) Digest() run.Digest

func (RoundResults) Entries added in v0.60.0

func (r RoundResults) Entries() []ResultEntry

func (RoundResults) JSON added in v0.60.0

func (r RoundResults) JSON() json.RawMessage

func (RoundResults) ModelCallSequence added in v0.60.0

func (r RoundResults) ModelCallSequence() uint64

func (RoundResults) ModelEffectID added in v0.60.0

func (r RoundResults) ModelEffectID() run.EffectID

func (RoundResults) ProcessID added in v0.60.0

func (r RoundResults) ProcessID() run.ProcessID

func (RoundResults) Reference added in v0.60.0

func (r RoundResults) Reference(index uint32) (run.EffectID, bool)

type StreamModelConfig added in v0.60.0

type StreamModelConfig struct {
	Streamer chat.Streamer
	// MaxDeltaBytes bounds cumulative Scope-encoded ModelResponseDelta payloads
	// before accumulation, independently of MaxResponseBytes. Zero uses
	// DefaultMaxStreamDeltaBytes.
	MaxDeltaBytes int
}

type ToolCallIntent added in v0.60.0

type ToolCallIntent struct {
	Call           chat.ToolCall
	ContinuationOf run.EffectID
}

ToolCallIntent is the call a committed tool Effect dispatches. ContinuationOf is the Effect of the original call when this Effect resumes it with requested input, and zero for the original dispatch.

func ToolCallFromEffect added in v0.60.0

func ToolCallFromEffect(effect run.Effect) (ToolCallIntent, bool, error)

type ToolInvocation

type ToolInvocation struct {
	// contains filtered or unexported fields
}

ToolInvocation is the durable identity of one tool call Effect. A resumed call keeps the identity of the Effect that first requested input, so every continuation of one logical call shares its idempotency key.

func ToolInvocationFromRequest added in v0.60.0

func ToolInvocationFromRequest(request run.EffectRequest) (ToolInvocation, error)

func (ToolInvocation) EffectID

func (t ToolInvocation) EffectID() run.EffectID

func (ToolInvocation) Epoch added in v0.60.0

func (t ToolInvocation) Epoch() run.Epoch

func (ToolInvocation) IdempotencyKey added in v0.60.0

func (t ToolInvocation) IdempotencyKey() tool.IdempotencyKey

IdempotencyKey is the key the Tool receives in its Admission. Hosts use it to find the external record of a call whose outcome the runtime cannot know. It digests the call's Reference so a Tool forwarding it to a third party discloses no process path or step.

func (ToolInvocation) ProcessID added in v0.60.0

func (t ToolInvocation) ProcessID() run.ProcessID

func (ToolInvocation) ProgramRef added in v0.60.0

func (t ToolInvocation) ProgramRef() run.ProgramRef

func (ToolInvocation) Reference added in v0.60.0

func (t ToolInvocation) Reference() run.EffectID

Reference is the Effect that started the logical call.

func (ToolInvocation) ToolCall

func (t ToolInvocation) ToolCall() chat.ToolCall

func (ToolInvocation) Valid

func (t ToolInvocation) Valid() bool

type ToolOutcome added in v0.60.0

type ToolOutcome string

ToolOutcome classifies one committed tool call. Every projection of a tool settlement reads it rather than re-deriving it from the settlement's parts. The outcomes of a result the model received are its ResultDisposition.

func (ToolOutcome) Valid added in v0.60.0

func (t ToolOutcome) Valid() bool

type ToolSet added in v0.16.0

type ToolSet struct {
	// contains filtered or unexported fields
}

ToolSet freezes execution and admission policy once; the interaction's dispatcher composes it without introducing a child process lifecycle.

func NewToolSet added in v0.16.0

func NewToolSet(config ToolSetConfig) (ToolSet, error)

func (ToolSet) Configured added in v0.60.0

func (t ToolSet) Configured() bool

type ToolSetConfig added in v0.16.0

type ToolSetConfig struct {
	Revision      string
	Middlewares   []tool.CallMiddleware
	Tools         []tool.Tool
	DeferredTools []tool.Tool
}

type ToolSettlement

type ToolSettlement struct {
	Outcome  ToolOutcome      `json:"outcome"`
	Result   *chat.ToolResult `json:"result,omitzero"`
	Failure  string           `json:"failure,omitzero"`
	Evidence *tool.Output     `json:"evidence,omitzero"`
}

ToolSettlement is a detached projection of a committed tool Effect.

func ToolSettlementFromRecord added in v0.61.0

func ToolSettlementFromRecord(call chat.ToolCall, record run.EffectSettled) (ToolSettlement, error)

ToolSettlementFromRecord projects the committed settlement of call, including one the runtime left Unknown because Dispatch returned an error.

Jump to

Keyboard shortcuts

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