toolcallctx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolCallFromContext

func ToolCallFromContext(ctx context.Context) (provider.ToolCall, bool)

ToolCallFromContext extracts the provider.ToolCall from ctx.

func WithBatchOrder added in v0.1.2

func WithBatchOrder(ctx context.Context, order *BatchOrder) context.Context

WithBatchOrder attaches a batch's dispatch ledger to ctx.

func WithToolCall

func WithToolCall(ctx context.Context, call provider.ToolCall) context.Context

WithToolCall attaches a provider.ToolCall to ctx.

Types

type BatchOrder added in v0.1.2

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

BatchOrder is the per-turn dispatch ledger an agent loop publishes to the tools it runs. The dispatched set is the exact list of provider tool-call indices the loop hands to workers, fixed serially BEFORE any worker starts; Settle marks one index finished for ANY reason - the tool ran to completion, the call was rejected before the tools layer saw it, or the batch aborted before the call was claimed. The publishing loop guarantees every dispatched index settles exactly once, and that a call whose tool DID run settles only after the tool returned.

A tool that orders shared per-turn work by call index can therefore wait exactly: a dispatched, unsettled predecessor is either running or not yet scheduled - never a permanent hole - so no grace timer is needed to tell a scheduling gap from a skipped call.

func BatchOrderFromContext added in v0.1.2

func BatchOrderFromContext(ctx context.Context) (*BatchOrder, bool)

BatchOrderFromContext extracts the batch dispatch ledger from ctx.

func NewBatchOrder added in v0.1.2

func NewBatchOrder(dispatched []int) *BatchOrder

NewBatchOrder builds the ledger for one batch. dispatched is copied and sorted; indices absent from it are not part of the batch's contract.

func (*BatchOrder) Changed added in v0.1.2

func (b *BatchOrder) Changed() <-chan struct{}

Changed returns a channel that is closed on the next settlement after this call. Waiters re-fetch after each wake: the channel is swapped on every Settle, so one settlement wakes every current waiter exactly once.

func (*BatchOrder) Dispatched added in v0.1.2

func (b *BatchOrder) Dispatched() []int

Dispatched returns the sorted dispatched indices as a copy.

func (*BatchOrder) Settle added in v0.1.2

func (b *BatchOrder) Settle(index int)

Settle marks index finished. Idempotent; every call past the first for the same index is a no-op, so defer-based settlement composes with explicit abort-path settlement.

func (*BatchOrder) Settled added in v0.1.2

func (b *BatchOrder) Settled(index int) bool

Settled reports whether index has settled.

func (*BatchOrder) UnsettledBefore added in v0.1.2

func (b *BatchOrder) UnsettledBefore(limit int) bool

UnsettledBefore reports whether any dispatched index below limit has not settled yet.

Jump to

Keyboard shortcuts

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