interaction

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package interaction provides the model-directed execution Strategy for the Agent Framework.

A Definition owns the serializable working context, bounded model/Tool state machine, exact managed Delegate bindings, typed Delegate Artifacts, and an optional pure completion validator. A Dispatcher owns chatclient and ordinary executable Tool I/O. Delegate child Processes are requested only by the Execution through Framework Effects. Both components are bound into one agent Deployment; neither owns a Process lifecycle, product conversation history, persistence, an application artifact store, pricing, approval policy, or UI records. Direct model calls remain available through package chatclient without constructing an Interaction or Engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrToolAdvertisementUnavailable = errors.New("interaction: tool advertisement unavailable")
	ErrInvalidToolAdvertisement     = errors.New("interaction: invalid tool advertisement")
)
View Source
var (
	ErrInvalidDefinitionConfig = errors.New("interaction: invalid definition configuration")
	ErrInvalidDispatcherConfig = errors.New("interaction: invalid dispatcher configuration")
	ErrInvalidDelegate         = errors.New("interaction: invalid delegate")
	ErrInvalidArtifact         = errors.New("interaction: invalid artifact")
	ErrInvalidInput            = errors.New("interaction: invalid input")
	ErrInvalidExecutionState   = errors.New("interaction: invalid execution state")
)
View Source
var (
	ErrInvalidToolInputRequest = errors.New("interaction: invalid tool input request")
	ErrToolInputRequired       = errors.New("interaction: tool input required")
)
View Source
var ErrHostFailure = errors.New("interaction: host failure")
View Source
var ErrInvalidPendingToolInput = errors.New("interaction: invalid pending tool input")
View Source
var ErrInvalidSteer = errors.New("interaction: invalid steer")

Functions

func AdvertiseTools

func AdvertiseTools(ctx context.Context, names ...string) error

AdvertiseTools stages already-bound deferred Tools for model visibility from the next model call onward. The change commits only if the current Tool call succeeds. It never adds executable authority. Names must be exact deferred Tool names; repeated names are idempotent.

func DelegateChildKey

func DelegateChildKey(modelCallSequence uint32, toolCall chat.ToolCall) (agent.ChildKey, error)

DelegateChildKey derives the exact managed ChildKey used for one Delegate ToolCall. Consumers can use the same value to correlate model observation with the child Process without exposing ToolCall to the Kernel.

func HostFailure

func HostFailure(cause error) error

HostFailure marks cause as an Interaction-host failure. A nil cause remains nil, and an already marked error is returned unchanged.

func NewSteerSignal

func NewSteerSignal(id agent.SignalID, messages ...chat.Message) (agent.SignalRequest, error)

func NewToolInputResponseSignal

func NewToolInputResponseSignal(
	id agent.SignalID,
	waitID agent.WaitID,
	response json.RawMessage,
) (agent.SignalRequest, error)

func RequireToolInput

func RequireToolInput(
	prompt json.RawMessage,
	responseSchema json.RawMessage,
	continuationState json.RawMessage,
) error

RequireToolInput validates the request and returns an error matching ErrToolInputRequired. A Tool returns this before external side effects, or after storing enough ContinuationState to prove safe re-entry.

Types

type ActiveDelegateChild

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

ActiveDelegateChild is the immutable Interaction-owned attribution of one model ToolCall to its currently active managed child Process. It contains no Engine handle, persistence identity, or Host metadata.

func ActiveDelegateChildrenFromSnapshot

func ActiveDelegateChildrenFromSnapshot(
	snapshot agent.ProcessSnapshot,
) (children []ActiveDelegateChild, found bool, err error)

ActiveDelegateChildrenFromSnapshot interprets only Interaction-owned state. A valid snapshot without an active Interaction Delegate segment returns found=false. Returned children preserve model ToolCall order.

func (ActiveDelegateChild) ChildKey

func (a ActiveDelegateChild) ChildKey() agent.ChildKey

ChildKey returns the parent-scoped logical child identity.

func (ActiveDelegateChild) ModelCallSequence

func (a ActiveDelegateChild) ModelCallSequence() uint32

ModelCallSequence returns the one-based model call that requested the child.

