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 ¶
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 ¶
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 ¶
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 ¶
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).
type JobRunner ¶
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.