crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG]: HITL pre-review fails open and silently bypasses automated safeguards

Open hello-args opened this issue 6 months ago • 1 comments

Description

When @human_feedback(..., learn=True) is used and lessons are recalled, _pre_review_with_lessons attempts to apply those lessons via an LLM before presenting output for human feedback.

If any exception occurs in this path (for example network or auth failure, LLM error, or structured-output issues), the implementation catches all exceptions and returns the original method_output.

As a result:

  • No exception is propagated
  • No warning or error is logged (in this except block)
  • The flow continues normally
  • Callers cannot distinguish between:
    • pre-reviewed output
    • raw model output

This creates a silent fallback: the pre-review step may not have executed, but downstream components are not informed.

Steps to Reproduce

  1. Define a Flow with memory enabled and a method decorated with @human_feedback(learn=True, ...).
  2. Ensure at least one lesson exists in memory (for example run once with learn=True to store feedback).
  3. On a subsequent run, force the pre-review LLM call to fail, for example by patching the LLM call used inside _pre_review_with_lessons to raise:
    RuntimeError("simulated pre-review failure")
    
  4. Run kickoff() or kickoff_async().
  5. Observe:
    • No exception is raised
    • The value passed to human feedback is the raw method_output
    • No visible signal that pre-review failed

Expected behavior

If pre-review fails, the system should not silently behave the same as a successful pre-review.

Any of the following would improve correctness and observability:

  • Fail closed: propagate the exception
  • Explicit degradation:
    • log at warning or error with exc_info=True
    • emit a structured signal or event
    • or return metadata such as pre_review_applied=False

Screenshots/Code snippets

Failure path (lib/crewai/src/crewai/flow/human_feedback.py):

except Exception:
    return method_output  # fallback to raw output on any failure

Other paths that return raw output without LLM pre-review:

if mem is None:
    return method_output

if not matches:
    return method_output

Docs reference

  • docs/en/learn/human-feedback-in-flows.mdx — section “Graceful degradation” describes falling back to raw output without blocking the flow.

Operating System

macOS Big Sur

Python Version

3.12

crewAI Version

Latest main (as of May 2026)

crewAI Tools Version

Latest / N/A

Virtual Environment

Venv

Evidence

  • Pre-review failures do not raise exceptions
  • No logging at warning or error level in this path
  • Returned output is indistinguishable from raw method_output
  • Downstream systems cannot detect whether pre-review actually ran

Possible Solution

  • Replace broad except Exception: with narrower handling where possible
  • For unexpected failures:
    • log with logger.warning(..., exc_info=True) or logger.error(..., exc_info=True)
    • optionally re-raise after logging
  • Consider returning structured metadata (for example pre_review_applied=False)
  • Optional strict mode (for example learn_strict=True) to fail on pre-review errors instead of silently substituting raw output

Additional context

  • Scoped only to the learn=True pre-review step.
  • The human feedback step still runs afterward in normal use.
  • The concern is that the automated pre-review layer may silently not run, with no signal to the caller.
  • Other behaviors (outcome collapse, resume emit fallback, listener failures) are out of scope for this issue.

hello-args avatar May 06 '26 04:05 hello-args

Hi, I'm Dexing Liu from Qijing Digital Technology. We've been building the Agent Delivery Engineering (ADE) Failure Registry — a curated, cross-architecture knowledge base of AI agent failure patterns, organized by a five-layer taxonomy (Channel → Observability → Data → Cognitive → Behavior).

ADE (Agent Delivery Engineering) is an engineering discipline focused on stability forces in AI agent systems — the engineering movement of humans against intelligence entropy.

Your report here has been documented as a case study in our registry — it's an excellent example of the failure pattern it describes, and we've credited you as the discoverer.

We're actively collecting and classifying similar failures across all agent frameworks (Hermes, CrewAI, AutoGen, LangChain, etc.) to build a comprehensive reference for the community. If you have more cases or would like to contribute, we'd love your help:

  • Registry: https://github.com/ADE-standard/ade-failure-registry
  • How to contribute: https://github.com/ADE-standard/ade-failure-registry/blob/main/CONTRIBUTING.md

Thanks for the detailed report — it's helping make agent systems more reliable for everyone.

tobiglevent001 avatar Jun 18 '26 01:06 tobiglevent001