func (ActiveDelegateChild) ProcessID

func (a ActiveDelegateChild) ProcessID() agent.ProcessID

ProcessID returns the Engine-minted child Process identity.

func (ActiveDelegateChild) ToolCall

func (a ActiveDelegateChild) ToolCall() chat.ToolCall

ToolCall returns the exact model ToolCall represented by the child.

func (ActiveDelegateChild) ToolCallIndex

func (a ActiveDelegateChild) ToolCallIndex() uint32

ToolCallIndex returns the zero-based ToolCall position in the model response.

func (ActiveDelegateChild) Valid

func (a ActiveDelegateChild) Valid() bool

type Artifact

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

Artifact is one successful, schema-validated Delegate output. It is identified by the exact Delegate binding, never by a Go runtime type name or an application artifact store.

func (Artifact) Decode

func (a Artifact) Decode[T any]() (T, error)

Decode strictly decodes a's output into T. The output was already validated against the exact Delegate Descriptor before the Artifact was admitted to Interaction state; T is only an edge convenience.

func (Artifact) DelegateName

func (a Artifact) DelegateName() string

DelegateName returns the exact model-facing Delegate name.

func (Artifact) Output

func (a Artifact) Output() agent.Output

Output returns the immutable, schema-validated child output.

type Artifacts

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

Artifacts is an immutable, ordered snapshot of successful Delegate outputs. All returns defensive copies, so a validator cannot mutate Execution state.

func (Artifacts) All

func (a Artifacts) All() []Artifact

All returns Artifacts in original model ToolCall order across model calls.

func (Artifacts) Len

func (a Artifacts) Len() int

Len returns the number of successful Delegate outputs accumulated so far.

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() Artifacts

Artifacts returns the immutable Delegate output snapshot.

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 permits completion with the proposed final semantic output.
	Accepted bool
	// Feedback explains a rejection to the model and is empty when accepted.
	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 CompletionSource

type CompletionSource string

CompletionSource identifies the semantic value that completed an Interaction. It is Strategy-owned and does not add a Framework lifecycle status.

const (
	// CompletionSourceModelResponse means the model produced a final response
	// without requesting another tool round.
	CompletionSourceModelResponse CompletionSource = "model_response"

	// CompletionSourceDirectToolResults means every call in one model-requested
	// batch targeted a DirectResultTool and returned successfully.
	CompletionSourceDirectToolResults CompletionSource = "direct_tool_results"
)

func (CompletionSource) Valid

func (c CompletionSource) Valid() bool

type CompletionValidator

type CompletionValidator func(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; MaxModelCalls remains the hard bound on retry rounds. Evaluation requiring external work belongs in a managed child Process, not this callback.

type ConcurrentTool

type ConcurrentTool interface {
	// ConcurrencyKey classifies one exact JSON argument document before any Tool
	// in the batch executes. concurrent=false requires exclusive execution;
	// concurrent=true with the same non-empty key serializes calls to that
	// resource. The method must be deterministic, bounded, side-effect-free, and
	// must not retain arguments.
	ConcurrencyKey(invocation tool.Invocation) (key string, concurrent bool)
}

ConcurrentTool is an optional Tool capability declaring which calls are safe to overlap within one model-requested batch. Tools without this capability, 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.

Returning concurrent=true also asserts that this invocation will not request external input through RequireToolInput. A parallel invocation that breaks that assertion makes the whole Tool Effect outcome unknown; the Dispatcher never re-executes siblings whose side effects may already have happened.

type Definition

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

Definition is an immutable managed model/Tool-loop definition. It contains no model client or executable Tool; those external capabilities belong to the Deployment-bound Dispatcher.

func NewDefinition

func NewDefinition(config DefinitionConfig) (*Definition, error)

func (*Definition) Descriptor

func (d *Definition) Descriptor() agent.Descriptor

Descriptor returns the immutable model-visible Definition contract.

func (*Definition) Restore

func (d *Definition) Restore(state agent.ExecutionState) (agent.Execution, error)

Restore recreates an Interaction solely from its opaque state.

func (*Definition) Start

func (d *Definition) Start(input agent.Input) (agent.Execution, error)

Start creates a fresh Interaction from validated caller input.

type DefinitionConfig

type DefinitionConfig struct {
	// Name is the stable qualified Definition name.
	Name string

	// Description states the managed behavior for discovery.
	Description string

	// MaxModelCalls bounds model Effects in one Interaction. It must be positive.
	MaxModelCalls uint32

	// Delegates is the frozen model-visible manifest of exact child
	// Deployments. Names must be unique within this slice and must not collide
	// with ordinary Tools bound by the Dispatcher.
	Delegates []Delegate

	// 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
	// the Deployment's ConfigurationDigest. Nil accepts every otherwise valid
	// completion.
	CompletionValidator CompletionValidator
}

DefinitionConfig describes immutable Interaction behavior. MaxModelCalls is required because a model-directed loop must have an explicit local stop condition in addition to Engine-wide Effect and Step limits.

type Delegate

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

Delegate is an immutable, model-visible binding to one exact managed child Deployment. 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)

