NVIDIA-NeMo / NVIDIA-NeMo/Guardrails

bug: missing "global $relevant_chunks" declaration in hf_classifier retrieval flows

Open
#2,172 1 comment 0 reactions 1 assignee View on GitHub

@Pouyanpi is already working on this.

Since Jul 15, 2026.

Dominant language
Python
Stars
7.2k
Forks
843
Avg merge
3d 1h
Merged PRs (30d)
25

Description

Describe the bug

In the hf classifier check retrieval flow (Colang), the masked/transformed $relevant_chunks value is reassigned locally without a global declaration, so the transformation does not propagate outside the flow's local scope. This affects:

  • nemoguardrails/library/hf_classifier/flows.co (lines 24-25, flow hf classifier check retrieval $classifier)
  • nemoguardrails/library/hf_classifier/flows.v1.co (matching retrieval subflow)

This is a pre-existing bug, unrelated to the RailOutcome migration in PR #2151, surfaced during review there.

Steps To Reproduce
  1. Configure a rail using hf classifier check retrieval with a classifier that triggers a transform (is_transform=True) on $relevant_chunks.
  2. Observe that $relevant_chunks = $response.transform_text["relevant_chunks"] is assigned without global $relevant_chunks.
  3. Check downstream flow/action usage of $relevant_chunks after this subflow returns.
Expected Behavior

The transformed $relevant_chunks value should be visible to the calling flow/context after the subflow completes, since it's meant to update the shared retrieval context.

Actual Behavior

Because global $relevant_chunks is not declared before reassignment, the transform assignment stays scoped to the local flow and does not propagate to the caller/global context, so callers may still see the pre-transform value.

References
Acceptance Criteria
  • Add global $relevant_chunks before the reassignment in flows.co and flows.v1.co retrieval transform branches.
  • Add/adjust a test confirming the transformed $relevant_chunks propagates to the caller context.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.