#Jig Agent Run invocation
Status: experimental alpha candidate.
Agent Run is one exact FLOW Invocation Contract consumed through Run/0
flow/call. A caller supplies explicit instructions, Skill contents and optional
guidance. The shared Agent method prepares the prompt
and interprets the response in an ordinary Flow. Jig provides the granted
HTTP or finite native transport, not the Agent's method. This adds no special
Agent invocation API to @jigging/flow.
The canonical descriptor is
agent-run/contract.json:
An Agent-using Flow includes an exact package-local copy of those descriptor
bytes and the referenced contracts/acp-public-updates.json descriptor. The
latter defines optional public updates. The bundle also includes direct
agent-commands.json and agent-replies.json channel contracts for conversational
use. Copy the complete
agent-run/ bundle, preserving its descriptor-relative contracts/ directory.
Declare the slot in a code Flow's optional FLOW.meta.json:
The slot name agent is local to this package. Like any ordinary dependency,
it resolves through an exact Binding route or project default. Contract URIs
are not fetched at runtime. The selected method uses its own independently
reviewed resource grants; a matching descriptor grants no authority.
#Declare required Agent behavior
The descriptor's features catalog names optional mechanisms. Implementations
claim the mechanisms they implement through package metadata supports;
consumers require them through uses.<slot>.requires. These use the ordinary
FLOW feature qualification
rules and the same exact contract identity as the call.
The HTTP package declares supports: []. The ACP package declares
supports: ["events", "conversation", "sessions"]. These are unconditional
claims about the method across its accepted package settings. A setting cannot
deliberately remove an advertised mechanism while leaving its claim true.
Static matching checks those declarations, not implementation honesty. Separate
resource grants, native profiles and runtime failures may still refuse work.
Matching grants no authority and never converts package output into host evidence.
A caller whose method needs continuing control declares:
Jig checks required names after exact contract matching and makes a mismatching
target unavailable before its caller starts. An explicit selection never falls
back automatically. A caller with no extra requirements needs no requires
field; it retains ordinary input, channel and runtime refusal semantics.
Conditional features may remain runtime decisions with authored recovery;
review cannot infer those branches or arbitrary wrappers' resource use.
Requiring conversation does not promise permission for a follow-up: a grant
with maxTurns: 1 permits only the initial prompt. Requiring sessions does not
grant retainSessions or promise a retained successor. Inspect final receipts
before restoring; unavailable retention and execution failure remain distinct.
Require events when the complete method supplies that optional port; after
accepted support, observer failure remains separate from essential execution.
Keep every participant's complete descriptor bundle synchronized. Catalog changes change the exact invocation digest even for callers with no feature requirements; refresh their bundle and use ordinary review/admission. Call syntax is unchanged.
#Calling the Agent
The optional events send channel carries the exact
ACP public updates profile through supported
native clients, with direct or isolated-broadcast delivery. It adds no session
control and does not replace the final result. API clients remain one-shot;
requested unsupported channels reject before dispatch. See channels
for ownership, buffering and installed output.
The contract has one invocation, with no method selector. Its input is:
Its result is:
On the Run/0 wire and in the SDK, run.call() returns that complete result.
An Agent blocked or limit outcome is ordinary domain data, not an execution
error. A done call requesting responseSchema includes output.structured.
The consumer must check it against the requested schema before using it. The pure
checkAgentResult(result, responseSchema) helper supplies this check without
dispatch or authority.
Jig validates the static invocation contract for every implementation. The supplied ordinary methods also check the dynamic schema. A consumer still checks independently when accepting a replacement.
The supplied methods preserve refusal and limit text even when it is not valid
JSON or does not match the requested schema. They include output.structured
only when the value matches. A valid structured value does not change a
blocked or limit outcome to done. Completed structured answers must decode
and match. Cancellation, host deadlines and operational failures remain errors.
checkAgentResult rejects any supplied structured value that does not match
the requested schema, including on a blocked or limited result.
An ordinary Flow offering the exact descriptor can replace the Agent through a project default or explicit Binding route. Its own grants supply its powers. Matching a descriptor grants neither credentials nor network access. Supported optional channels still require qualification by the selected implementation.
The optional session input requests native retention or restoration under a
separately reviewed grant. Its receipt appears only in the final invocation
output, after resource settlement. Calls without a request omit it. The supplied
HTTP method rejects a session request before dispatch. See
retaining a native conversation.
#Continuing conversations
One-shot calls keep the input and result above. A conversational call adds
conversation: true and supplies both direct channels: commands (the Agent
receives) and replies (the Agent sends). Other pairings reject before native
dispatch. The supplied HTTP method does not support this mode and rejects it
before HTTP dispatch. A conversational native Binding grants maxTurns from
1 through 8; omission permits only one turn. One finite Agent invocation owns
the complete conversation, with unchanged root lifetime and aggregate limits.
Initial input starts turn 0. Later controls are ordinary channel values:
prompt requires the next sequential turn and no running turn. Its input is
the ordinary instructions, optional guidance and responseSchema; initial Skills
remain in the native conversation, not newly selected by a follow-up. interrupt
names the running turn. close requires the last settled turn. Controls are
not queued or replayed: busy, stale, duplicate interruption, exhausted allowance
and invalid prompt input receive a correlated rejected reply with a closed
code. A malformed channel value is an operation failure.
An invocation accepts at most 64 controls, including rejected controls; exceeding
that bound fails it. The prompt allowance is separately enforced by the host.
An accepted reply names command and turn; it acknowledges the control,
not native completion. Each turn separately produces one of:
{type:"result", turn, result}with a complete ordinary Agent Run result;{type:"cancelled", turn}after native cancellation settlement; or{type:"error", turn, code:"INVALID_RESULT", message}when a completed answer cannot satisfy the requested structured result. A caller may issue another turn after that error. Malformed ACP or uncertain native work is fatal instead.
Per-turn results contain the answer's text and optional structured value,
never a session receipt. Only the initial invocation input may request
retention or restoration; follow-up prompt inputs cannot change that request.
Replies are essential and fit the ordinary 64 KiB channel item bound. Oversized
results fail visibly rather than truncate. A reply blocked for five seconds
fails the conversation and settles its resource. Command EOF without an accepted
close fails; closing the command stream does not imply successful execution.
After sending close, the caller seals its command writer before awaiting the
invocation. The Agent waits at most five seconds for that clean EOF before
releasing its receiver; further controls after accepted close are invalid.
On accepted close, the invocation returns {outcome:"done",output:{turns:N}}
only after native cleanup. N counts all settled turns, including cancelled or
invalid answers; conversation completion does not imply every turn succeeded.
When the initial input requests a session, this final output also contains
the retention receipt defined below.
Optional public events add turn in conversational mode. They remain lossy
observation, never the source of turn-result or interruption acknowledgement.
Late native text/plan updates outside an active turn fail. Within a turn, native
ordering depends on the qualified client's ACP compliance; local turn labels
are not independent proof of native causality. All turn text and frame limits
remain cumulative across the invocation.
The live conversation stays within one invocation. Cross-Run restoration uses the explicit session request below. Candidate failover stays within reviewed slots and recovery policy and never grants native workspace tools.
#Retaining a native conversation
The optional session field is exactly one of {retain:true},
{retain:true,lifetime:"run"}, or
{restore:reference}, where reference is an opaque, canonical lowercase
36-character UUID returned by a previous
final invocation. The request applies to one-shot and conversational native
calls. Omission keeps the invocation ephemeral. Retention is a separately
reviewed native grant, retainSessions:true; a request or a reference never
grants this authority.
retain starts a new conversation and requests retention when it closes.
Omitting lifetime permits later authorized Runs to restore it. lifetime:"run"
restricts every reference in the chain to the current root Run, for temporary
work such as one evidence-driven repair correction. This lifetime spans child
and native-call settlement; it is not the lifetime of the individual Agent call.
restore consumes previously retained native state before starting the current
prompt, then requests a successor snapshot after this invocation settles.
It inherits the original lifetime; supplying a lifetime on restore is invalid.
Run-scoped state is inaccessible after the root ends and is deleted atomically
with its authoritative terminal, including cancellation and recovered termination.
Failed storage cleanup prevents terminal completion and must remain visible.
The current instructions, Skills and guidance supply the new prompt. The host
restores the native conversation; the Agent Flow relays metadata and does not
read native storage, replay a transcript or synthesize an earlier answer.
Only the final invocation output carries one of these closed receipts:
retained means that the final turn settled, the native client actually exited
cleanly, all owned execution was fenced, and bounded validated state was
collected, cleaned up and committed atomically. Accepted ACP close, a completed
answer, channel EOF or controlled termination alone cannot establish retention.
A successfully settled answer may therefore include an unavailable session receipt;
the answer remains valid under its ordinary result checks. An invocation error
does not return a usable successor reference.
The required reason distinguishes ineligible native exit, absent rollout,
unsupported collected history and exhausted retention capacity. It is not a
raw native error or information about another recipient's reference. Unexpected
collection, storage and cleanup failures remain errors; the exact host behavior
is defined in Finite ACP.
Restoration requires the current grant, protected project, admitted recipient and
ancestry, and compatible native identity across client, adapter, and executable.
Qualified Codex bindings share scope across compatible authProfile and
model slots. Changing the accepted package, client, or executable invalidates
access to an earlier snapshot. A reference is identity, never permission.
The host claims a reference once before native startup. If native setup fails
before session/resume is accepted, the host releases the claim so a compatible
backup candidate can restore it. Once restoration is accepted, the old reference
is spent. Failover under sameClientSession: "fresh" runs a backup without
history and reports unsupported-history. Default
sameClientSession: "resume-if-qualified" never drops { restore } to a fresh
conversation. A { retain: true } failover to a slot without retention also
reports unsupported-history.
The initial host profile permits at most 16 available snapshots per project, each at most 8 MiB. References expire logically after 24 hours; expired state is pruned on the next store access, without promising automatic secure erasure. Active execution ownership outlives snapshot expiry. Credentials, native tools and arbitrary workspaces are outside retained state. Exact collection and restore requirements belong to Finite ACP.
This is the synchronized source candidate contract. Installed-client save-and-restore qualification and publication of matching artifacts are separate requirements; the descriptor alone establishes neither.
#Structured-output profile
responseSchema is private call input describing the requested Agent reply,
not a Jig project declaration or the Flow's complete public result contract.
A small one-call schema may be inline or a local constant; substantial or reused
schemas may live in ordinary descriptive package-local files. Placement creates
no required filename, directory or FLOW.response.json declaration and does not
change validation or the profile below. Optional managed @agentResponse
projections follow contract authoring ownership and
explicit generation. Shared models require genuinely shared constraints;
public and Agent schemas remain distinct when their profiles differ.
The alpha accepts one bounded recursive structured-output profile. Its root is
a nonempty closed object with the FLOW Schema/0 $schema identifier. Every
object:
- has
type: "object", 1–32 properties, andadditionalProperties: false; - lists every property exactly once in
required, so optional fields are not part of this profile; and - contains only values from this same recursive profile.
Values may be:
- another closed object;
- a homogeneous array with one
itemsschema and a required integermaxItemsfrom 0 through 256;minItemsmay additionally bound the lower end; - a string, optionally restricted by a nonempty string
enum; - a JSON/0 safe integer; or
- a nullable string or safe integer, expressed by including
"null"in itstypearray.
A nullable string enum includes null and at least one string in enum;
otherwise its type declaration and allowed values would disagree.
The canonical JSON/0 schema is limited to 256 KiB, eight schema levels including the root, 128
properties across all objects, and 256 enum members across all string enums.
Property names and enum strings together may contain at most 120,000 Unicode
characters; an enum with more than 250 members has a 15,000-character limit.
Descriptions may guide the provider but grant no authority. References,
definitions, applicators such as anyOf, free-form maps, optional properties,
booleans, non-integer numbers, and nullable objects or arrays are outside this
profile. Use an unstructured call for other result shapes. Unsupported schemas
fail before provider dispatch rather than being translated approximately.
operationId has the ordinary Run/0 meaning: use one stable identity for one
logical call. Reusing it with changed slot, input, intent, or channel mappings conflicts. Work
which may have been dispatched is fenced and reported honestly; Jig does not
silently send it again. Cancellation fences Jig's local provider worker, but
cannot retract a request which the remote provider has already accepted.
#Package-local skills
Each selected skill is an immediate package-local directory:
The caller reads the selected files and passes their complete contents in
skills; names are not requests for the host to open files. The optional
readPackageSkills(packageRoot, names) library reader performs bounded reads
of explicit trees from the caller's package. Under Jig these are the caller's
captured source files. A caller may also supply constructed text: names and
paths describe that data, not independently host-attested provenance.
Skill names and file paths must be unique; every Skill contains SKILL.md.
The shared method sorts them by UTF-8 bytes. Skill files must be UTF-8 text.
Skills and guidance share 64 groups, 1,024 files/text items, and 1 MiB of
content including instructions. The rendered provider input has its own
1 MiB bound. Omission or [] supplies no Skills. Content grants no Flow,
filesystem, network, tool, or host authority.
SKILL.md and its supporting files are plain UTF-8 guidance. Jig does not
require frontmatter or define another skill metadata grammar.
#Exact ticket router
This Flow asks the Agent for one value from a closed enum, then calls the matching exact Binding-local child slot:
The corresponding Binding fixes the only two children the Flow can call:
The model returns data, not authority. The response schema limits its answer
to billing or technical, and Jig resolves that name only through the
Binding's exact same-generation slots. Either child may use Agent Run itself.
A slot may instead name binding:<id> to invoke a specialist with that
Binding's own admitted settings and slots, within the bounded call tree below.
Parent settings, slots, and native authority are never inherited implicitly.
Each specialist selects Skills from its own admitted package for each Agent call. A fresh call does not include the parent's or another specialist's conversation unless the application explicitly passes that content as input. Native restoration can access only the current recipient's authorized snapshot; it does not inherit another specialist's conversation. The operator selects the implementation and its grants. The caller does not inherit the selected implementation's credentials or source files.
The root allows up to two sibling Flow calls or one exclusive effect; a child allows one active Flow or effect, within the branch depth allowed by the aggregate reservation budget. The root reserves each branch's resources before dispatch, including its effect capacity. Parent cancellation and the inherited deadline govern the child and its Agent worker; cleanup must settle both before the parent result becomes terminal. As with root Agent calls, cancelling local work cannot retract an already accepted remote request.
Exactly one child is a property of this example's completed path, not a new host rule. A blocked or limited Agent result reaches no child, and another Flow may make sequential calls or two parallel sibling calls within its admitted slots.
#Replaceable implementations
Two ordinary packages offer the same Agent Run contract:
@jigging/agent-methodprepares nonstreaming Chat Completions or Responses requests through an exact HTTP grant.@jigging/agent-acpdrives the finite ACP dialogue through an exact native resource grant, including optional public updates.
A default provider or explicit Binding route selects the package. Both execute as ordinary keyless, network-isolated Flows; their granted resources hold credentials and enforce dispatch and lifetime. Jig does not implement a hidden Agent method or fall back to another provider.
The HTTP package's settings choose its model, token cap, API format and strict
schema preference. The native package follows the resource's reviewed client
configuration. Settings guide method behavior; authority comes from the grant.
An operator requiring HTTP body restrictions against modified method code
uses the grant's bodySchema.
See Choose an Agent for configuration and Finite ACP for native installation, authentication and containment limits. Review does not perform a remote health check. A ready local plan does not assert model availability or quality.