setters = [s for s in group if s[0].id.endswith(CONTEXT_CONFIG_SUFFIX_SET)]
        for dep in deps_by_key[key]:
            if key in deps_by_key[dep]:
                raise ValueError(
                    f"Deadlock detected between context keys {key} and {dep}"
                )
        if len(getters) < 1:
            raise ValueError(f"Expected at least one getter for context key {key}")
        if len(setters) != 1:
            raise ValueError(f"Expected exactly one setter for context key {key}")
        setter_idx = setters[0][1]
        if any(getter_idx < setter_idx for _, getter_idx in getters):
            raise ValueError(
                f"Context setter for key {key} must be defined after all getters."
            )
        context_funcs[getters[0][0].id] = partial(getter, events[key], values)
        context_funcs[setters[0][0].id] = partial(setter, events[key], values)
    return patch_config(config, configurable=context_funcs)
[docs]def aconfig_with_context(
    config: RunnableConfig,
    steps: List[Runnable],
) -> RunnableConfig:
    return _config_with_context(config, steps, _asetter, _agetter, asyncio.Event)
[docs]def config_with_context(
    config: RunnableConfig,
    steps: List[Runnable],
) -> RunnableConfig:
    return _config_with_context(config, steps, _setter, _getter, threading.Event)
[docs]class ContextGet(RunnableSerializable):
    prefix: str = ""
    key: Union[str, List[str]]
    @property
    def ids(self) -> List[str]:
        prefix = self.prefix + "/" if self.prefix else ""