For AI agents: the complete documentation index is available at https://jig.md/llms.txt, the full documentation bundle is available at https://jig.md/llms-full.txt, and this page is available as Markdown at https://jig.md/build/agent-method.md.
DocumentationGuidePrerelease

#Reuse the Agent method

View Markdown

Ask your project's Agent for one answer. Call the same method from a Flow. The operator chooses the Agent, credentials, and permissions. Your caller supplies the task.

#Before you start

Use a project with an approved binding:agent. Follow Agent setup if you need to configure it.

#Invoke the ordinary Flow

From the project root:

jig run binding:agent --input '{"instructions":"Explain a useful way to check an assumption."}'

Read execution status first, then the method's outcome:

OutcomeMeaning
doneAn answer is available in output.text. Check whether it is useful and correct.
blockedThe Agent could not provide the requested answer. Read its explanation.
limitThe method reached its limit. Inspect the returned text before choosing further work.

A successful command does not prove a correct answer. Operational failures remain execution errors. Nothing is retried automatically. Results explains host status, delivery, and cleanup.

#Call the Agent from your own Flow

Create a caller using the installed Agent Run agreement:

jig new specialist --use agent=jig:agent-run

This copies the contract and declares the caller's agent slot. It does not select an Agent or grant permissions. If jig.ts uses explicit membership, add flows/specialist to its flows list.

Replace flows/specialist/FLOW.ts:

import { handle } from '@jigging/flow'

await handle(run => {
  if (typeof run.input !== 'string') throw new TypeError('Supply a string.')
  return run.call({
    operationId: 'answer',
    slot: 'agent',
    input: { instructions: run.input },
  })
})

The project's configured Agent route supplies the implementation for this slot. The caller receives the method's ordinary outcome and output. Review the caller before running it:

jig review --allow-resolution-network
jig run flow:flows/specialist --input '"Explain a useful way to check an assumption."'

The starter's SDK dependency may need fresh resolution when its lock is missing. That permission can contact dependency-selected destinations before approval. Read dependency preparation before granting it. Inspect the source and proposed authority before approving execution.

Expect the same outcome and output shape as the direct invocation. The answer's wording can differ. Try another question without changing the source. Review again if you change the caller or its Agent selection.

Your application owns factual checks and decisions based on the answer.

For failed requests, see Agent execution troubleshooting.

#Input reference

Supply instructions, with optional context or a result schema:

{
  instructions: string;
  guidance?: readonly { label: string; text: string }[];
  responseSchema?: JsonObject;
  skills?: readonly { name: string; files: readonly { path: string; text: string }[] }[];
}

guidance preserves order and needs unique nonempty labels. Each selected Skill includes its complete UTF-8 files and exact-case SKILL.md. Omission supplies no Skills. Skill names and guidance labels use separate namespaces.

The public readPackageSkills helper reads explicit trees from the caller's own captured package. Supplied labels, paths, and text describe context. They do not authenticate its origin or grant powers. Selected Skills and files use canonical sorting.

Duplicates and invalid UTF-8 reject.

#Request a structured answer

Set responseSchema when the application needs a checked shape. Keep a small one-call schema inline or beside its call. Use an ordinary adjacent descriptive file for a substantial or reused schema, such as charge-assessment.schema.json. The Agent reply schema and the Flow's complete result contract serve different purposes.

No schemas directory or FLOW.response.json declaration is required. Dynamic values, such as an enum of eligible routes, remain ordinary code. A schema import does not authorize a cross-Flow dependency.

Retain the explicit dialect and supported schema profile. A done structured answer includes locally validated output.structured. Application code still checks its truth and meaning. For a replacement Agent implementation, use checkAgentResult(result, responseSchema) to check the complete result independently.

The supplied methods retain text for blocked and limit and include structured only when it matches the requested schema. Matching data never changes either outcome to done. checkAgentResult accepts these outcomes without structured data. It still rejects malformed results and any supplied structured value that does not match.

Optional managed response generation helps interfaces that actually share constraints. Keep distinct shapes separate when their constraints differ. Change generated files through their source declaration and explicit regeneration. Placement advice does not permit removing or moving tool-owned outputs.

#Choose the entrypoint

The ordinary HTTP and native ACP packages provide the same Agent Run interface.

ImplementationUse
Ordinary HTTP FlowCall a reviewed Chat Completions or Responses endpoint.
Ordinary ACP FlowUse a reviewed native client.
Pure TypeScript libraryPrepare requests and check responses with your own transport.

The operator approves which endpoint or native client the method can use. Each caller uses its own reviewed route. Parent settings and permissions are not inherited. Optional events, conversations, and sessions need corresponding requires declarations when the complete caller needs them.

