Write the Agent program

Target outcome

Place the business rules and required source code under /oasn so OpenClaw's main Agent can handle the same class of task in both development WebChat and formal invocations.

Confirm the target runtime first

ItemCurrent development Workspace baselineDevelopment implication
Business root/oasnBusiness files, Skills, Plugins, and optional services are all rooted here.
Agent RuntimeOpenClaw 2026.6.11Configuration and extensions must be validated against this pinned version.
Operating systemDebian GNU/Linux 12, amd64If local development uses another platform, remote verification remains authoritative.
Resources2 vCPU / 4 GB / 10 GB rootfsAvoid builds, models, or resident services that exceed these limits.
Preinstalled toolsNode.js 22, Python 3.12, Git, OpenSSHThe CLI does not report their exact versions. Measure them in the active Workspace with the commands below.

After the Workspace reaches status=active, run openagent-dev workspace connect --workspace-id <workspace_id> using an existing local key. Only when the result reports ssh_binding_status=bound and ssh_verified=true should you copy its ssh_command exactly, enter the current Workspace, and run:

node --version
npm --version
python3 --version
python3 -m pip --version
git --version

Record the actual output in this development run's notes. Do not infer exact patch versions from this handbook, installation logs, or another Workspace.

Program area in the version workspace
Version workspace. The Program area shows VM, Chat, Models, and Resources. The actual business implementation is under remote /oasn.
/oasn/
├── AGENTS.md                              # Business rules for the main Agent
├── SOUL.md                                # Optional: voice and boundaries
├── IDENTITY.md                            # Optional: identity description
├── USER.md                                # Optional: user-context conventions
├── TOOLS.md                               # Optional: Tool usage instructions
├── skills/<skill-name>/SKILL.md           # Optional: business Skill
├── .openclaw/extensions/<plugin-id>/      # Optional: Workspace Plugin
├── service/                               # Optional: business service or source
└── Other business source and static assets

Do not treat runtime state as the Program.

Sessions, logs, PIDs, device identities, authentication databases, each Agent's models.json, Secrets, caches, and browser data must not become version content. /opt/oasn/platform and /usr/local/bin/openclaw are managed by the platform and may be overwritten during publishing.

Implement in this order

  1. Start with one clearly defined task

    In AGENTS.md, define applicable inputs, required information, output format, failure semantics, and safety boundaries. Make the smallest text-only task work before adding files, Tools, Plugins, or services.
  2. Make sure the capability belongs to the main Agent

    Formal invocations always enter through main. The main Agent may call other Agents or subagents, but do not configure the complete business capability only on another Agent.
  3. Place extensions in standard locations

    Put business Skills under /oasn/skills/<skill-name>/ and Workspace Plugins under /oasn/.openclaw/extensions/<plugin-id>/. Do not create unused directories merely to match the example structure.
  4. Validate dependencies in the target environment

    A dependency declaration, installation log, or existing file is not proof that a dependency works. Actually test the import/module, system command, Plugin runtime, any required service reload, and one real business request.
  5. Validate main through WebChat

    Use only the WebChat URL associated with the current active Workspace, and cover normal, attachment, and boundary requests. See “Testing and acceptance” for the detailed gates.

Formal input contract

Skills and Plugins normally handle the messages and attachments received by main directly. Native tools that need structured input on a shared runtime can locate the current Run's manifest using the fifth execute argument, oasnRunId, on builds that support it.

/oasn/.oasn-shared-runs/<run_id>/in/invocation.json
FieldMeaningConstraint
input.user_promptUser text for this invocationIf it is empty or insufficient, explicitly ask the user for what is missing; do not invent it.
input.attachmentsList of attachment paths for this invocationProcess only the listed paths. Do not scan directories, guess paths, or reuse files from an earlier invocation.

Legacy non-shared runtimes use /oasn/in/invocation.json. If a shared formal invocation has no trusted Run ID, report the missing input and check the runtime build. Input manifests are read-only and may contain short-lived runtime material. Read only the business fields on the server and keep the complete manifest out of logs, final replies, and screenshots. Development WebChat uses its current message and attachments. See the formal invocation example in Structured Input and WebUI JSON.

Output contract

  • Text: main must return a non-empty final response.
  • Files: create a real file and return it in the final response as an attachment or downloadable Markdown link. Merely returning a path such as /oasn/... is not acceptable.
  • WebUI: use CLI 0.11.0 openagent-dev version webui-ports get --version-id <agent_version_id> to inspect ports supplied by the confirmed configuration and platform configuration. The CLI does not edit or refresh ports; missing or expired connections are restored through the platform readback flow. A failed result must retain failure_code. The service must listen on a declared port and return the corresponding oasn-webui block; see “Input, Output, and WebUI” for its structured JSON contract.
  • Sensitive information: never output .env, keys, Cookies, sessions, logs, caches, or browser data.

Definition of done

The Program is complete only when all of the following are true:

  • All business files are under /oasn, with no dependency on a local file that was not uploaded.
  • main completes representative tasks and gives clear, actionable guidance when required input is missing.
  • Every dependency, Tool, Plugin, or MCP in use has been genuinely validated on the remote runtime surface.
  • Attachments come only from explicit input in the current invocation, and users can actually open or download the output artifacts.
  • No Secret, temporary state, or platform-managed file is included in version content.