Control sessions and call RPC¶
A control attach lets application code interact with named nodes in a running session. Use it for transcript taps, context injection, debugging, node state changes, and exposed RPC methods.
Attach locally or remotely¶
Use attach_inproc(session) with an FFI streaming session, or attach(address, session_id=...) with a compatible gRPC service. For Scaling, follow the Entry setup requirements.
Run the self-contained local example after installation:
The example creates an echo session, subscribes, publishes hello, and prints the tapped text. It closes the iterator, attach, and session. The main operation is:
import asyncio
from remotemedia.control import attach_inproc
async def tap_echo(session):
async with attach_inproc(session) as ctrl:
tap = await ctrl.subscribe("echo.out")
try:
await ctrl.publish("echo.in", "hello")
item = await asyncio.wait_for(anext(tap), timeout=5)
print(item.text)
finally:
await tap.aclose()
subscribe() is awaited to obtain an async iterator. Subscribe before publishing if you need to observe that publication. These are live taps, not a history query.
Choose an operation¶
The table below describes the reviewed checkout. The tested release client supports the local subscribe/publish example; input taps, output publication, metadata keywords, and endpoint hosting require newer checkout APIs. Check availability before using them in a release environment.
| Task | API | Meaning |
|---|---|---|
| Observe a node's output | await ctrl.subscribe("node.out") |
Returns an async iterator of Data |
| Observe a node's input | await ctrl.subscribe_in("node.in") |
Input-side tap |
| Inject input | await ctrl.publish("node.in", data) |
Accepts a Data wrapper or text string |
| Inject attributed input | ctrl.publish(..., metadata=...) |
Accepts metadata; see the tested input-tap limitation |
| Publish to output subscribers | await ctrl.publish_out("node.out", data) |
Control-bus delivery to output taps; does not enqueue downstream graph execution |
| Inspect/edit/drop output | ctrl.intercept(...) |
Interception has a deadline and decision contract |
| Change processing state | ctrl.set_node_state(...), ctrl.clear_node_state(...) |
Explicit state override and reset |
| Expose application callbacks | ctrl.host_endpoint(...) |
Application-owned endpoint lifecycle |
Named ports extend the address, for example llm.in.context. The target graph must expose the corresponding node/port. Unknown nodes, invalid address directions, missing sessions, and remote authorization failures are separate error conditions.
Call a node method¶
Worker nodes can expose methods with remotemedia.rpc.rpc. @rpc(reply=True) declares a result-bearing method; streamed and fire-and-forget modes have different contracts. An attached client resolves node proxies through ctrl.<node_id>.
For a node named formatter that actually exposes a reply method named describe, an application excerpt is:
This is illustrative, not a method supplied by PassThrough. The node example exposes its own describe() method and exercises it through a real worker in the checkout environment. That check confirms the configured prefix and a process ID different from the host. RPC results follow the RPC reply protocol and should not be treated as ordinary media output.
Go deeper¶
Use session control for downstream intercept effects and node-state checks, and RPC and application tools for complete worker RPC and endpoint examples.
Own the lifecycle¶
The control context closes its transport and proxies; closing the attach does not close the pipeline. Close tap/stream iterators when exiting early. Handle timeouts and cancellation at the call boundary, and keep slow consumer work off a high-volume observation path.
Transport capabilities differ. For example, endpoints() exposes richer details in-process than over gRPC. Use per-operation reference pages before assuming equivalent behavior across a local session and Scaling.
Source references: remotemedia-sdk/clients/python/remotemedia/control/client.py · remotemedia-sdk/clients/python/remotemedia/control/data.py · remotemedia-sdk/clients/python/remotemedia/control/transport.py · remotemedia-sdk/clients/python/remotemedia/rpc.py · remotemedia-sdk/clients/python/remotemedia/control/rpc_proxy.py (base revision; reviewed with local changes) · remotemedia-scaling/crates/entry/src/control.rs