fix: target agent component when updating chat flow system prompt#2001
fix: target agent component when updating chat flow system prompt#2001Vchen7629 wants to merge 6 commits into
Conversation
… of provider LLM component Signed-off-by: vchen7629 <[email protected]>
Signed-off-by: vchen7629 <[email protected]>
Signed-off-by: vchen7629 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
WalkthroughThe chat settings path now updates Langflow through the Agent node directly, without passing a provider. New tests verify the flow contains an Agent node with ChangesSystem prompt update fix
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/test_langflow_agent_system_prompt.py (1)
8-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRelative flow path depends on process cwd.
_load_flowresolves"flows/openrag_agent.json"relative to the current working directory rather than the repository root or test file location. If pytest is invoked from a different directory, both tests will fail withFileNotFoundError.♻️ Suggested fix: resolve path relative to test file
+from pathlib import Path + +_REPO_ROOT = Path(__file__).resolve().parents[2] + + def _load_flow(flow_path: str) -> dict: """Load a Langflow flow JSON file from the given path.""" - return json.loads(Path(flow_path).read_text(encoding="utf-8")) + return json.loads((_REPO_ROOT / flow_path).read_text(encoding="utf-8"))Also applies to: 27-27, 43-43
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/test_langflow_agent_system_prompt.py` around lines 8 - 10, The helper _load_flow currently reads the flow JSON using a path that depends on the process working directory, so tests can break when pytest runs elsewhere. Update _load_flow in test_langflow_agent_system_prompt.py to resolve the flow path relative to the test file or repository root before calling Path.read_text, and make sure the two tests that use openrag_agent.json keep using that resolved path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/test_langflow_agent_system_prompt.py`:
- Around line 8-10: The helper _load_flow currently reads the flow JSON using a
path that depends on the process working directory, so tests can break when
pytest runs elsewhere. Update _load_flow in test_langflow_agent_system_prompt.py
to resolve the flow path relative to the test file or repository root before
calling Path.read_text, and make sure the two tests that use openrag_agent.json
keep using that resolved path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f7fc59d0-5364-4b86-8f5e-e329b83a352b
📒 Files selected for processing (3)
src/api/settings/langflow_sync.pysrc/services/flows_service.pytests/unit/test_langflow_agent_system_prompt.py
…gent_system_prompt Signed-off-by: vchen7629 <[email protected]>
Summary
Port of PR #1918 to target main, Fixes #1514. update_chat_flow_system_prompt was targeting the LLM provider component (e.g. "Ollama", "WatsonX") instead of the Agent component where the system_prompt field lives. As a result, saving new agent instructions in OpenRAG settings never updates langflow
Changes:
Summary by CodeRabbit
Bug Fixes
system_prompt, improving consistency.Tests
system_prompttemplate and that update requests send the correct PATCH payload reflecting the new prompt.