oneshot

package
v0.221.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oneshot is the one way gofer asks a model a single, read-only question: a one-shot, tool-less, single-turn agent job whose answer is a document the server parses. The delivery check is its first user; later decision points use the same invoker so every such call has the same guards.

The package sits beside bgagent in the layering: it imports the data layer, bgagent (hard stops, run log, audit) and the agent registry, and never the job service. The job layer is reached through the JobRunner seam, which the job package implements (the job package imports oneshot, never the reverse, G022 / G024).

Index

Constants

View Source
const (
	// KindJobCheck is the delivery check (交付核验).
	KindJobCheck = bgagent.KindJobCheck
)

The kinds of one-shot call. A kind is the unit of the daily limit and of the run log.

Variables

View Source
var ErrOutputInvalid = errors.New("one-shot output does not match the expected schema")

ErrOutputInvalid is wrapped by the error Run returns when the answer does not satisfy Request.OutputSchema.

Functions

func NoToolsArgs

func NoToolsArgs(agents *agent.Registry, agentKey string, operatorArgs []string) ([]string, error)

NoToolsArgs is the operator's args for the agent followed by the tool-less argv the server forces for the agent type. An agent type without a known no-tools argv is refused, so a one-shot never runs with tools by omission.

Types

type Invoker

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

Invoker runs one-shot calls.

func NewInvoker

func NewInvoker(bg *bgagent.Runner, jobs JobRunner, agents *agent.Registry) *Invoker

NewInvoker builds an Invoker over the background-agent runner (guards, run log, audit), the job seam and the agent registry (it resolves an agent's no-tools argv).

func (*Invoker) Run

func (i *Invoker) Run(ctx context.Context, req Request) (Result, error)

Run guards the kind's hard stops (a trip is a *bgagent.HardStopError and is audited), runs one read-only job, records the run and validates the answer.

type JobOutput

type JobOutput struct {
	JobID     string
	SessionID string
	Output    []byte
	Usage     *runner.Usage
}

JobOutput is the answer of one job.

type JobRunner

type JobRunner interface {
	RunReadOnly(ctx context.Context, spec JobSpec) (JobOutput, error)
}

JobRunner is the seam to the job service: run one read-only job and return its stdout.

type JobSpec

type JobSpec struct {
	Kind        string
	Project     string
	Agent       string
	Model       string
	Prompt      string
	Args        []string
	Title       string
	SourceJobID string
	Origin      string
	Timeout     time.Duration
}

JobSpec is what the JobRunner is asked to run: one read-only, tool-less job. It carries only text and routing; the runner fixes the safety shape.

type Request

type Request struct {
	Kind    string
	Project string
	Agent   string
	Model   string
	// Prompt is the full instruction. Input, when set, is appended to it as indented
	// JSON (the structured evidence the model judges).
	Prompt string
	Input  any
	// OutputSchema validates the model's answer; nil accepts any output. A failure is
	// returned wrapping ErrOutputInvalid (the run itself still counts against the limits).
	OutputSchema func(output []byte) error
	// Args must be built with NoToolsArgs (the operator's args followed by the forced
	// tool-less argv); Run refuses a request whose Args do not end with it.
	Args        []string
	Title       string
	SourceJobID string
	Origin      string
	// Limits are the hard stops of the kind (daily runs / cost / tokens, timeout); the
	// counters live in background_agent_runs, so they survive a restart.
	Limits bgagent.Limits
}

Request is one one-shot call.

type Result

type Result struct {
	Output    []byte
	JobID     string
	SessionID string
	Usage     *runner.Usage
}

Result is the answer of one call.

Jump to

Keyboard shortcuts

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