Skip to content

Commit 28bacb9

Browse files
committed
fix v3
1 parent 0e73056 commit 28bacb9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/agents/wizard_workflow/nodes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import hashlib
23

34
from langchain_core.messages import AIMessage
45

@@ -175,7 +176,16 @@ def input_guardrails_node(state: WizardState):
175176

176177
lowered = cleaned.lower()
177178
if any(pattern in lowered for pattern in GUARDRAIL_BLOCK_PATTERNS):
178-
logger.warning("[WIZARD/guardrails] Possible prompt-injection-like answer blocked")
179+
msg_preview = cleaned[:64]
180+
msg_hash = hashlib.sha256(cleaned.encode("utf-8")).hexdigest()[:12]
181+
logger.warning(
182+
"[WIZARD/guardrails] Possible prompt-injection-like answer blocked "
183+
"session_id=%s current_question=%s msg_preview=%r msg_hash=%s",
184+
state.get("wizard_session_id"),
185+
current_q,
186+
msg_preview,
187+
msg_hash,
188+
)
179189
return {
180190
**state,
181191
"messages": [

app/agents/wizard_workflow/wizard_graph.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def should_ask_or_store(state: WizardState) -> str:
5858

5959
def should_store_after_guardrails(state: WizardState) -> str:
6060
is_valid = state.get("valid") is True
61-
decision = "store_answer" if is_valid else "finish"
61+
if is_valid:
62+
decision = "store_answer"
63+
elif not state.get("awaiting_answer", False):
64+
decision = "ask_question"
65+
else:
66+
decision = "finish"
6267
logger.debug(f"[WIZARD_GRAPH] should_store_after_guardrails: valid={is_valid} -> {decision}")
6368
return decision
6469

@@ -103,6 +108,7 @@ def completion_message_node(state: WizardState):
103108
should_store_after_guardrails,
104109
{
105110
"store_answer": "store_answer",
111+
"ask_question": "ask_question",
106112
"finish": "finish",
107113
},
108114
)

0 commit comments

Comments
 (0)