Skip to main content
Wraps a LangGraph node so that, after it runs, each event you extract from its result is sent to Aether with emit_delta. The node’s result is returned unchanged.

When to use it

Use wrap_node to report Deltas from LangGraph nodes without adding reporting code inside each node.

Signature

What you implement

wrap_node only sends what you give it. You write extract and workspace_revision for your use case.

extract

You decide, for each node:
  • Which events to report, and their names, e.g. "dependency.scan.completed".
  • What goes in each payload. Only what extract returns is sent.
  • How many Deltas to send: one, several (e.g. one per change applied), or none ([]), e.g. when the node produced nothing worth reporting.
Write extract defensively. An error raised inside it fails the node. For example, use result.get("findings", []), not result["findings"].

workspace_revision

You decide what “revision” means for your workspace: a git commit SHA, a document version, a run id, and so on. It is called once per node run, and all Deltas from that run share it.
The revision is read after the node runs. If the node changes the workspace (e.g. commits a fix), you get the new revision. To report the revision the node started from, store it in the state before the node runs and return it from there.

Returns

An async node that you add to the graph in place of fn.

Behavior

  • Runs fn, then calls extract(state, result).
  • Sends one Delta per (event, payload) pair.
  • Adds wall_ms (the node’s run time in milliseconds) to every payload.
  • Converts dataclasses in the payload to plain values with to_jsonable.
  • Delta failures never break the node: emit_delta fails open.
  • Errors raised by fn or extract still propagate.

Example

Running the node reports a summary.created Delta with the payload {"summary": "...", "wall_ms": 12}.