func (Delegate) Valid

func (d Delegate) Valid() bool

type DelegateConfig

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

	// Description tells the model when and why to delegate this work.
	Description string

	// Deployment is the exact child behavior binding. The Delegate retains only
	// its immutable reference and Descriptor schemas.
	Deployment agent.Deployment

	// Budget is permanently allocated from the parent for each invocation.
	Budget agent.Budget

	// Capabilities is the attenuated authority set granted to each child.
	Capabilities agent.CapabilitySet
}

DelegateConfig exposes one exact child Deployment 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 declares whether a successful invocation can terminate
	// Interaction with the ToolResult itself. The answer is read and frozen at
	// Dispatcher construction and therefore 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 NewDispatcher; a panic or capability-resolution error rejects construction.

type Dispatcher

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

Dispatcher executes model calls and ordinary Tool segments emitted by an Interaction Execution. Its configuration is immutable after construction; internal observation health counters are concurrency-safe. It may serve Processes concurrently when the supplied Client and Tools support concurrent use.

func NewDispatcher

func NewDispatcher(definition *Definition, config DispatcherConfig) (*Dispatcher, error)

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(
	ctx context.Context,
	request agent.EffectRequest,
	emit agent.DeltaEmitter,
) (agent.Settlement, error)

Dispatch executes one validated Interaction protocol operation and returns a definite owner-defined Signal payload. An error means the external outcome is not provable; Engine therefore records an unknown settlement instead of retrying the operation.

func (*Dispatcher) ObservationFailures

func (d *Dispatcher) ObservationFailures() ObservationFailureCounts

ObservationFailures returns a concurrency-safe snapshot of ExecutionObserver panics isolated by this Dispatcher. The counts do not alter settlements.

func (*Dispatcher) ReplayPolicy

func (*Dispatcher) ReplayPolicy(effect agent.Effect) agent.ReplayPolicy

ReplayPolicy is deliberately conservative. Model calls may incur cost and produce a different answer, while Tools may have irreversible side effects; neither is replayed after a crash without an explicit Process resolution.

type DispatcherConfig

type DispatcherConfig struct {
	// Client provides complete and optional streaming model calls.
	Client ModelClient

	// Tools is the frozen ordinary model-visible and executable Tool manifest.
	// Managed Delegate definitions come from the bound Definition.
	Tools []tool.Tool

	// DeferredTools is the frozen ordinary executable Tool set omitted from the
	// initial model manifest. An executing Tool may make exact names visible on
	// later model calls through AdvertiseTools; authority never changes.
	DeferredTools []tool.Tool

	// MaxConcurrentToolCalls bounds calls that explicitly declare safe overlap.
	// Zero preserves serial execution; negative values are invalid. Undeclared
	// calls and calls with the same non-empty concurrency key remain serial.
	MaxConcurrentToolCalls int

	// StreamModelResponses selects Client.Stream and publishes each validated
	// response chunk as a best-effort ModelResponseDelta. False uses Client.Call.
	StreamModelResponses bool

	// Observer receives exact settled Interaction facts. It is intentionally
	// separate from Engine Events/Deltas: those describe execution mechanics,
	// while this boundary exposes typed model and Tool semantics.
	Observer ExecutionObserver

	// ModelContextReducer optionally replaces only the provider-neutral message
	// context at the last safe boundary before each model call. The Dispatcher
	// installs the effective messages back into Interaction recovery state when
	// the call settles, so later calls and checkpoints cannot regrow a reduced
	// context from the pre-reduction Effect payload.
	ModelContextReducer ModelContextReducer
}

