projection

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithState

func WithState(ctx context.Context) context.Context

WithState ensures a mutable ProjectionState exists in context.

Types

type ContextProjection

type ContextProjection struct {
	// Scope mirrors Agent.Tool.CallExposure ("turn" | "conversation").
	Scope string
	// HiddenTurnIDs lists turns hidden from active prompt history.
	HiddenTurnIDs []string
	// HiddenMessageIDs lists message-level prompt suppressions, including
	// superseded tool-call results and turn-expanded hides.
	HiddenMessageIDs []string
	// Reason is a short human-readable explanation for observability.
	Reason string
	// TokensFreed is an approximate count of tokens removed by projection.
	TokensFreed int
}

ContextProjection carries model-facing prompt projection decisions for the current request. It does not mutate transcript truth; it only records what should be hidden from the active prompt build.

func SnapshotFromContext

func SnapshotFromContext(ctx context.Context) (ContextProjection, bool)

SnapshotFromContext returns a copy of the current projection value.

type ProjectionState

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

ProjectionState is a mutable request-scoped holder for ContextProjection. Callers should update it during decision phases and consume a Snapshot() during prompt-history construction.

func StateFromContext

func StateFromContext(ctx context.Context) (*ProjectionState, bool)

StateFromContext returns the mutable state holder when present.

func (*ProjectionState) AddReason

func (s *ProjectionState) AddReason(reason string)

AddReason appends a distinct reason segment for observability.

func (*ProjectionState) AddTokensFreed

func (s *ProjectionState) AddTokensFreed(tokens int)

AddTokensFreed accumulates projected token savings.

func (*ProjectionState) HideMessages

func (s *ProjectionState) HideMessages(messageIDs ...string)

HideMessages adds message IDs to the hidden set, preserving insertion order.

func (*ProjectionState) HideTurns

func (s *ProjectionState) HideTurns(turnIDs ...string)

HideTurns adds turn IDs to the hidden set, preserving insertion order.

func (*ProjectionState) SetReason

func (s *ProjectionState) SetReason(reason string)

SetReason replaces the reason string when non-empty.

func (*ProjectionState) SetScope

func (s *ProjectionState) SetScope(scope string)

SetScope sets the projection scope.

func (*ProjectionState) Snapshot

func (s *ProjectionState) Snapshot() ContextProjection

Snapshot returns a stable copy of the current projection value.

Jump to

Keyboard shortcuts

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