fix: address PR review for LLM hardening and API Docker import - #39
Closed
omakszewska wants to merge 4 commits into
Closed
fix: address PR review for LLM hardening and API Docker import#39omakszewska wants to merge 4 commits into
omakszewska wants to merge 4 commits into
Conversation
omakszewska
force-pushed
the
cypher-hardening
branch
2 times, most recently
from
May 16, 2026 19:03
af74e0d to
0620c3d
Compare
omakszewska
force-pushed
the
cypher-hardening
branch
from
May 16, 2026 19:09
f45bccb to
4f6692c
Compare
Contributor
Author
|
Superseded by the unified PR on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review follow-up (fix: address PR review)
src/config/messages.py(fix API image import)accurate_modelfor Cypher,fast_modelfor guardrailsThis PR improves safety and reliability in the knowledge-graph RAG pipeline:
Cypher write-operation guardrail
Validates generated Cypher before Neo4jGraph.query().
Blocks mutation keywords such as CREATE, MERGE, DELETE, DETACH, SET, REMOVE, and DROP.
Strips comments first and inspects uppercase tokens, so unsafe queries fail before execution with a controlled error.
LLM call timeouts
Adds explicit timeout values to LangChain LLM clients (BaseChatOpenAI / ChatGoogleGenerativeAI).
Wraps async pipeline entry points with asyncio.wait_for() so a single request cannot hang indefinitely.
Uses a separate wall-clock budget for the full LangGraph run where applicable.
LLM retry with exponential backoff
Wraps chain.invoke() / chain.ainvoke() used by generate_cypher and guardrails_system with Tenacity.
Uses 3 attempts with exponential backoff and jitter for transient failures such as rate limits and temporary API errors.
Provider fallback is intentionally left as follow-up TODO; startup-time provider selection remains unchanged.
Guardrail output as strict JSON
Guardrail prompt now requires strict JSON output: {decision: generate_cypher} or {decision: end}.
Parser strips optional code fences, extracts JSON from noisy text, parses it safely, and normalizes decisions via aliases.
Parse failures default to end, keeping LangGraph routing aligned with guardrail_decision.