DispatcherConfig binds external capabilities for one Deployment.

type ExecutionObserver

type ExecutionObserver interface {
	// OnModelResponse receives the complete provider-neutral response after the
	// model boundary settles and before later Interaction work is observed. The
	// response is detached and may be mutated by the observer. Panics are
	// isolated and the callback has no control authority.
	OnModelResponse(ctx context.Context, invocation ModelInvocation, response *chat.Response)
	// OnToolStarted marks the actual external Tool-call boundary; it is not
	// emitted for calls rejected before execution. Concurrently authorized Tool
	// calls may invoke this method in parallel.
	OnToolStarted(ctx context.Context, invocation ToolInvocation)
	// OnToolSettled receives exactly one conclusive or unknown host-boundary
	// outcome for a started Tool call. The ToolResult, when present, is detached;
	// the callback cannot alter the value committed to Interaction state.
	OnToolSettled(ctx context.Context, invocation ToolInvocation, settlement ToolSettlement)
}

ExecutionObserver receives exact, provider-neutral Interaction facts after model and Tool boundaries settle. It is observational: callbacks cannot alter execution, panics are isolated, and implementations must return in bounded time. A Dispatcher may invoke it concurrently for explicitly concurrent Tool calls.

type Input

type Input struct {
	// Messages is the initial provider-neutral WorkingContext.
	Messages []chat.Message `json:"messages"`

	// Options contains request-specific generation overrides.
	Options chat.Options `json:"options,omitzero"`
}

Input is the complete caller-supplied starting working context. Tools are deliberately absent: a Deployment freezes executable Tools in its Dispatcher so model-visible definitions and executable behavior cannot drift per Process.

func (Input) Validate

func (i Input) Validate() error

type ModelClient

type ModelClient interface {
	// Call invokes the configured model for one complete response.
	Call(ctx context.Context, request *chat.Request) (*chat.Response, error)
	// Stream invokes the configured model as a lazy response sequence.
	Stream(ctx context.Context, request *chat.Request) iter.Seq2[*chat.Response, error]
}

ModelClient stays consumer-owned so Interaction does not depend on one concrete Core client implementation.

type ModelContextReducer

type ModelContextReducer interface {
	// ReduceModelContext returns the complete messages for the attributed model
	// invocation. The result must be non-empty, valid, and independently owned.
	ReduceModelContext(
		ctx context.Context,
		invocation ModelInvocation,
		request *chat.Request,
	) ([]chat.Message, error)
}

ModelContextReducer owns an optional, provider-neutral reduction immediately before one actual model call. The request is an independently owned snapshot containing the exact Tool manifest and options that the model would receive; implementations may inspect it but return only the complete replacement message sequence, so they cannot change model options or Tool authority.

ReduceModelContext must return a definite outcome. A non-nil error means the main model was not called and is settled as a Host failure. Implementations that perform I/O must therefore resolve their own ambiguity before returning.

type ModelInvocation

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

ModelInvocation is the immutable execution attribution of one actual model call. It contains no Engine handle or Host metadata.

func ModelInvocationFromContext

func ModelInvocationFromContext(ctx context.Context) (ModelInvocation, bool)

ModelInvocationFromContext returns the attribution installed only for the duration of an Interaction model call.

func (ModelInvocation) AppliedSteerSignalIDs

func (m ModelInvocation) AppliedSteerSignalIDs() []agent.SignalID

AppliedSteerSignalIDs returns the ordered identities of steer Signals whose messages were first made visible to this exact model request. The returned slice is independently owned. An empty slice means the request applied no new steer input; previously applied messages may still remain in WorkingContext.

func (ModelInvocation) DeploymentRef

func (m ModelInvocation) DeploymentRef() agent.DeploymentRef

DeploymentRef returns the exact Interaction binding that owns the model call.

