Help us shape the future of Go! Take the 2026 Go Developer Survey

executor

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package executor is the hands' consumer: it pulls tool_exec work from the queue, runs the built-in toolset inside the session's sandbox, and appends the agent.tool_result events the brain resumes on. Platform-managed cloud and customer BYOC are the same pull protocol at two deployment points; this is the platform-managed one, embedding the Docker sandbox provider.

The loop mirrors the brain's: Claim the oldest tool_exec item (reclaiming an expired lease), do the work, hand the item back. The brain, when a turn stops for a built-in tool, commits the agent.tool_use intents and enqueues one tool_exec item; this executor answers every unanswered agent.tool_use for the session, then — once the set is complete — enqueues the model_turn that wakes the brain to continue. The result append, the resume enqueue, and the item's completion are one transaction under the session row lock, so a concurrent trigger never sees a gap.

At-most-once is the queue's lease, not a marker in the sandbox (which is agent-writable and disposable — see internal/sandbox/shell). A lease keeper holds the claim while tools run so two executors never run one session's tools at once; a crash mid-run lets the lease lapse, and the reclaiming executor re-runs only the still-unanswered tools — a committed result is never re-run, so a tool's result is exactly-once even though a non-idempotent command can run more than once across a crash. That residue is inherent to a disposable sandbox and is documented, not solved here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Image        string
	Workdir      string
	LeaseTTL     time.Duration
	PollInterval time.Duration
}

Config tunes the loop. Image is the sandbox base image (a deployment choice — the wire's environment config has no image field). LeaseTTL must comfortably exceed toolset.MaxTimeout: the lease keeper renews at TTL/3 while a tool runs, but the TTL is also the window a crashed executor's work waits before another reclaims it.

type Executor

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

Executor consumes tool_exec work over one Postgres pool and one sandbox provider.

func New

func New(pool *pgxpool.Pool, log *events.Log, q *queue.Queue, provider sandbox.Provider, cfg Config) *Executor

func (*Executor) Run

func (e *Executor) Run(ctx context.Context) error

Run polls until the context is cancelled. It claims one tool_exec item at a time; an error processing one item is logged by returning it up to the caller only for a fatal claim failure — a per-item fault is swallowed so the loop keeps serving other sessions, and the faulted item is reclaimed after its lease lapses.

Jump to

Keyboard shortcuts

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