Skip to main content
Version: v5.8.1

12.7 Build one: agent init and agent dev

packs:agents

After this you can: write an agent repository of your own with opschain agent init, run it against an embedded server with make dev, keep its SDK current with agent init --upgrade, and package it as a signed release.

Before you start — tick each one:

  • Lesson 12.2 — Enrol, own, assign, grant, ceiling (opschain learn 12.2)

In the GUI: nothing extra — agent dev runs its own loopback server; once your release is enrolled on a real server, the agent's sheet names it like any other (lesson 12.4).

So far you have operated Felix. This lesson builds it. The opschain binary carries the OpsChain Agent SDK at its own version — the Python runtime and its model adapters — so the binary is all you need: one command writes a working agent repository, one more runs it. Nothing here needs a licence or a network connection; the local loop is deliberately waived from the entitlement gates, and the production ceremony at the end is not.

1. Write the agent​

opschain agent init felix --lang python
cd felix
wrote the python agent "felix" to ./felix with the OpsChain Agent SDK 5.8.1 (12 files)
next: cd ./felix && make dev (README.md walks the rest; the agent's state directory is its credential and is git-ignored)

--lang is required, and python is the language the SDK ships in. The repository holds:

pathwhat it is
agent.pyyour agent: one chat capability, one custom capability (x-hello)
manifest.jsonthe job description a signed release carries — name, version, type, capabilities, disclosures
tests/, Makefilethe smoke test; make dev, make test, make release
opschain_sdk/the SDK at your binary's version, with VERSION and MANIFEST.sha256
.gitignorethe state directory and .env

The SDK gives you, for free: enrolment with a registration token, a durable Ed25519 identity under a state directory, the outbound-only channel with reconnect and re-register, the five mandatory surfaces (healthz, readyz, info, metrics, logs), the request lane for calling the platform API, and one correlation scope per unit of work threaded through every call you make. You write capabilities:

def register(agent):
@agent.chat
def chat(message):
yield "felix here, "
yield "you said: " + message

@agent.capability("x-hello")
def hello(request):
return Response(200, {"Content-Type": "text/plain"}, "hello from felix\n")

The repository carries no token, key or server URL. The state directory holds the agent's identity — its credential — and is git-ignored.

2. Run it with make dev​

make dev

make dev starts opschain agent dev — an embedded server on loopback, the sandbox project local, a seeded trust profile — mints a registration token for felix against it and runs agent.py, which enrols exactly as it would against production:

dev server: http://127.0.0.1:7726 (project local, dev server log .opschain/dev-server.log)
agent: http://127.0.0.1:7726/api/projects/local/agents/felix/{healthz,readyz,info,metrics,logs,chat,x-hello}
registered agent … as /local/agents/felix
channel open (long-poll)

Call the surfaces with the dev server's admin token, which make dev prints on its admin: line (a new one every run):

curl -sN -H "Authorization: Bearer <admin-token>" -H 'Content-Type: application/json' \
-d '{"message":"ping"}' http://127.0.0.1:7726/api/projects/local/agents/felix/chat

Ctrl-C stops the agent (it says goodbye first) and the dev server. make test runs the offline smoke test.

Two rules the server enforces on whatever you write: a capability you did not declare never reaches the agent (404 at the platform edge), and a change or workflow run the agent creates through the request lane (agent.call_api(...)) MUST carry a rationale attribute — the server refuses an agent-originated create without one, and the approver reads it back in the inbox (lesson 12.3).

In any other language, the agent runs as a separate process behind opschain agent --target <url>: the OpsChain runtime holds the identity and the channel and forwards each declared capability to it — how the runtime reaches that process, and the trust boundary of the hop, is opschain docs agent-plane.

3. The AI job description​

opschain agent init felix-ai --lang python --adapter claude

adds adapters/ with the Claude bridge and pins claude-agent-sdk in requirements.txt to the version this SDK was tested against (opschain agent sdk version prints the supported matrix). The manifest declares type ai with the disclosures that type must attest — its model is claude-agent-sdk-default, the framework's default, because no model is pinned in the supported matrix — and custody defaults to brokered: on a server, OPSCHAIN_MODEL_PROVIDER names the platform's model provider and the agent holds no model key. The local dev server has no model gateway, so locally set the agent-host key in the agent's environment instead. Install the requirement into a virtual environment and run make dev PYTHON=.venv/bin/python. Locally no entitlement applies; on a licensed server the same manifest needs packs:agent-governance + packs:ai-agents (lesson 12.6). Add a bridge to an existing agent later with opschain agent init --add-adapter claude.

4. The production ceremony, locally​

opschain agent dev --strict seeds nothing: the registration-token ceremony and token-gated telemetry run exactly as production enforces them — the enforcement code is identical in both profiles, they differ only in which rows exist at the start:

opschain agent dev --strict --admin-token <token>

With no --token the command prints the exact opschain admin agent-token create invocation to mint one against the dev server and keeps the server running so you can. Point your agent at it with OPSCHAIN_SERVER and OPSCHAIN_TOKEN and it enrols the way Felix did in lesson 12.2.

5. Keep the SDK current​

After you upgrade OpsChain:

opschain agent init --upgrade

refreshes opschain_sdk/ (and adapters/) to the new binary's SDK and lists every file it added, updated or removed; nothing else in the repository is touched. It refuses, naming each file, when you changed a file there — keep your code outside the SDK directories, or pass --force to overwrite. opschain agent sdk version --verify . checks the SDK files against the binary's digests at any time. To vendor the SDK into a repository you already have, opschain agent sdk export --lang python ./vendor/opschain writes the files alone.

6. Package it as a signed release​

A build becomes something the estate can trust by becoming a release: a <name>@<version>, the manifest document, the content-addressed artifact (the image digest or git sha you built) and a signature from a registered key. Register the key once, sign in the pipeline, register the release:

opschain admin agent-release keygen --name release-pipeline --out ./felix-signing.key
make release KEY_FILE=./felix-signing.key VERSION=2.2.0
opschain admin agent-release create --name felix --version 2.2.0 \
--artifact <git-sha> --manifest manifest.json --type service \
--key-id <key-id> --signature-file dist/felix-2.2.0.sig
signed felix@2.2.0 (artifact …) with key fingerprint SHA256:…
signature written to dist/felix-2.2.0.sig
created agent release felix@2.2.0 (id 019a0e11-…)
stage: dev

make release runs opschain admin agent-release sign over the commit you built; sign makes no server call, so a pipeline signs offline. create re-verifies the signature server-side before the row lands and freezes the declared type (and any disclosures object in the manifest) into the signed content. From here the release is at dev, and lesson 12.4's walk takes it up the ladder: promote, try it in the shadow lane, promote into prod under approval, roll the stable lane, retire the old one.

An SDK agent names the release it runs as with the Python release="felix@2.2.0" option or OPSCHAIN_AGENT_RELEASE in the container's environment, and handles the platform-instructed restart of a rollover itself.

Check yourself​

  • Which directory of your agent repository does agent init --upgrade own, and what does it do when you edited a file there?
  • What does agent dev give you that a production instance does not, and what signs a release?

What you learned​

  • opschain agent init writes a complete agent repository from the SDK your binary embeds — offline, with no credential in it; the state directory is the credential.
  • make dev runs the agent against an embedded loopback server with a seeded trust profile; --strict runs the production ceremony locally.
  • agent init --upgrade keeps opschain_sdk/ at your binary's version and never overwrites your changes silently; agent sdk version --verify checks it.
  • A release is name, version, manifest and artifact under an Ed25519 signature — signed offline with a registered key, verified server-side, registered at dev; from there lesson 12.4's ladder takes it into production.

Next: lesson 12.8 — The bundled SMEs (opschain learn 12.8), or back to your track (opschain learn).