Skip to content
Merged
Changes from 1 commit
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
22 changes: 9 additions & 13 deletions RAGManager/app/agents/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ def create_agent_graph() -> StateGraph:
"guard",
route_after_guard,
{
"malicious": END, # End with error if malicious
"continue": "fallback_inicial", # Continue to fallback_inicial if valid
"malicious": "fallback_inicial", # go to fallback_inicial if malicious
"continue": "parafraseo", # Continue to parafraseo if valid
},
)

# fallback_inicial -> parafraseo
workflow.add_edge("fallback_inicial", "parafraseo")

# parafraseo -> retriever
workflow.add_edge("parafraseo", "retriever")

Expand All @@ -77,17 +74,16 @@ def create_agent_graph() -> StateGraph:
# Note: Primary LLM is called within context_builder node
workflow.add_edge("context_builder", "generator")

# generator -> fallback_final
workflow.add_edge("generator", "fallback_final")
# generator -> guard
workflow.add_edge("generator", "guard")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

# fallback_final -> conditional routing
# guard -> conditional routing
workflow.add_conditional_edges(
"fallback_final",
route_after_fallback_final,
"guard",
route_after_guard,
{
"risky": END, # End with error if risky
"continue": END, # End with final_response if valid
# Note: Final LLM is called within fallback_final node
"malicious": "fallback_inicial", # go to fallback_final if malicious
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "go to fallback_final if malicious" but the code routes to "fallback_inicial". Based on the PR description indicating the second guard should route to fallback_final if malicious, this appears to be a copy-paste error. The routing should likely be to "fallback_final" not "fallback_inicial".

Suggested change
"malicious": "fallback_inicial", # go to fallback_final if malicious
"malicious": "fallback_final", # go to fallback_final if malicious

Copilot uses AI. Check for mistakes.
"continue": END, # if there's no error ends
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment contains a grammatical error. It should read "if there's no error, ends" or better yet "End if no error is detected".

Suggested change
"continue": END, # if there's no error ends
"continue": END, # End if no error is detected

Copilot uses AI. Check for mistakes.
},
)
Comment on lines 72 to 79
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate conditional edge definition for the "guard" node. Lines 58-65 already define conditional edges for "guard" with route_after_guard. In LangGraph, adding a second conditional edge to the same node will overwrite the first one, meaning the routing defined at lines 58-65 will be ignored and only this second definition will be active. This creates a logical error where the workflow cannot reach the parafraseo node at all, since the first guard check is effectively removed.

Copilot uses AI. Check for mistakes.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment on lines +68 to 79
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The graph has two conditional edges from the 'guard' node (lines 53-60 and 72-79), but the workflow uses the same guard node for both inicial and final validation. This creates conflicting routing logic. The second guard should be a separate node called 'guard_final' to validate the generated response for PII, as indicated by the guard_final.py file that was created but never integrated into the graph.

Copilot uses AI. Check for mistakes.

Expand Down