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/agents.md.
DocumentationGuidePrerelease

#Choose an Agent

View Markdown

An Agent-capable Flow delegates intelligent work through an agreed interface. Choose its implementation once for your project. Callers supply the task and selected Skills. Jig keeps the selected method's resources and credentials separate from the caller.

Both the HTTP and native ACP implementations are ordinary, replaceable Flow packages. The reusable Agent method can also be imported as a pure library. Jig grants their underlying resources rather than implementing the Agent on their behalf.

The current alpha reads exported environment variables for both jig review and jig run. Project .env files are not loaded automatically.

#Before you start

Use an installed Jig CLI on a supported host. Start with the project from your first Flow. You need Bun for the dependency commands below. Choose either an API credential or an authenticated supported native client.

The first test asks for one answer and returns it in output.text. Your application still checks the answer before using it.

#Choose for the work you need

The shared Agent contract describes the interface, not support for every optional feature. Choose the implementation and grant before starting expensive work:

Needed behaviorHTTP AgentNative ACP Agent
One bounded answer, including a checked structured resultSupported with a compatible configured APISupported with a qualified client
Public live updatesNot supported by this implementationOptional events channel
Same-session follow-up or interruptionNot supportedConversation channels. maxTurns bounds the total turns
Native retention or restorationNot supportedSeparately enabled native grant and qualified client. Inspect the final retention receipt

Declare behavior that the complete calling method requires, for example "requires": ["conversation"] beside its uses.agent.contract reference. The HTTP implementation declares supports: []. ACP declares events, conversation, and sessions. jig review rejects a required name missing from the selected implementation's claims before the caller starts. It does not switch the chosen implementation automatically.

Check three separate facts:

  1. The method claims to implement the behavior.
  2. Its reviewed resources permit it.
  3. This execution actually completes. Review checks declarations and known host/resource prerequisites without running the package or calling a model. It cannot prove an arbitrary Flow's behavior or infer its resource use. A one-turn grant still cannot provide a follow-up, and a valid answer is not evidence of retained native state. See the exact feature definitions.

#API access

From your project root, install the HTTP Agent package and retain its Bun lock:

bun add @jigging/agent-method@alpha
mkdir -p bindings

Use workspace:* instead when the package is a local Bun workspace member. The ordinary Flow supports Chat Completions and Responses. Its Binding selects model and API behavior. Its exact HTTP grant selects the endpoint and credential name. The operator supplies that credential through the environment.

Create bindings/agent.ts:

import { defineBinding } from '@jigging/jig'

export default defineBinding({
  package: 'npm:@jigging/agent-method',
  settings: { model: 'your-model', maxCompletionTokens: 4096 },
  slots: {
    http: {
      kind: 'http', method: 'POST',
      url: 'https://api.openai.com/v1/chat/completions',
      bearerEnv: 'OPENAI_API_KEY',
    },
  },
})

Choose a model supported by the endpoint. Export the named credential. For a gateway, use its exact URL and credential name. See OpenAI-compatible gateways for formats and limits.

Then select the Binding in jig.ts:

import { defineJig, discover } from '@jigging/jig'

export default defineJig({
  flows: discover('./flows'),
  bindings: discover('./bindings'),
  defaultProviders: { 'https://jig.md/contracts/agent-run': 'binding:agent' },
})

binding:agent names your discovered bindings/agent.ts. Jig does not supply or install an Agent Binding. Its package selects the implementation and its slots configure that implementation's resources. The mapping is by contract, not by the consumer's local slot name. With exactly one eligible configured Agent, the defaultProviders line is optional. A missing explicitly selected Binding remains a configuration error.

Matching code and Markdown Flows use that reviewed selection. An explicit Binding slot can choose another matching implementation. See default providers.

The npm: selector uses declared dependency preparation. It does not traverse the live installation tree at execution time. Review the grant before invoking the Binding:

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

Expect execution status succeeded, outcome done, and an answer in output.text. A blocked or limit outcome needs inspection before further work. Try another question by changing instructions, without changing the grant.

Jig holds the credential and network access. The method interprets the HTTP response. Use the method guide to supply Skills, schemas and application checks.

#Local clients

For a new project, choose your installed client while creating its ordinary files:

jig init my-project --agent codex

Replace codex with claude, or use --agent without a value for an interactive choice. Open the generated README for authentication prerequisites, review and the first Run. Initialization writes the dependency and Binding shown below. It does not install a client or approve its grant. The generated dependency pins the tested ACP package version. Source-candidate builds still require that version to be published or supplied through an ordinary workspace.

