Ockam Agents are intelligent autonomous actors powered by large language models. They understand natural language, engage in conversations, and perform complex tasks. Each agent:

  • Maintains a unique identity and long-running conversations
  • Accepts customization with specific knowledge and capabilities
  • Runs securely in an isolated environment
  • Communicates with other agents and systems using Ockam’s secure messaging protocols

There are three key files that define an agent. First is the ockam.yaml file:

ockam.yaml
name: example001
pods:
  - name: main-pod
    public: true
    containers:
      - name: main
        image: main

The ockam.yaml file above defines:

  • name: example001 - A unique name for this deployment zone
  • pods - A list of pods to run in the zone
    • name: main-pod - The name of the pod
    • public: true - Makes the pod accessible from the internet
    • containers - The containers to run in the pod
      • name: main - Container name
      • image: main - References the image built from the Dockerfile located at images/<value>/Dockerfile

This minimal configuration creates a deployment that runs our agent code.

Next is the Dockerfile file:

images/main/Dockerfile
FROM ghcr.io/build-trust/ockam-python:latest
COPY . .
ENTRYPOINT ["python", "main.py"]

The Dockerfile above:

  • Uses the official Ockam Python base image which includes the Ockam SDK
  • Copies the agent code (main.py and other files) into the container
  • Sets the entrypoint to run main.py when the container starts

Finally is the main.py file:

images/main/main.py
from ockam import Agent, Node


async def main(node):
    await Agent.start(node, "You are Henry, an expert legal assistant", "henry")


Node.start(main)

The main.py file above:

  • Imports the Ockam SDK
  • Defines an async main function that starts an agent with a specific prompt
  • Starts the node and agent
Ensure you have Docker installed and running on your workstation before running the ockam command.

When you run ockam it will:

  • Build the image from the Dockerfile
  • Deploy the container to the Ockam serverless runtime
  • Expose a public HTTP endpoint to the agent
  • Create two local (i.e., on your workstation) portals to the agent’s HTTP endpoint and log output.
» ockam
    Deploying zone example001 in cluster 25df35de87aa441b88f22a6c2a830a17...

  ✔ Created a repository for the image main
  ✔ Built image main
  ✔ Pushed image main

  ✔ Deployed zone example001 in cluster 25df35de87aa441b88f22a6c2a830a17

    The http server on the main-pod is available at:
    https://25df35de87aa441b88f22a6c2a830a17-example001.ai.ockam.network

  ✔ Opened a portal to the outlet http on main-pod from tcp://localhost:8000
  ✔ Opened a portal to the outlet logs on logs-pod from tcp://localhost:3000

    ─────────────────────────────────────────────────
    Press Ctrl+C to stop all portals and exit

Logs

You can see the logs of your running python app on http://localhost:3000/logs/explorer .

HTTP Server

http GET \
"https://25df35de87aa441b88f22a6c2a830a17-example001.ai.ockam.network/agents"
http POST \
  "https://25df35de87aa441b88f22a6c2a830a17-example001.ai.ockam.network/agents/henry" \
  message="who are you"
http POST \
  "https://25df35de87aa441b88f22a6c2a830a17-hello.ai.ockam.network/agents/henry?stream=true" \
  message="who are you"