Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions nemoguardrails/rails/llm/llmrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ def _prepare_model_kwargs(self, model_config):
Returns:
dict: The prepared kwargs for model initialization
"""
kwargs = model_config.parameters or {}
# Make a copy to avoid modifying the original model config
kwargs = dict(model_config.parameters) if model_config.parameters else {}

# If the optional API Key Environment Variable is set, add it to kwargs
if model_config.api_key_env_var:
Expand Down Expand Up @@ -651,7 +652,9 @@ def _get_events_for_messages(self, messages: List[dict], state: Any):
user_message = prev_msg["content"]
break

if user_message:
# If tool input rails are configured, process tool messages even without user message
# This allows standalone tool message validation (e.g., in MCP gateway scenarios)
if user_message or self.config.rails.tool_input.flows:
# If tool input rails are configured, group all tool messages
if self.config.rails.tool_input.flows:
# Collect all tool messages for grouped processing
Expand Down
Loading
Loading