func (ModelInvocation) EffectID

func (m ModelInvocation) EffectID() agent.EffectID

EffectID returns the stable model Effect identity.

func (ModelInvocation) ModelCallSequence

func (m ModelInvocation) ModelCallSequence() uint32

ModelCallSequence returns the one-based model call position in this Interaction.

func (ModelInvocation) Relation

func (m ModelInvocation) Relation() agent.ProcessRelation

Relation returns the Process tree location that owns the model call.

func (ModelInvocation) StepSequence

func (m ModelInvocation) StepSequence() uint64

StepSequence returns the one-based Process Step that declared the model Effect.

func (ModelInvocation) Valid

func (m ModelInvocation) 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)

ParseModelResponseDelta strictly decodes an Interaction model Delta payload.

func (ModelResponseDelta) Response

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

Response returns an independently owned response chunk.

type ObservationFailureCounts

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

ObservationFailureCounts is an immutable snapshot of ExecutionObserver panics isolated by one Dispatcher. Counts are monotonic and saturate at math.MaxUint64.

func (ObservationFailureCounts) ModelResponsePanics

func (c ObservationFailureCounts) ModelResponsePanics() uint64

func (ObservationFailureCounts) ToolSettledPanics

func (c ObservationFailureCounts) ToolSettledPanics() uint64

func (ObservationFailureCounts) ToolStartedPanics

func (c ObservationFailureCounts) ToolStartedPanics() uint64

type Output

