NVIDIA-NeMo / NVIDIA-NeMo/Guardrails

refactor: self-check hallucination context bindings

Open
#2,274 0 comments 0 reactions 1 assignee View on GitHub

@tgasser-nv is already working on this.

Since Aug 12, 2026.

refactoring status: needs triage
Dominant language
Python
Stars
7.2k
Forks
842
Avg merge
3d 1h
Merged PRs (30d)
25

Description

Required checks
  • I searched existing issues and pull requests for related refactor proposals.
  • I understand that opening this issue does not mean a refactor PR will be accepted.
  • I understand that a refactor PR should not be opened unless a maintainer approves the plan and assigns the work.
Problem

Copy-pasted discussion from #2253 prior to merging

This is a gap in the Manifest definition. Without looking at the self_check_hallucination() code you can't tell which keys of context are going to be used in the action.

The answer seems to be to declare two Binding.context() variables, one for bot_message and one for _last_bot_prompt. And then change the signature of self_check_hallucination() to take these directly rather than pull them out of the context dict. Also the last_bot_prompt is created by generate_bot_message() which is a Colang-only function.

The activefence rail does this and uses a RailSurface to pull out either user_message or bot_message dependeing on the name of the rail.

Fixing this problem would be a self-contained update of the self check hallucination rail to declare proper bindings and route them through at runtime rather than just context.

Proposed direction

Rewrite the self-check hallucination to use named arguments rather than puling them out of a flat dict. Need to add helper to generate last_bot_prompt outside of Colang

Migration and compatibility notes

Rewrite atomically in a single PR

Validation plan

Validate with sample prompts which contain hallucination and don't

Risks

Low - limited to just a single rail

Relevant branch or files

No response

Are you interested in helping after maintainer approval?

I am only proposing this for maintainer consideration.

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.