The HTTP package supports none of those optional features. ACP declares all three. Package claims, host support, reviewed grants, and actual completion remain distinct. See required Agent behavior.

#HTTP outcomes

The HTTP Flow sends one non-streaming Chat Completions request by default through its exact http slot. Jig holds credentials and network access. The method interprets status, answer text, and stop reason. A refusal returns blocked.

Token exhaustion returns limit. Both outcomes retain text under the structured-answer rule. Tool requests, malformed responses, and non-200 statuses fail execution. Cancellation and host deadlines remain operational failures. The CLI reports host execution status separately from the method's outcome.

HTTP errors retain phase, api, status, category, and retry: "not-attempted" in details. An optional parameter names only a recognized API field reported by the provider. Errors do not print provider bodies or invent a cause.

An HTTP response proves the endpoint responded, not that remote effects were undone or safe to repeat. Review changed settings or grants before new work. The method never switches providers automatically.

#Use an OpenAI-compatible gateway

The same Flow can call an OpenAI-compatible gateway by changing its model, endpoint URL, and operator credential. For example, OpenRouter documents a Chat Completions endpoint and a dynamic free-model route:

settings: { model: 'openrouter/free', maxCompletionTokens: 4096 },
slots: {
  http: {
    kind: 'http', method: 'POST',
    url: 'https://openrouter.ai/api/v1/chat/completions',
    bearerEnv: 'OPENROUTER_API_KEY',
  },
},

See OpenRouter's API instructions and route details. The route selects from the provider's currently available free models. Availability, data policy, and model quality are provider-controlled and may change. This is a development configuration, not a stable model choice or a quality guarantee.

maxCompletionTokens defaults to 4096, within 1–65536. Model and token settings guide the admitted method. To enforce them against malicious method code, add matching constraints in the HTTP grant's bodySchema. The endpoint still owns its billing and data policy.

See HTTP Request.

Set api: 'responses' in the Binding settings and grant the exact /v1/responses endpoint to use Responses instead. structuredOutput: 'json-schema' requests the selected API's strict schema format. The default 'prompt' requests the shape in instructions. Both modes validate returned data locally and fail on unsupported responses.

Neither establishes semantic correctness.

Both APIs send store: false by default. Set omitStore: true in Binding settings for endpoints that reject this field. Omission does not establish the provider's data retention policy.

HTTP grants default to a 256 KiB request and 1 MiB response. For larger explicit context or answers, change the reviewed HTTP slot. Set requestBytes up to 8 MiB. Set responseBytes up to 12 MiB.

The method requests response: 'json', so a structured API response is passed as data rather than wrapped in another JSON string. The shared 1 MiB rendered-prompt and 8 MiB text limits still apply.

JSON/0's complete-value bounds, the grant's timeout (at most 60 seconds), and the Run deadline also apply. Requests are rejected, not truncated.

#Reuse the library

Import the pure functions from @jigging/agent-method:

FunctionResponsibility
prepareAgentRender instructions and explicit guidance into bounded request data.
finishAgentDecode an interpreted response and assemble done, blocked, or limit.
checkAgentResultCheck an implementation's complete result, including structured output when requested.

prepareAgent and finishAgent perform no provider call or file read. Your transport supplies bounded text and an interpreted stop reason. prepared.request contains ordinary prompt data and an optional responseSchema. It grants no execution rights.

The optional second preparation argument accepts SkillText values shaped as { name, files: [{ path, text }] }. The separate @jigging/agent-method/skills export provides readPackageSkills(packageRoot: URL, names). It reads explicit local Skill trees without acquiring other packages or authenticating caller identity. Use the package README for exact APIs, argument types, and source build/pack instructions.

The published Flow contains its runtime and needs no consumer build hook or unpublished runtime dependency. For source development, use ordinary workspaces. Keep source and rebuilt runtime together. Do not edit generated files.

#Composition and observations

A project's default Agent route can serve code and Markdown callers. A Binding can explicitly select another matching implementation. Child calls share the root deadline and aggregate budget. A failed descendant call throws through run.call.

Ordinary try/catch can handle conclusively cleaned failures. See composition policy for exact branch limits and cleanup requirements.

HTTP does not support optional update channels. A requested channel fails before dispatch. Use ACP when the caller requires public native updates. Markdown may select slots: { 'markdown-agent': 'binding:agent' } and validates structured decisions before activating authored recipes.

Finite ACP rejects instructions beginning with / after whitespace before native dispatch because clients interpret them as controls. See the finite authority profile.

Other Run/0 hosts can supply the same exact HTTP Request interface under their own authority. Library reuse, Flow consumption, and answer quality need separate evidence. Agent Run owns the exact interface and all input limits.