Skip to main content
Version: v5.8.1

opschain agent init

packs:agents

Writes a complete agent repository carrying the OpsChain Agent SDK this binary embeds: a hello agent with one chat capability and one custom capability, its manifest, a smoke test, a Makefile with dev, test and release, and the SDK itself at the binary's version. Offline: no server, no registry, no download. It writes nothing outside the target and never a token, a key or a server URL.

opschain agent init <dir> --lang python [--name <name>] [--adapter claude|openai|none] [--force]
opschain agent init --upgrade [<dir>] [--force]
opschain agent init --add-adapter claude|openai [<dir>] [--force]
cd <dir> && make dev

What it writes​

PathOwner
README.mdYours: the getting-started notes for this agent, with the two commands.
agent.pyYours: the hello agent — chat and x-hello. It runs under agent.run_forever(), so a refusal it cannot recover from ends it with one line and exit status 1, without a traceback.
manifest.jsonYours: name, version, type, entrypoint, capabilities, the SDK it was written with, and the disclosures (with --adapter: type ai, model, adapter, tool surface and brokered custody; with --adapter claude the model is claude-agent-sdk-default, the framework's default, while the supported matrix pins none).
requirements.txtYours. With --adapter claude: claude-agent-sdk pinned to the version the SDK was tested against (opschain agent sdk version).
tests/test_smoke.pyYours: the offline smoke test (make test).
.gitignoreYours: the state directory (.opschain/, the agent's key) and .env.
MakefileYours: dev (the embedded dev server and the agent), test, release (signs a release with KEY_FILE=<key>).
scripts/dev.shYours: what make dev runs.
opschain_sdk/Managed: the SDK at this binary's version, with VERSION and MANIFEST.sha256.
adapters/Managed, only with --adapter: the bridge module(s), with VERSION and MANIFEST.sha256.

The agent runs the SDK in-process: it enrols with a registration token, holds the channel and serves its capabilities with no listener. make dev starts opschain agent dev, mints a token for the agent against the dev server and runs agent.py.

The native SDK is Python. An agent written in any other language runs as a separate process behind the sidecar, opschain agent, which holds the identity and the channel and forwards each declared capability to that process (opschain docs cli/agent, opschain docs agent-plane).

The agent's state directory holds its Ed25519 identity — the agent's credential — and is git-ignored. With --adapter, custody defaults to brokered (the model reached through the platform's model gateway, no model key in the agent's environment); the agent-host key form is noted beside it in agent.py.

--upgrade​

Refreshes opschain_sdk/ (and adapters/) to this binary's SDK after a product upgrade and touches nothing else. It lists each file added, updated and removed. It refuses, naming every file, when a managed file no longer matches the digest MANIFEST.sha256 recorded (modified locally or missing); --force overwrites them.

--add-adapter​

Adds an adapter to an existing agent: the bridge module(s) under adapters/ and, for claude, the pinned claude-agent-sdk line appended to requirements.txt once. agent.py and manifest.json are yours, so it prints what to change in them. Repeating it is harmless.

Flags​

FlagMeaning
--lang pythonThe agent's language. Required for a new agent; there is no default. Any other value is refused.
--name <name>Agent name and code: lower-case letters, digits and hyphens, starting with a letter (default: the directory's name). dev is reserved for the runtime agent agent dev enrols itself.
--adapter claude|openai|noneModel framework adapter (default none: the runtime alone).
--upgradeRefresh only the SDK files of an existing agent (default target: the current directory).
--add-adapter claude|openaiAdd an adapter to an existing agent (default target: the current directory).
--forceWrite into a non-empty directory (files of the same name are overwritten, nothing else is touched), or overwrite managed files changed locally.

Exit codes​

CodeMeaning
0Written.
1Refused (named error below) or a filesystem error.
2Usage error.

Named errors​

  • --lang is required: python (exit 2)
  • unknown SDK language "<lang>" (the native SDK ships for python only); an agent in any other language runs as a separate process behind the sidecar: … (exit 2) — the message names the sidecar command (opschain docs cli/agent) and opschain docs agent-plane
  • unknown adapter "<name>" (one of claude, openai, none) (exit 2)
  • invalid agent name "<name>": … (exit 2)
  • target directory is not empty: <dir> holds <n> entries; pass --force …
  • SDK files were changed locally — <path> (modified locally), …; move your changes out of the SDK directories or pass --force to overwrite them
  • not an OpsChain Agent SDK tree: <dir> is not an agent written by opschain agent init (no opschain_sdk/MANIFEST.sha256)

Postures​

Offline in every posture: the local lane, a server on the SQLite store and a server on PostgreSQL. The written agent runs against opschain agent dev locally (no model gateway there: an adapter agent uses an agent-host key) and enrols with any server.

See also​

  • opschain learn 12.7 — the lesson walking agent init and agent dev.
  • opschain docs cli/agent-sdk-version — the embedded SDK's version, digests and supported matrix, and the verification of an agent's SDK files.
  • opschain docs cli/agent-sdk-export — the SDK files alone, for an existing repository.
  • opschain docs cli/agent-dev — the development loop.
  • opschain docs agent-plane — the platform-side contract.