diff --git a/bluesky_darkframes/__init__.py b/bluesky_darkframes/__init__.py
index ddb3fac..6603ab1 100644
--- a/bluesky_darkframes/__init__.py
+++ b/bluesky_darkframes/__init__.py
@@ -8,6 +8,7 @@ import event_model
 from frozendict import frozendict
 import bluesky.preprocessors
 import bluesky.plan_stubs as bps
+from bluesky.utils import short_uid
 import numpy
 from ophyd import Device
 
@@ -138,6 +139,9 @@ class _SnapshotShell:
         return getattr(self.__snapshot, key)
 
 
+GROUP_PREFIX = 'bluesky-darkframes-trigger'
+
+
 class DarkFramePreprocessor:
     """
     A plan preprocessor that ensures each Run records a dark frame.
@@ -312,18 +316,29 @@ class DarkFramePreprocessor:
                 # bluesky will always see the "Device" self._current_snapshot
                 # here, and it will be satisfied.
                 yield from bps.stage(self._current_snapshot)
-                yield from bps.trigger_and_read([self._current_snapshot],
-                                                name=self.stream_name)
+                yield from trigger_and_read(
+                    [self._current_snapshot],
+                    name=self.stream_name,
+                    group=short_uid(GROUP_PREFIX))
                 yield from bps.unstage(self._current_snapshot)
             self._latch = False
             if msg is not None:
                 return (yield msg)
 
         def maybe_insert_dark_frame(msg):
-            if msg.command == 'trigger' and msg.obj is self.detector and not self._latch:
+            # * Is this a 'trigger' message?
+            # * Does it refer to the detector that this preprocessor cares about?
+            # * Is it *not* from another DarkFramePreprocessor. (There can be
+            # multiple nested DarkFramePreprocessors watching the same detector
+            # by applying different dark_plans / recording Events in different
+            # streams.)
+            if (msg.command == 'trigger'
+                    and msg.obj is self.detector
+                    and not msg.kwargs['group'].startswith(GROUP_PREFIX)
+                    and not self._latch):
                 force_read = self._force_read_before_next_event
                 self._force_read_before_next_event = False
-                self._latch = True
+                self._latch = True  # prevents infinite recursion
                 return insert_dark_frame(force_read=force_read, msg=msg), None
             elif msg.command == 'open_run':
                 # Make sure we get a new Event because we have just started a
@@ -486,3 +501,56 @@ class NoDarkFrame(RuntimeError, BlueskyDarkframesException):
 
 class NoMatchingSnapshot(KeyError, BlueskyDarkframesException):
     ...
+
+
+# Vendored from bluesky.plan_stubs, added `group` parameter
+
+
+def trigger_and_read(devices, name='primary', group=None):
+    """
+    Trigger and read a list of detectors and bundle readings into one Event.
+
+    Parameters
+    ----------
+    devices : iterable
+        devices to trigger (if they have a trigger method) and then read
+    name : string, optional
+        event stream name, a convenient human-friendly identifier; default
+        name is 'primary'
+    group : string (or any hashable object), optional
+        identifier used by 'trigger' and 'wait'
+
+    Yields
+    ------
+    msg : Msg
+        messages to 'trigger', 'wait' and 'read'
+    """
+    # If devices is empty, don't emit 'create'/'save' messages.
+    if not devices:
+        yield from bps.null()
+    devices = bps.separate_devices(devices)  # remove redundant entries
+    rewindable = bps.all_safe_rewind(devices)  # if devices can be re-triggered
+
+    def inner_trigger_and_read():
+        nonlocal group
+        if group is None:
+            group = short_uid('trigger')
+        no_wait = True
+        for obj in devices:
+            if hasattr(obj, 'trigger'):
+                no_wait = False
+                yield from bps.trigger(obj, group=group)
+        # Skip 'wait' if none of the devices implemented a trigger method.
+        if not no_wait:
+            yield from bps.wait(group=group)
+        yield from bps.create(name)
+        ret = {}  # collect and return readings to give plan access to them
+        for obj in devices:
+            reading = (yield from bps.read(obj))
+            if reading is not None:
+                ret.update(reading)
+        yield from bps.save()
+        return ret
+    from bluesky.preprocessors import rewindable_wrapper
+    return (yield from rewindable_wrapper(inner_trigger_and_read(),
+                                          rewindable))
diff --git a/docs/source/usage.rst b/docs/source/usage.rst
index 7071e1a..cb89373 100644
--- a/docs/source/usage.rst
+++ b/docs/source/usage.rst
@@ -110,8 +110,10 @@ for whether/how dark frames can be reused.)
        yield from bps.unstage(detector)
        yield from bps.stage(detector)
        yield from bps.mv(shutter, 'closed')
-       yield from bps.trigger(detector, group='darkframe-trigger')
-       yield from bps.wait('darkframe-trigger')
+       # The `group` parameter passed to trigger MUST start with
+       # bluesky-darkframes-trigger.
+       yield from bps.trigger(detector, group='bluesky-darkframes-trigger')
+       yield from bps.wait('bluesky-darkframes-trigger')
        snapshot = bluesky_darkframes.SnapshotDevice(detector)
        yield from bps.mv(shutter, 'open')
        # Restage.

Support multiple DarkFramePreprocessors
I believe (but have not rigorously verified) that if two `DarkFramePreprocessors` are applied, they will interfere. The outer one will see the `trigger` messages added by the inner one, and try to take a dark frame for a dark frame (if that makes sense...).

We briefly tried this at CSX and that theory seemed to be correct; at least we can say for sure that trying two nested preprocessors failed.

The fix I have in mind is to let `DarkFramePreprocessors` recognize `trigger` messages that came from itself by using a special convention in the `group`---that is instead of `'trigger-<uuid>'`, do `'trigger-dark-frame-preprocessor-<uuid>'`. The content of the group has no meaning to any other part of our system.
diff --git a/bluesky_darkframes/tests/tests.py b/bluesky_darkframes/tests/tests.py
index 98ddcbb..31bf2ea 100644
--- a/bluesky_darkframes/tests/tests.py
+++ b/bluesky_darkframes/tests/tests.py
@@ -21,7 +21,7 @@ def dark_plan(detector):
     yield from bps.unstage(detector)
     yield from bps.mv(shutter, 'closed')
     yield from bps.stage(detector)
-    yield from bps.trigger(detector, group='darkframe-trigger')
+    yield from bps.trigger(detector, group='bluesky-darkframes-trigger')
     yield from bps.wait('darkframe-trigger')
     snapshot = bluesky_darkframes.SnapshotDevice(detector)
     yield from bps.unstage(detector)
@@ -277,3 +277,19 @@ def test_no_dark_frames(RE, tmp_path):
 
     with pytest.raises(bluesky_darkframes.NoDarkFrame):
         RE(count([det]))
+
+
+def test_nested_preprocessors(RE):
+    N = 3
+    for i in range(N):
+        dark_frame_preprocessor = bluesky_darkframes.DarkFramePreprocessor(
+            dark_plan=dark_plan, detector=det, max_age=0,
+            stream_name=f'dark_{i}')
+        RE.preprocessors.append(dark_frame_preprocessor)
+
+    def verify_event_count(name, doc):
+        if name == 'stop':
+            for i in range(N):
+                assert doc['num_events'][f'dark_{i}'] == 3
+
+    RE(count([det], 3), verify_event_count)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest coverage flake8 codecov sphinx jupyter-sphinx matplotlib numpydoc sphinx-copybutton sphinx_rtd_theme bluesky >=1.6.0rc1 codecov coverage databroker flake8 ophyd scipy suitcase-tiff
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.16
appdirs==1.4.4
asciitree==0.3.3
asttokens==3.0.0
attrs==25.3.0
babel==2.17.0
beautifulsoup4==4.13.3
bleach==6.2.0
bluesky==1.13.1
-e git+https://github.com/bluesky/bluesky-darkframes.git@53808f1f4450c3e1ec65aa4c6f8e9a91949d602a#egg=bluesky_darkframes
bluesky-live==0.0.8
boltons==25.0.0
cachetools==5.5.2
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
cloudpickle==3.1.1
codecov==2.1.13
comm==0.2.2
contourpy==1.3.0
coverage==7.8.0
cycler==0.12.1
dask==2024.8.0
databroker==1.2.5
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
Deprecated==1.2.18
dnspython==2.7.0
doct==1.1.0
docutils==0.21.2
entrypoints==0.4
event-model==1.22.3
exceptiongroup==1.2.2
executing==2.2.0
fasteners==0.19
fastjsonschema==2.21.1
flake8==7.2.0
flexcache==0.3
flexparser==0.4
fonttools==4.56.0
frozendict==2.4.6
fsspec==2025.3.1
historydict==1.2.6
humanize==4.12.2
idna==3.10
imageio==2.37.0
imagesize==1.4.1
importlib_metadata==8.6.1
importlib_resources==6.5.2
iniconfig==2.1.0
intake==0.6.4
ipykernel==6.29.5
ipython==8.18.1
ipywidgets==8.1.5
jedi==0.19.2
Jinja2==3.1.6
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-sphinx==0.5.3
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
jupyterlab_widgets==3.0.13
kiwisolver==1.4.7
locket==1.0.0
MarkupSafe==3.0.2
matplotlib==3.9.4
matplotlib-inline==0.1.7
mccabe==0.7.0
mistune==3.1.3
mongoquery==1.4.2
msgpack==1.1.0
msgpack-numpy==0.4.8
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
networkx==3.2.1
numcodecs==0.12.1
numpy==2.0.2
numpydoc==1.8.0
opentelemetry-api==1.31.1
ophyd==1.10.0
packaging==24.2
pandas==2.2.3
pandocfilters==1.5.1
parso==0.8.4
partd==1.4.2
pexpect==4.9.0
pillow==11.1.0
PIMS==0.7
Pint==0.24.4
platformdirs==4.3.7
pluggy==1.5.0
prettytable==3.16.0
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycodestyle==2.13.0
pyflakes==3.3.1
Pygments==2.19.1
pymongo==4.11.3
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rpds-py==0.24.0
scipy==1.13.1
six==1.17.0
slicerator==1.1.0
snowballstemmer==2.2.0
soupsieve==2.6
Sphinx==7.4.7
sphinx-copybutton==0.5.2
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
stack-data==0.6.3
suitcase-mongo==0.7.0
suitcase-msgpack==0.3.0
suitcase-tiff==0.4.0
suitcase-utils==0.5.4
tabulate==0.9.0
tifffile==2024.8.30
tinycss2==1.4.0
tomli==2.2.1
toolz==1.0.0
tornado==6.4.2
tqdm==4.67.1
traitlets==5.14.3
typing_extensions==4.13.0
tzdata==2025.2
tzlocal==5.3.1
urllib3==2.3.0
wcwidth==0.2.13
webencodings==0.5.1
widgetsnbextension==4.0.13
wrapt==1.17.2
xarray==2024.7.0
zarr==2.18.2
zipp==3.21.0

name: bluesky-darkframes
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.16
      - appdirs==1.4.4
      - asciitree==0.3.3
      - asttokens==3.0.0
      - attrs==25.3.0
      - babel==2.17.0
      - beautifulsoup4==4.13.3
      - bleach==6.2.0
      - bluesky==1.13.1
      - bluesky-live==0.0.8
      - boltons==25.0.0
      - cachetools==5.5.2
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - click==8.1.8
      - cloudpickle==3.1.1
      - codecov==2.1.13
      - comm==0.2.2
      - contourpy==1.3.0
      - coverage==7.8.0
      - cycler==0.12.1
      - dask==2024.8.0
      - databroker==1.2.5
      - debugpy==1.8.13
      - decorator==5.2.1
      - defusedxml==0.7.1
      - deprecated==1.2.18
      - dnspython==2.7.0
      - doct==1.1.0
      - docutils==0.21.2
      - entrypoints==0.4
      - event-model==1.22.3
      - exceptiongroup==1.2.2
      - executing==2.2.0
      - fasteners==0.19
      - fastjsonschema==2.21.1
      - flake8==7.2.0
      - flexcache==0.3
      - flexparser==0.4
      - fonttools==4.56.0
      - frozendict==2.4.6
      - fsspec==2025.3.1
      - historydict==1.2.6
      - humanize==4.12.2
      - idna==3.10
      - imageio==2.37.0
      - imagesize==1.4.1
      - importlib-metadata==8.6.1
      - importlib-resources==6.5.2
      - iniconfig==2.1.0
      - intake==0.6.4
      - ipykernel==6.29.5
      - ipython==8.18.1
      - ipywidgets==8.1.5
      - jedi==0.19.2
      - jinja2==3.1.6
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - jupyter-client==8.6.3
      - jupyter-core==5.7.2
      - jupyter-sphinx==0.5.3
      - jupyterlab-pygments==0.3.0
      - jupyterlab-widgets==3.0.13
      - kiwisolver==1.4.7
      - locket==1.0.0
      - markupsafe==3.0.2
      - matplotlib==3.9.4
      - matplotlib-inline==0.1.7
      - mccabe==0.7.0
      - mistune==3.1.3
      - mongoquery==1.4.2
      - msgpack==1.1.0
      - msgpack-numpy==0.4.8
      - nbclient==0.10.2
      - nbconvert==7.16.6
      - nbformat==5.10.4
      - nest-asyncio==1.6.0
      - networkx==3.2.1
      - numcodecs==0.12.1
      - numpy==2.0.2
      - numpydoc==1.8.0
      - opentelemetry-api==1.31.1
      - ophyd==1.10.0
      - packaging==24.2
      - pandas==2.2.3
      - pandocfilters==1.5.1
      - parso==0.8.4
      - partd==1.4.2
      - pexpect==4.9.0
      - pillow==11.1.0
      - pims==0.7
      - pint==0.24.4
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - prettytable==3.16.0
      - prompt-toolkit==3.0.50
      - psutil==7.0.0
      - ptyprocess==0.7.0
      - pure-eval==0.2.3
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pygments==2.19.1
      - pymongo==4.11.3
      - pyparsing==3.2.3
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.2
      - pyzmq==26.3.0
      - referencing==0.36.2
      - requests==2.32.3
      - rpds-py==0.24.0
      - scipy==1.13.1
      - six==1.17.0
      - slicerator==1.1.0
      - snowballstemmer==2.2.0
      - soupsieve==2.6
      - sphinx==7.4.7
      - sphinx-copybutton==0.5.2
      - sphinx-rtd-theme==3.0.2
      - sphinxcontrib-applehelp==2.0.0
      - sphinxcontrib-devhelp==2.0.0
      - sphinxcontrib-htmlhelp==2.1.0
      - sphinxcontrib-jquery==4.1
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==2.0.0
      - sphinxcontrib-serializinghtml==2.0.0
      - stack-data==0.6.3
      - suitcase-mongo==0.7.0
      - suitcase-msgpack==0.3.0
      - suitcase-tiff==0.4.0
      - suitcase-utils==0.5.4
      - tabulate==0.9.0
      - tifffile==2024.8.30
      - tinycss2==1.4.0
      - tomli==2.2.1
      - toolz==1.0.0
      - tornado==6.4.2
      - tqdm==4.67.1
      - traitlets==5.14.3
      - typing-extensions==4.13.0
      - tzdata==2025.2
      - tzlocal==5.3.1
      - urllib3==2.3.0
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - widgetsnbextension==4.0.13
      - wrapt==1.17.2
      - xarray==2024.7.0
      - zarr==2.18.2
      - zipp==3.21.0
prefix: /opt/conda/envs/bluesky-darkframes

bluesky_darkframes/tests/tests.py::test_nested_preprocessors[False] bluesky_darkframes/tests/tests.py::test_nested_preprocessors[True]
bluesky_darkframes/tests/tests.py::test_one_dark_event_emitted[False] bluesky_darkframes/tests/tests.py::test_one_dark_event_emitted[True] bluesky_darkframes/tests/tests.py::test_disable[False] bluesky_darkframes/tests/tests.py::test_disable[True] bluesky_darkframes/tests/tests.py::test_mid_scan_dark_frames[False] bluesky_darkframes/tests/tests.py::test_mid_scan_dark_frames[True] bluesky_darkframes/tests/tests.py::test_max_age[False] bluesky_darkframes/tests/tests.py::test_max_age[True] bluesky_darkframes/tests/tests.py::test_locked_signals[False] bluesky_darkframes/tests/tests.py::test_locked_signals[True] bluesky_darkframes/tests/tests.py::test_locked_signals_event_output[False] bluesky_darkframes/tests/tests.py::test_locked_signals_event_output[True] bluesky_darkframes/tests/tests.py::test_limit[False] bluesky_darkframes/tests/tests.py::test_limit[True] bluesky_darkframes/tests/tests.py::test_non_colliding_uids[False] bluesky_darkframes/tests/tests.py::test_non_colliding_uids[True] bluesky_darkframes/tests/tests.py::test_streaming_export[False-None] bluesky_darkframes/tests/tests.py::test_streaming_export[False-0] bluesky_darkframes/tests/tests.py::test_streaming_export[False-100] bluesky_darkframes/tests/tests.py::test_streaming_export[True-None] bluesky_darkframes/tests/tests.py::test_streaming_export[True-0] bluesky_darkframes/tests/tests.py::test_streaming_export[True-100] bluesky_darkframes/tests/tests.py::test_no_dark_frames[False] bluesky_darkframes/tests/tests.py::test_no_dark_frames[True]
bluesky_darkframes/__init__.py docs/source/usage.rst
bluesky_darkframes/__init__.py docs/source/usage.rst