type Output struct {
	// Source identifies which mutually exclusive result field is authoritative.
	Source CompletionSource `json:"source"`

	// ModelResponse is the authoritative accumulated response when Source is
	// CompletionSourceModelResponse.
	ModelResponse *chat.Response `json:"model_response,omitempty"`

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

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

Output is the final semantic Interaction result. Response is accumulated independently of best-effort stream Delta delivery, so it remains complete after observer loss or snapshot restoration.

func (Output) Validate

func (o Output) Validate() error

type PendingToolInput

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

PendingToolInput is the consumer-facing view of one current Tool input wait. It deliberately excludes Tool continuation state and all application UI, persistence, approval, or actor concepts.

func PendingToolInputFromProcess

func PendingToolInputFromProcess(
	ctx context.Context,
	process *agent.Process,
) (PendingToolInput, bool, error)

PendingToolInputFromProcess captures process and interprets its committed state only when it is an Interaction currently waiting for Tool input.

func PendingToolInputFromSnapshot

func PendingToolInputFromSnapshot(snapshot agent.ProcessSnapshot) (PendingToolInput, bool, error)

PendingToolInputFromSnapshot interprets only Interaction-owned state. A valid non-Waiting or non-Interaction snapshot returns found=false.

func (PendingToolInput) Prompt

func (p PendingToolInput) Prompt() json.RawMessage

Prompt returns an independently owned Tool-defined JSON prompt.

func (PendingToolInput) ResponseSchema

func (p PendingToolInput) ResponseSchema() json.RawMessage

ResponseSchema returns the authoritative JSON Schema for a response.

func (PendingToolInput) ResponseSignal

func (p PendingToolInput) ResponseSignal(
	id agent.SignalID,
	response json.RawMessage,
) (agent.SignalRequest, error)

ResponseSignal validates response locally against ResponseSchema and returns one WaitID-addressed SignalRequest with caller-supplied deduplication ID.

func (PendingToolInput) Valid

func (p PendingToolInput) Valid() bool

func (PendingToolInput) WaitID

func (p PendingToolInput) WaitID() agent.WaitID

WaitID returns the Engine-minted identity required to address the response.

type ToolInputContinuation

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

ToolInputContinuation is the immutable state and validated external response attached only while re-entering the Tool that requested input.

func ToolInputContinuationFromContext

func ToolInputContinuationFromContext(ctx context.Context) (ToolInputContinuation, bool)

ToolInputContinuationFromContext returns continuation data only for the active resumed Tool call. Ordinary first attempts return false.

func (ToolInputContinuation) Response

func (t ToolInputContinuation) Response() json.RawMessage

Response returns the schema-validated external input.

func (ToolInputContinuation) State

State returns the Tool-owned continuation state captured at suspension.

type ToolInputRequest

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

ToolInputRequest is an immutable Tool request for external input. Prompt is an owner-defined JSON value for a consumer, ResponseSchema is authoritative, and ContinuationState is returned only to the same Tool when input arrives. It contains no Process identity or WaitID; Engine owns those identities.

func NewToolInputRequest

func NewToolInputRequest(
	prompt json.RawMessage,
	responseSchema json.RawMessage,
	continuationState json.RawMessage,
) (ToolInputRequest, error)

func (ToolInputRequest) ContinuationState

func (t ToolInputRequest) ContinuationState() json.RawMessage

ContinuationState returns opaque state owned by the requesting Tool.

func (ToolInputRequest) Prompt

func (t ToolInputRequest) Prompt() json.RawMessage

Prompt returns an independently owned consumer-facing JSON value.

func (ToolInputRequest) ResponseSchema

func (t ToolInputRequest) ResponseSchema() json.RawMessage

ResponseSchema returns the authoritative JSON Schema for an answer.

func (ToolInputRequest) Valid

func (t ToolInputRequest) Valid() bool

type ToolInputRequiredError

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

ToolInputRequiredError carries one validated, snapshot-safe ToolInputRequest across a Tool boundary. It is control flow, not a failed ToolResult.

func (*ToolInputRequiredError) Error

func (t *ToolInputRequiredError) Error() string

func (*ToolInputRequiredError) Unwrap

func (*ToolInputRequiredError) Unwrap() error

type ToolInvocation

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

ToolInvocation is the immutable execution attribution of one actual Tool call. ToolCall is the exact model request being executed.

func ToolInvocationFromContext

func ToolInvocationFromContext(ctx context.Context) (ToolInvocation, bool)

ToolInvocationFromContext returns the attribution installed only for the duration of the exact Interaction Tool call.

func (ToolInvocation) DeploymentRef

func (t ToolInvocation) DeploymentRef() agent.DeploymentRef

DeploymentRef returns the exact Interaction binding that owns the Tool call.

func (ToolInvocation) EffectID

func (t ToolInvocation) EffectID() agent.EffectID

EffectID returns the stable Tool-batch Effect identity.

func (ToolInvocation) ModelCallSequence

func (t ToolInvocation) ModelCallSequence() uint32

ModelCallSequence returns the one-based model call that requested the Tool.

func (ToolInvocation) ModelResult

func (t ToolInvocation) ModelResult(output chat.ToolOutput, cause error) (result chat.ToolResult, present bool)

ModelResult maps the executable Tool's Go return values onto the exact provider-neutral ToolResult consumed by Interaction. present=false means the cause belongs to the host or control plane and must not enter model context.

func (ToolInvocation) Relation

func (t ToolInvocation) Relation() agent.ProcessRelation

Relation returns the Process tree location that owns the Tool call.

func (ToolInvocation) StepSequence

func (t ToolInvocation) StepSequence() uint64

StepSequence returns the one-based Process Step that declared the Tool batch.

func (ToolInvocation) ToolCall

func (t ToolInvocation) ToolCall() chat.ToolCall

ToolCall returns the exact model ToolCall value being executed.

func (ToolInvocation) ToolCallIndex

func (t ToolInvocation) ToolCallIndex() uint32

ToolCallIndex returns the zero-based ToolCall position in the model response.

func (ToolInvocation) Valid

func (t ToolInvocation) Valid() bool

type ToolSettlement

type ToolSettlement struct {
	// Result is the exact ordinary Tool result fed back to the model.
	Result *chat.ToolResult
	// InputRequired reports that the Tool paused before producing Result.
	InputRequired bool
	// Failure describes a host or cancellation failure that produced no Result.
	Failure string
	// Unknown reports that the external Tool settlement could not be determined.
	Unknown bool
}

ToolSettlement is the conclusive outcome visible at the Tool host boundary. Result is the exact value fed back to the model. InputRequired instead means the Tool paused durably before producing a result. Failure is reserved for a host/cancellation failure for which no ordinary ToolResult was produced.

Jump to

Keyboard shortcuts

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