Side Effects and Isolation

Side Effects and Isolation

Handling dangerous operations.

Side Effects and Isolation

A function has a "side effect" if it interacts with the outside world (Database, API, File System).

Idempotency

Ideally, tools should be idempotent.

  • read_file() is safe to run 10 times.
  • append_to_file() is NOT. If the graph retries, you duplicate the content.

Isolation Layers

Wrap side-effect tools in an "Execution Layer" node. When testing, you can swap this node for a "Mock Node" that just logs "I would have sent an email" without actually sending it. This allows you to test the logic of the graph without spamming users.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn