molecule-core/sdk/python/examples/remote-agent
Hongming Wang fa9342aa81 chore: structural cleanup — dead dirs, moves, gitignore
- Delete empty platform/plugins/ (dead remnant; plugins/ at repo root is
  the real registry; router.go comment updated)
- Gitignore local dev cruft: platform/workspace-configs-templates/,
  .agents/ (codex/gemini skill cache), backups/
- Untrack .agents/skills/ (keep local, stop tracking)
- Move examples/remote-agent/ → sdk/python/examples/remote-agent/
  (co-locate with the SDK it exercises); update refs in
  molecule_agent README + __init__ + PLAN.md + the demo's own README
- Move docs/superpowers/plans/ → plugins/superpowers/plans/
  (plans were written by the superpowers plugin's writing-plans
  subskill; belong with the plugin, not under docs)
- Add tests/README.md explaining the unit-tests-per-package +
  root-E2E split so new contributors don't ask
- Add docs/README.md explaining why site tooling lives under docs/
  rather than a separate docs-site/ (VitePress ergonomics)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:06:52 -07:00
..
README.md chore: structural cleanup — dead dirs, moves, gitignore 2026-04-13 14:06:52 -07:00
run.py chore: structural cleanup — dead dirs, moves, gitignore 2026-04-13 14:06:52 -07:00

Remote agent demo

A ~100-line Python script that registers with a Molecule AI platform from outside its Docker network, pulls its secrets, and heartbeats — exercising the Phase 30.1 / 30.2 / 30.4 endpoints end-to-end.

Prerequisites

  • A running Molecule AI platform (./infra/scripts/setup.sh + go run ./cmd/server from platform/)
  • pip install requests in your Python environment

Quick start

# 1. Create the workspace row on the platform. `external` runtime keeps
#    the provisioner from trying to start a Docker container:
curl -s -X POST http://localhost:8080/workspaces \
    -H 'Content-Type: application/json' \
    -d '{"name":"remote-demo","tier":2,"runtime":"external"}'
# → {"id":"<UUID>", ...}

# 2. (Optional) seed a secret so `pull_secrets` has something to return:
curl -s -X POST http://localhost:8080/workspaces/<UUID>/secrets \
    -H 'Content-Type: application/json' \
    -d '{"key":"REMOTE_DEMO_KEY","value":"hello-from-remote"}'

# 3. Run the demo from any machine that can reach the platform:
WORKSPACE_ID=<UUID> PLATFORM_URL=http://localhost:8080 \
    python3 sdk/python/examples/remote-agent/run.py

You should see log lines for each of the three phases, and then heartbeat lines every 5s. The workspace should appear online on the canvas. Pause or delete it from the canvas / via API, and the script exits cleanly.

What this demonstrates

Phase Endpoint Shown in the demo
30.1 POST /registry/register Token issuance + on-disk caching
30.1 POST /registry/heartbeat Bearer-authenticated liveness report
30.2 GET /workspaces/:id/secrets/values Token-gated decrypted-secrets pull
30.4 GET /workspaces/:id/state Token-gated pause/delete detection

What it doesn't do yet

  • No inbound A2A server. Other agents can't initiate calls back to this remote agent. Future 30.8b adds an optional HTTP server helper.
  • No sibling discovery. Future 30.6 adds peer URL caching so this agent can call siblings directly instead of going through the proxy.

Troubleshooting

  • 401 missing workspace auth token on the secrets/state calls — your cached token is stale (workspace was recreated). Delete ~/.molecule/<workspace_id>/.auth_token and re-run.
  • connection refused — double-check PLATFORM_URL and that the platform is actually listening.
  • Workspace never appears as online on the canvas — confirm it was created with runtime: external (otherwise the provisioner will try to start a local container and fail).