Skip to content

datarobot_genai.crewai.kickoff_storage

kickoff_storage

Disable crewai's kickoff-outputs SQLite storage for stateless serving.

crewai's Crew opens an on-disk SQLite db via _task_output_handler on every kickoff, using with sqlite3.connect(...) blocks that commit but never close -- so a long-lived nat dragent serve leaks fds until [Errno 24] Too many open files. It can't be disabled and only backs Crew.replay(), which we never use.

:func:neutralize_kickoff_storage swaps that handler for an in-process no-op so no further database connections are opened. It is applied to every crew built via :func:datarobot_genai.crewai.agent.datarobot_agent_class_from_crew. No stdlib monkeypatch, no crewai version pin.

neutralize_kickoff_storage

neutralize_kickoff_storage(crew: Crew) -> Crew

Replace a crew's kickoff-outputs handler with the no-op (in place).

Safe to call on any crew. If a future crewai release renames or drops the private _task_output_handler attribute, this degrades to a logged no-op instead of raising, leaving the crew functionally unchanged.

Source code in datarobot_genai/crewai/kickoff_storage.py
def neutralize_kickoff_storage(crew: Crew) -> Crew:
    """Replace a crew's kickoff-outputs handler with the no-op (in place).

    Safe to call on any crew. If a future crewai release renames or drops the
    private ``_task_output_handler`` attribute, this degrades to a logged no-op
    instead of raising, leaving the crew functionally unchanged.
    """
    if hasattr(crew, "_task_output_handler"):
        crew._task_output_handler = _NoOpTaskOutputHandler()  # type: ignore[assignment]
    else:
        logger.debug(
            "crew has no _task_output_handler attribute; kickoff-storage "
            "neutralization skipped (crewai layout changed)"
        )
    return crew