Compare commits

..

2 Commits

Author SHA1 Message Date
sdk-dev 56e963bb87 fix(docs): update stale docstring to reflect shipped inbound delivery paths
[Do] Manual ack
Test / test (3.12) (pull_request) Successful in 2m1s
Test / test (3.11) (pull_request) Successful in 2m8s
Test / test (3.13) (pull_request) Successful in 2m16s
sop-checklist / all-items-acked All items acknowledged
sop-checklist / [Do] Done
The module docstring claimed "No inbound A2A server is bundled here yet"
but A2AServer (push) and PollDelivery (poll) have been implemented and
documented since Phase 30.8b/30.8c. Replaced the outdated claim with a
concise description of both delivery modes and how run_agent_loop uses them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 20:19:09 +00:00
sdk-dev 6a1b2bf1a1 fix(docs): remove stale sdk/python/ path references
Test / test (3.11) (pull_request) Successful in 2m7s
Test / test (3.12) (pull_request) Successful in 2m19s
Test / test (3.13) (pull_request) Successful in 2m28s
sop-checklist / all-items-acked test
[Do] Manual ack
The repo was restructured from sdk/python/ to top-level molecule_agent/
and molecule_plugin/. Four doc references still pointed to sdk/python/:

- molecule_agent/__init__.py: sdk/python/examples/remote-agent/ → examples/remote-agent/
- molecule_agent/README.md: sdk/python/examples/remote-agent/ → examples/remote-agent/
- molecule_plugin/__init__.py: sdk/python/README.md → repo root README.md
- examples/remote-agent/README.md: sdk/python/examples/remote-agent/run.py → examples/remote-agent/run.py

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:18:29 +00:00
7 changed files with 24 additions and 56 deletions
+1 -22
View File
@@ -1,4 +1,4 @@
name: CI
name: Test
on:
push:
@@ -27,24 +27,3 @@ jobs:
- name: Lint
run: pip install ruff && ruff check molecule_agent/ molecule_plugin/
all-required:
name: all-required
needs: [test]
# required: all matrix variants must succeed
if: always()
runs-on: ubuntu-latest
steps:
- name: Verify all required jobs passed
run: |
# Collect results from all test matrix variants
results="${{ needs.test.result }}"
echo "Matrix results: $results"
# Any result that is not "success" is a failure condition
if [[ "$results" == *"failure"* ]] || \
[[ "$results" == *"cancelled"* ]] || \
[[ "$results" == *"skipped"* ]]; then
echo "One or more required jobs did not succeed: $results"
exit 1
fi
echo "All required jobs passed."
-15
View File
@@ -219,21 +219,6 @@ python -m molecule_agent verify-sha256 ./my-plugin-dir
shut the loop down cleanly. Cursor optionally persisted to `--cursor-file` so
restarts resume from the last-seen activity row.
- **`run_heartbeat_loop(stop_event)` and `run_agent_loop(stop_event)`** (KI-009):
Both loops accept an optional `threading.Event` parameter. When the event is set
from another thread, the loop exits immediately with return value `"stopped"`.
The check runs before `max_iterations` so a signal always wins. Useful for
embedding the client in a long-running process that needs a clean shutdown path:
```python
import threading, time
from molecule_agent import RemoteAgentClient
stop = threading.Event()
client = RemoteAgentClient(...)
# Signal-safe: call stop.set() from any thread to stop the loop
terminal = client.run_heartbeat_loop(stop_event=stop)
# terminal == "stopped" if stop.set() was called, else "paused"/"deleted"
```
---
## Relevant platform docs
+1 -1
View File
@@ -27,7 +27,7 @@ curl -s -X POST http://localhost:8080/workspaces/<UUID>/secrets \
# 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
python3 examples/remote-agent/run.py
```
You should see log lines for each of the three phases, and then
+6 -9
View File
@@ -54,16 +54,13 @@ secrets = client.pull_secrets()
client.install_plugin("molecule-dev")
client.install_plugin("my-plugin", source="github://acme/my-plugin")
# 4. Run the heartbeat + state-poll loop until the platform pauses/deletes us
# or until stop_event.set() is called from another thread.
import threading
stop = threading.Event()
terminal = client.run_heartbeat_loop(stop_event=stop)
# 4. Run the heartbeat + state-poll loop until the platform pauses/deletes us.
terminal = client.run_heartbeat_loop()
print(f"loop exited: {terminal}")
```
A runnable demo with full setup walkthrough lives at
[`sdk/python/examples/remote-agent/`](../examples/remote-agent).
[`examples/remote-agent/`](https://git.moleculesai.app/Molecule-AI/molecule-sdk-python/-/tree/main/examples/remote-agent) — the runnable demo with full setup walkthrough.
## What the SDK gives you
@@ -78,8 +75,8 @@ A runnable demo with full setup walkthrough lives at
| `call_peer(target, message)` | 30.6 | Direct A2A with proxy fallback; response may be wrapped in OFFSEC-003 boundary markers — use ``strip_a2a_boundary()`` to remove them |
| `fetch_inbound(since_id=…)` | 30.8c | One-shot poll of `/workspaces/:id/activity` for inbound A2A |
| `reply(msg, text)` | 30.8c | Smart-routes reply to `/notify` (canvas user) or `/a2a` (peer) |
| `run_heartbeat_loop(stop_event=None)` | combo | Drives heartbeat + state-poll on a timer; exits on pause/delete or when `stop_event.set()` is called from another thread (KI-009) |
| `run_agent_loop(handler, stop_event=None)` | combo | Heartbeat + state + **inbound dispatch**; exits on pause/delete or when `stop_event.set()` is called from another thread (KI-009) |
| `run_heartbeat_loop()` | combo | Drives heartbeat + state-poll on a timer; exits on pause/delete |
| `run_agent_loop(handler)` | combo | Heartbeat + state + **inbound dispatch**; exits on pause/delete |
## Inbound delivery — push vs poll
@@ -285,5 +282,5 @@ the security benefits of bearer auth until both sides upgrade.
- [`molecule_plugin`](../molecule_plugin) — the *other* SDK in this
package, for plugin authors. Different audience.
- [`sdk/python/examples/remote-agent/run.py`](../examples/remote-agent/run.py)
- [`examples/remote-agent/run.py`](https://git.moleculesai.app/Molecule-AI/molecule-sdk-python/-/blob/main/examples/remote-agent/run.py)
— the runnable demo that proves all of the above end-to-end.
+2 -4
View File
@@ -9,7 +9,6 @@ and detect pause/resume/delete — all via the Phase 30.130.5 HTTP contract.
Intended usage::
import threading
from molecule_agent import RemoteAgentClient
client = RemoteAgentClient(
@@ -19,10 +18,9 @@ Intended usage::
)
client.register() # mints + persists the auth token
env = client.pull_secrets() # decrypted secrets dict
stop = threading.Event()
client.run_heartbeat_loop(stop_event=stop) # background heartbeat; stop.set() to exit cleanly
client.run_heartbeat_loop() # background heartbeat + state-poll
See ``sdk/python/examples/remote-agent/`` for a runnable demo.
See ``examples/remote-agent/`` for a runnable demo.
Design notes:
* **No async.** The SDK uses blocking ``requests`` so a remote agent author
+13 -4
View File
@@ -11,10 +11,19 @@ a Phase 30 endpoint:
* :py:meth:`run_heartbeat_loop` — drives heartbeat + state-poll on a timer,
returns when the platform reports the workspace paused or deleted.
No inbound A2A server is bundled here yet — that requires hosting an HTTP
endpoint the platform's proxy can reach, which is network-dependent.
Use :class:`molecule_agent.a2a_server.A2AServer` to add inbound A2A support.
See that module for usage and the Phase 30.8b contract.
The client also exposes two inbound delivery paths for handling platform-initiated
A2A messages:
* **Push mode** — :class:`molecule_agent.a2a_server.A2AServer` hosts an HTTP server
in a background thread; platform pushes inbound A2A as HTTP requests. Use when the
agent has a publicly reachable URL (cloud VM, ngrok tunnel, etc.).
* **Poll mode** — :class:`molecule_agent.inbound.PollDelivery` polls
``GET /workspaces/:id/activity`` on a configurable interval; no public URL required.
The default when no explicit delivery is passed to :py:meth:`run_agent_loop`.
Both feed the same :py:class:`molecule_agent.inbound.MessageHandler` callback.
Reply routing (``/notify`` for canvas users, ``/a2a`` for peer agents) is handled
automatically by :py:meth:`reply`.
"""
from __future__ import annotations
+1 -1
View File
@@ -26,7 +26,7 @@ Example: a minimal plugin that's installable on Claude Code and DeepAgents
├── claude_code.py # `from molecule_plugin import AgentskillsAdaptor as Adaptor`
└── deepagents.py # same one-liner
Full docs + cookiecutter template: see ``sdk/python/README.md``.
Full docs + cookiecutter template: see the repo root ``README.md``.
"""
from __future__ import annotations