For an existing project, add the package from its root:

bun add @jigging/agent-acp@alpha
mkdir -p bindings

Retain the Bun lock. Use workspace:* for a member of your Bun workspace. The published package contains the runnable Flow. Its source package also documents building and packing a candidate from reviewed source. Create bindings/agent.ts:

import { defineBinding } from '@jigging/jig'

export default defineBinding({
  package: 'npm:@jigging/agent-acp',
  slots: { native: { kind: 'acp' } },
})

Omitting client is the portable default. Interactive jig review asks which native Agent to use. Noninteractive review supplies the choice:

jig review --agent codex --yes

Replace codex with claude. The chosen default is recorded with the approved generation, not written to application source. An author can explicitly pin client: 'codex', client: 'claude' when the method depends on a specific implementation. Explicit pins can also specify a compatible model or native session retention.

A simple native policy belongs directly in its Binding. Use a named grant when several Bindings intentionally share one policy or it has a separate management owner. No grants directory is required for inline policy.

Choose your installed client during review and consult its configuration profile. The package has no second client selector.

For multiple operator-owned authentication sources of one native client, add an optional authProfile LocalName to the ACP grant. Set the matching JIG_ACP_PROFILE_<NAME>__<FIELD> environment selector before invoking jig review, for example:

export JIG_ACP_PROFILE_PERSONAL_CODEX__CODEX_HOME=/absolute/path/to/personal-codex
export JIG_ACP_PROFILE_WORK_API__OPENAI_API_KEY="$MY_WORK_OPENAI_API_KEY"
slots: { native: { kind: 'acp', client: 'codex',
                   authProfile: 'personal-codex' } }

The native method receives only the chosen profile's validated credential projection. A selected profile never falls back to ambient or sibling secrets. For API-key mode, select the workload's model in the grant. This is profile selection, not automatic failover or native history migration. Named profiles support session retention when combined with retainSessions: true on qualified Codex. See ACP grants.

To require an exact reasoning effort, add reasoningEffort: 'low' to the ACP grant and review the change. Either native client can use the setting with subscription or API authentication. You can leave the client for the operator to select or pair the effort with a pinned client and model. At Run time, if the selected model cannot confirm the effort, Jig stops before forwarding the first prompt. Leave the field out to use the client's effort selection. See Finite ACP.

#Native candidate recovery

The ordinary native ACP package (npm:@jigging/agent-acp) supports ordered candidate recovery. When an active slot fails at an authorized boundary with confirmed process cleanup, execution advances safely to a backup slot (backup1, backup2, or backup3). Recovery boundaries include unforwarded task prompts and first-turn rejection without output.

import { defineBinding } from '@jigging/jig'

export default defineBinding({
  package: 'npm:@jigging/agent-acp',
  slots: {
    native: {
      kind: 'acp',
      client: 'codex',
      authProfile: 'subscription-a',
    },
    backup1: {
      kind: 'acp',
      client: 'codex',
      authProfile: 'api-key',
      model: 'o3-mini',
    },
    backup2: {
      kind: 'acp',
      client: 'claude',
      authProfile: 'work-claude',
    },
  },
})

Backup slots are optional and declared on the same single Flow level without extra wrapper packages or protocol-level shims. Calls maintain full events, conversation, and sessions support.

Configure candidate advancement with optional settings.recovery fields on the binding:

  • beforePrompt ("next" default, or "stop"): controls failover after a confirmed unforwarded failure on turn 0.
  • afterRejectedPrompt ("stop" default, "next-on-limit-or-service", or "next-on-auth-limit-or-service"): controls failover when turn 0 is rejected before output.
  • sameClientSession ("resume-if-qualified" default, or "fresh"): controls whether compatible same-client profiles reuse retained Codex sessions.

Add model: 'your-model-id' beside client in the grant to select a model for that Binding. Omission uses the operator environment or the client's documented default. Authentication stays with the operator. Review shows the exact grant, model and installation before launch. Changing the grant requires renewed approval.

jig review
jig run binding:agent --input '{"instructions":"Explain one useful check."}' --receive events

The ordinary Flow interprets ACP responses and emits selected public updates. The finite ACP resource owns the native client and its restricted profile. The original repository and the Flow's source are not mounted into that credential-bearing scope. Observation does not confer Agent control or establish that the answer is correct.

