Skip to content

Fix: target agent component when updating chat flow system prompt#1781

Open
Vchen7629 wants to merge 6 commits into
langflow-ai:mainfrom
Vchen7629:agent-system-instruction-update-fix
Open

Fix: target agent component when updating chat flow system prompt#1781
Vchen7629 wants to merge 6 commits into
langflow-ai:mainfrom
Vchen7629:agent-system-instruction-update-fix

Conversation

@Vchen7629

@Vchen7629 Vchen7629 commented Jun 5, 2026

Copy link
Copy Markdown

Summary

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:

  • Updated update_chat_flow_system_prompt to use AGENT_COMPONENT_DISPLAY_NAME as the target component
  • Added unit tests verifying the value is written to the Agent component in the flow

Summary by CodeRabbit

  • Improvements

    • Simplified system prompt updates for Langflow flows.
  • Tests

    • Added unit tests to verify system prompt functionality in Langflow flows.

@github-actions github-actions Bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests community labels Jun 5, 2026
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place.

Review Change Stack

Walkthrough

The PR simplifies system prompt updates for the Langflow Agent by removing provider-specific targeting. The FlowsService.update_chat_flow_system_prompt method removes its provider parameter and always targets the Agent node by fixed display name. The caller in langflow_sync.py is updated to stop deriving and passing the provider. New tests verify the Agent node structure and confirm the PATCH request correctly updates the system prompt field.

Changes

Agent System Prompt Update

Layer / File(s) Summary
Service contract and implementation
src/services/flows_service.py
update_chat_flow_system_prompt removes the provider parameter and always targets AGENT_COMPONENT_DISPLAY_NAME instead of deriving the target component ID from the provider.
Sync caller update
src/api/settings/langflow_sync.py
_update_langflow_system_prompt no longer derives or passes llm_provider to the service method, calling update_chat_flow_system_prompt with only the system prompt.
Agent node verification tests
tests/unit/test_langflow_agent_system_prompt.py
Test helpers load flow JSON and locate nodes by display name. Tests verify the Agent node contains a system_prompt field and that PATCH updates write the new prompt to template.system_prompt.value.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • langflow-ai/openrag#1742: Both PRs intersect on the Langflow openrag_agent.json Agent node/template, where this PR changes how system_prompt is PATCH-updated (and adds tests validating that path), while the retrieved PR substantially refreshes the embedded Agent component implementation in that same flow.

Suggested labels

bug

Suggested reviewers

  • edwinjosechittilappilly
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: targeting the agent component instead of the LLM provider when updating the system prompt.
Linked Issues check ✅ Passed The PR successfully addresses issue #1514 by fixing the system prompt update to target the Agent component instead of the LLM provider, which resolves the bug where agent instructions were not being applied to Langflow flows.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the system prompt update mechanism and adding comprehensive tests; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread src/services/flows_service.py
@Wallgau Wallgau self-requested a review June 6, 2026 11:32

@Wallgau Wallgau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) community tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Updating Agent Instructions in settings doesn't have any effect

2 participants