Jig finds the selected native client on your exported PATH, including an operator-managed profile or nix-shell. You can select a particular executable with an absolute CODEX_PATH or CLAUDE_PATH. An invalid override must be corrected or unset. It does not fall back to PATH discovery. Review shows the resolved executable so you can check which installation you selected.

Native runtime files keep their installation paths inside containment. Install them outside reserved sandbox paths (/dev, /jig, /proc, /run, /sys, /tmp and /work). Review reports a location error for a conflicting executable, adapter or supporting file. Select an operator-owned installation and review again.

Discovery skips relative PATH entries, the project tree, and ancestor node_modules directories, including symlink routes through them. Shell aliases are not visible to Jig. The adapters require supported native installations. A shell wrapper or npm JavaScript launcher is not itself the native executable. For Codex's current official npm layout, Jig finds the matching native package without running the launcher. This also works with Volta's recorded global npm installation.

Review shows the native binary that will run. No extra path setting is needed for these layouts. Unsupported launchers still require an explicit native executable. See the selection rules for the supported metadata and project exclusions.

#Codex

Install Codex and sign in as the OS user running Jig, using Codex's login instructions. Jig supports these Codex installations:

  • Standalone Linux x86-64 binaries.
  • Native packages using Nix's binary PATH wrapper.
  • The current official npm layout, including Volta.
  • Native Mach-O clients on qualified Macs. It retains the executable and required non-system shared libraries as individual reviewed files.

On Linux, for Codex's nested sandbox, Jig selects an unprivileged bwrap from the installation wrapper's PATH prefix or your exported PATH. If none is available, it uses the installation's matching codex-resources/bwrap. You do not need that bundled directory when your package supplies Bubblewrap separately. JIG_BWRAP_PATH configures only Jig's outer containment tool.

On native Apple Silicon Macs, Codex uses /usr/bin/sandbox-exec and an explicitly checked preference observer. Before selection and each launch, including restoration, Jig refreshes host policy and refuses configured managed preferences or unavailable observation. Keep managed settings intact. A missing or unverifiable observer requires repairing the complete Jig installation.

The check is a prelaunch snapshot. Jig does not continuously monitor policy changes introduced after that snapshot.

Mac release qualification requires genuine native session creation and confirmed cleanup on macOS 15 and macOS 26. An unsupported-client refusal cannot satisfy that check. Offline startup with placeholder credentials establishes neither subscription authentication nor endpoint access or model execution.

The contained profile may receive narrow preference-change notifications while preference values and writes remain denied. Native canary checks do not prove the private notification-page layout. Actual forced-policy refusal and expiry during a genuinely stalled framework call remain separate qualification gaps.

The current adapter reads a file-backed login from $CODEX_HOME/auth.json, defaulting to ~/.codex/auth.json. Configure Codex with cli_auth_credentials_store = "file" before signing in. Jig does not currently read Codex's OS-keyring credentials.

Codex token metadata named oauth_provenance and login_owner_id may be present or absent. Jig discards these fields when preparing its short-lived credential and leaves your authentication file unchanged. The existing ownership, permission, expiry and account checks still apply. Successful projection alone does not prove that subscription inference will succeed.

An overridden OPENAI_BASE_URL must use HTTPS, without a username, password, query or fragment. The selected endpoint must pass normal certificate verification. A local HTTP server is not an accepted native Codex endpoint.

The current adapter supplies a short-lived credential to the contained client. It does not give it your full authentication store or refresh credentials.

If review rejects the selected client, follow client-check troubleshooting.

#Continue a conversation

For applications that revise an answer or interrupt a running turn, see continuing conversations. The same ordinary Agent package uses paired control/reply channels. An explicit maxTurns grant bounds further prompts. One-shot calls require neither change.

#Switching

With an unpinned ACP grant, choose your preferred Agent when reviewing the application. A terminal prompt lets you choose without editing source:

jig review
jig run

For repeatable noninteractive review:

jig review --agent claude --yes

Only unpinned native ACP resources use that choice. The approved lock retains each exact client and jig inspect reports the effective selection. Runs cannot replace Agents. To switch after approval, review again and approve the changed resources. A later review may suggest the previous choice, but never reuses it without operator input.

A method needing a specific native Agent explicitly pins its client in the Binding or a named grant. Those pins are not changed by --agent. Keep compatible model and native session requirements with the pin. HTTP-backed Agents remain separate replaceable Flow implementations. This feature does not yet route between HTTP and ACP implementations.