Skip to content

feat: update flows with agent with debug logs for chat history#10204

Merged
edwinjosechittilappilly merged 7 commits into
mainfrom
fix-templates-agents-add-logs
Oct 13, 2025
Merged

feat: update flows with agent with debug logs for chat history#10204
edwinjosechittilappilly merged 7 commits into
mainfrom
fix-templates-agents-add-logs

Conversation

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Oct 9, 2025

This pull request updates the metadata for the Instagram Copywriter.json starter project. The only change is an update to the code_hash value, which likely reflects a new version of the project's code.

  • Updated the code_hash field in the metadata section of Instagram Copywriter.json to reflect the latest code version.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 9, 2025

Walkthrough

Replaces and expands AgentComponent implementations across multiple starter project JSONs, adds a LanguageModelComponent to one template, updates several code_hash metadata values, changes one JSON’s code string encoding, adds a new frontend E2E test, and adds a chat history debug log in the core agent module.

Changes

Cohort / File(s) Summary
Agent + LLM overhaul (expanded implementation)
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json, .../Market Research.json, .../News Aggregator.json, .../Research Agent.json, .../Pokédex Agent.json, .../Search agent.json, .../Simple Agent.json, .../Invoice Summarizer.json
Replaces AgentComponent code with a larger implementation adding memory handling, structured JSON output paths, dynamic model/provider wiring, tool integration, enhanced error handling; Instagram also adds a LanguageModelComponent; some templates remove memory_inputs from public inputs.
Metadata-only updates
.../Price Deal Finder.json, .../SaaS Pricing.json, .../Social Media Agent.json, .../Youtube Analysis.json
Updates Agent component code_hash values; no functional code changes.
Encoding-only change
.../Nvidia Remix.json
Stores Agent code as an escaped string; code_hash updated; logic unchanged.
Frontend test addition
src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts
Adds E2E test covering Simple Agent with memory: configures template, runs 2-message interaction, asserts final output content; conditional on OPENAI_API_KEY.
Core agent logging
src/lfx/src/lfx/components/agents/agent.py
Adds debug log to output chat_history after memory retrieval in get_agent_requirements.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as UI/Starter Template
  participant Agent as AgentComponent
  participant LMC as LanguageModelComponent
  participant Prov as Model Provider
  participant Mem as MemoryStore
  participant Tools as Tools/CurrentDate
  participant LLM as LLM

  UI->>Agent: input_value, settings, schema?, tools?
  Agent->>Mem: retrieve chat_history/session data
  Mem-->>Agent: chat_history
  Agent->>Prov: build_config (provider, model, params)
  Prov-->>LMC: resolved model configuration
  LMC-->>Agent: LLM factory / instance
  Agent->>Tools: initialize toolkits (async)
  Agent->>LLM: run (system + user + memory prompts)
  alt structured JSON schema
    Agent->>LLM: request structured output
    LLM-->>Agent: candidate JSON
    Agent->>Agent: validate/parse (pydantic)
  else plain text
    LLM-->>Agent: message text
  end
  Agent-->>UI: response (text/JSON)
  opt error
    Agent-->>UI: raise/log error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

enhancement, size:XXL, lgtm

Suggested reviewers

  • ogabrielluiz
  • mfortman11
  • jordanrfrazier

Pre-merge checks and finishing touches

❌ Failed checks (1 error, 2 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error The PR introduces substantial updates to multiple agent starter templates along with an added debug log, and it also includes a new Playwright integration test (Simple Agent Memory.spec.ts) that exercises the revised Simple Agent flow to verify memory behavior end-to-end; the test contains concrete assertions (checking for “john doe”) and is not a placeholder. However, the project’s stated frontend naming convention is *.test.ts, while the new file uses .spec.ts, so it does not align with the required convention even though it otherwise targets the new functionality. Consequently, the custom check fails on the naming requirement despite appropriate coverage content. Please rename the new Playwright test file to follow the *.test.ts convention (e.g., SimpleAgentMemory.test.ts) so it complies with project guidelines; once renamed, the coverage provided by the test should satisfy the check.
Test Quality And Coverage ⚠️ Warning The PR’s primary functional changes revolve around overhauling multiple agent starter templates to fix chat memory behavior and adding a debug log hook, yet the only new automated coverage is a single Playwright spec that superficially exercises one template without asserting that stored memory is surfaced back to the user or that failure paths behave correctly across the other updated templates. There are no backend unit/integration tests ensuring template code properly handles memory, structured output, or error cases, and the frontend test does not validate negative scenarios or other flows touched by the PR, leaving significant portions of the new functionality untested. Consequently, test coverage is insufficient to gain confidence in the updated agent logic. Please supplement the PR with targeted backend tests for the updated agent behavior (including memory handling and error branches) and expand frontend coverage beyond a single happy-path scenario so the breadth of template changes is properly validated.
Test File Naming And Structure ⚠️ Warning The only new test is src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts, which is Playwright-based but the naming pattern ends with .spec.ts rather than the required .test.ts or .test.tsx, so it fails the stated frontend test naming convention even though the structure and scenarios appear well organized. Please rename the Playwright test file to use the .test.ts suffix (for example, Simple Agent Memory.test.ts) so it complies with the required frontend test naming pattern.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed Reviewed the newly added Playwright integration test (Simple Agent Memory.spec.ts) and found no mocking frameworks or stubbed dependencies; the test drives real UI interactions end-to-end, so there is no evidence of excessive or inappropriate mock usage in this PR.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title highlights adding debug logs for chat history, which is indeed part of this PR, but it omits the broader scope of extensive updates to multiple agent starter templates and the inclusion of a new integration test. While it does refer to a real aspect of the changes, it does not capture the main bulk of work performed. However, because it partially relates to the changeset, it passes the partial relevance criterion.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-templates-agents-add-logs

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.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 9, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 9, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 11%
10.94% (2890/26409) 4.56% (926/20272) 6.5% (372/5721)

Unit Test Results

Tests Skipped Failures Errors Time
1200 0 💤 0 ❌ 0 🔥 13.931s ⏱️

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.76%. Comparing base (60f78f0) to head (e5e0ba4).
⚠️ Report is 3 commits behind head on main.

❌ Your project status has failed because the head coverage (48.71%) is below the target coverage (55.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10204   +/-   ##
=======================================
  Coverage   24.76%   24.76%           
=======================================
  Files        1090     1090           
  Lines       40108    40108           
  Branches     5550     5550           
=======================================
  Hits         9934     9934           
  Misses      30003    30003           
  Partials      171      171           
Flag Coverage Δ
backend 48.71% <ø> (ø)
frontend 10.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Oct 9, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (11)
src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json (1)

906-924: Avoid logging full chat history

logger.debug(f"Chat history: {self.chat_history}") will dump user conversations into backend logs. Even at debug level, this risks leaking PII / sensitive content and violates our usual privacy posture. Drop the log or sanitize/mask before emitting.

src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json (1)

1327-1331: Avoid logging full chat history

logger.debug(f"Chat history: {self.chat_history}") will dump every prior user message into logs, which can contain sensitive/PII data. Even at debug level this is a compliance risk once debug logging is enabled in prod. Please remove the raw content from logs or mask/redact it (e.g., log counts/IDs only).

src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (1)

1405-1420: Strip chat history dump from template

This starter template now ships the same logger.debug(f"Chat history: {self.chat_history}") line, so every generated flow will emit full user conversations to logs. Please remove or sanitize that statement here as well to stay compliant once the core component is fixed.

src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json (1)

1723-1740: Remove chat transcript logging from this template

Same concern: the embedded AgentComponent code logs raw chat history. Please align this template with the sanitized implementation so flows derived from it don't leak conversation content.

src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json (1)

915-918: Do not log full chat history contents.

logger.debug(f"Chat history: {self.chat_history}") will dump entire conversations (potential PII) into logs. Even at debug level this is a compliance/privacy risk. Please remove it or replace with a safe, redacted metric (e.g., count of messages) gated behind an explicit opt-in.

src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (1)

1125-1128: Avoid logging raw chat transcripts.

logger.debug(f"Chat history: {self.chat_history}") emits the entire conversation to logs, which can include sensitive customer data. Replace this with a sanitized summary (e.g., length) or gate it behind a configurable opt-in before logging.

src/backend/base/langflow/initial_setup/starter_projects/Nvidia Remix.json (1)

846-850: Redact chat history before logging

logger.debug(f"Chat history: {self.chat_history}") will dump user conversations—including PII—into application logs. That's a compliance/privacy risk and can violate retention policies. Please drop the raw log or redact it (e.g., log counts/message IDs only).

src/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json (1)

1195-1210: Do not log full chat history content.

logger.debug(f"Chat history: {self.chat_history}") will emit every message in memory—including user prompts and potentially sensitive data—to our logs whenever debug logging is enabled. That’s a privacy/compliance risk and goes beyond “debug” utility. Please drop this line or replace it with a redacted/summary log that never prints raw conversation text.

src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (1)

1500-1515: Avoid dumping chat history into logs.

Here as well, logger.debug(f"Chat history: {self.chat_history}") prints every stored message verbatim. That exposes end-user conversations/PII in logs whenever debug is active. Please remove or sanitize this log before shipping.

src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json (1)

1035-1037: Avoid logging full chat transcripts

Dumping self.chat_history verbatim pushes every user message into our logs, which can easily include secrets or PII. That’s a compliance/privacy footgun even at debug level—debug pipelines often end up in central log storage. Please only log metadata (e.g., count) and keep the actual transcript out of the logs.

-        logger.debug(f"Chat history: {self.chat_history}")
+        history_count = len(self.chat_history) if isinstance(self.chat_history, list) else "unknown"
+        logger.debug("Chat history retrieved (count=%s)", history_count)
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (1)

2265-2326: Structured-output fallback fails for JSON arrays

When the agent returns a list (common for multi-item schemas) with any leading text, the fallback regex (r"\{.*\}") drops the entire payload, so build_structured_output_base exits with "Try setting an output schema" instead of validating the list. Please allow both objects and arrays in the fallback scan.

Apply this diff inside the embedded AgentComponent code:

-        json_pattern = r"\{.*\}"
+        json_patterns = [r"\{.*?\}", r"\[.*?\]"]
         schema_error_msg = "Try setting an output schema"
 
         # Try to parse content as JSON first
         json_data = None
         try:
             json_data = json.loads(content)
         except json.JSONDecodeError:
-            json_match = re.search(json_pattern, content, re.DOTALL)
-            if json_match:
-                try:
-                    json_data = json.loads(json_match.group())
-                except json.JSONDecodeError:
-                    return {"content": content, "error": schema_error_msg}
-            else:
-                return {"content": content, "error": schema_error_msg}
+            for pattern in json_patterns:
+                json_match = re.search(pattern, content, re.DOTALL)
+                if not json_match:
+                    continue
+                try:
+                    json_data = json.loads(json_match.group())
+                    break
+                except json.JSONDecodeError:
+                    continue
+            if json_data is None:
+                return {"content": content, "error": schema_error_msg}
🧹 Nitpick comments (2)
src/backend/base/langflow/initial_setup/starter_projects/Search agent.json (1)

1068-1068: Consider log verbosity for large chat histories.

The debug log logger.debug(f"Chat history: {self.chat_history}") directly logs the entire chat history object. If the chat history contains many messages or long message contents, this could produce very verbose logs that are difficult to read and may impact performance.

Consider one of these approaches:

  1. Log only the count and basic metadata:
logger.debug(f"Chat history: {len(self.chat_history)} messages")
  1. Use structured logging with truncation:
logger.debug(
    "Chat history retrieved",
    extra={
        "message_count": len(self.chat_history),
        "sample": self.chat_history[:2] if self.chat_history else []
    }
)
  1. Add a helper method to summarize chat history for logging:
logger.debug(f"Chat history summary: {self._summarize_chat_history()}")
src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts (1)

59-60: Consider more specific assertion selector.

The test uses getByTestId("div-chat-message").innerText() which retrieves the text from all chat messages, not just the assistant's final response. While this may work, it could lead to false positives if "john doe" appears in any message (including the user's input message).

Consider selecting specifically the last assistant message:

// Get all assistant messages and check the last one
const assistantMessages = await page
  .getByTestId("div-chat-message")
  .filter({ hasText: /AI|Assistant|Machine/ })  // or whatever identifies assistant messages
  .all();
const lastAssistantText = await assistantMessages[assistantMessages.length - 1].innerText();
expect(lastAssistantText.toLowerCase()).toContain("john doe");

Or if there's a specific test ID for assistant messages:

const finalText = await page
  .getByTestId("div-chat-message-ai")  // or similar
  .last()
  .innerText();
expect(finalText.toLowerCase()).toContain("john doe");
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d12bb50 and aaa00b3.

📒 Files selected for processing (15)
  • src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Nvidia Remix.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Search agent.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json (2 hunks)
  • src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts (1 hunks)
  • src/lfx/src/lfx/components/agents/agent.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx}: Frontend test files should be located in 'src/frontend/' and use '.test.{ts,tsx,js,jsx}' or '.spec.{ts,tsx,js,jsx}' extensions.
Test both sync and async code paths in frontend test files.
Mock external dependencies appropriately in frontend test files to isolate unit tests from external services.
Test error handling and edge cases in frontend test files.
Validate input/output behavior and test component initialization and configuration in frontend test files.
Each frontend test should have a clear description or comment explaining its purpose, especially for complex setups or mocks.

Files:

  • src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts
🧬 Code graph analysis (1)
src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts (2)
src/frontend/tests/utils/withEventDeliveryModes.ts (1)
  • withEventDeliveryModes (15-41)
src/frontend/tests/utils/await-bootstrap-test.ts (1)
  • awaitBootstrapTest (4-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (52)
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 38/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 37/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 34/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 40/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 36/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 31/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 39/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 29/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 35/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 32/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 25/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 33/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 28/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 30/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 27/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 26/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 24/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 22/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 23/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 21/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 19/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 17/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 18/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 20/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 12/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 15/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 16/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 13/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 14/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 11/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/40
  • GitHub Check: Lint Backend / Run Mypy (3.10)
  • GitHub Check: Test Docker Images / Test docker images
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Test Starter Templates
  • GitHub Check: test-starter-projects
  • GitHub Check: Optimize new Python code in this PR
  • GitHub Check: Update Starter Projects
🔇 Additional comments (3)
src/backend/base/langflow/initial_setup/starter_projects/Search agent.json (1)

899-899: LGTM!

The code_hash update correctly reflects the updated AgentComponent code below.

src/frontend/tests/core/integrations/Simple Agent Memory.spec.ts (1)

17-19: Verify .env file path usage

No .env file was found in the repo tree—confirm where your .env actually resides and update the path.resolve(__dirname, …) call to point to that location (or remove the explicit path option so dotenv loads the default .env from the working directory).

src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (1)

2530-2532: Strip chat content from debug logs

Here too we’re emitting the entire chat history into logs, exposing user conversations. That’s a privacy/compliance risk—please log only safe metadata (like message counts) rather than the raw transcript.

-        logger.debug(f"Chat history: {self.chat_history}")
+        history_count = len(self.chat_history) if isinstance(self.chat_history, list) else "unknown"
+        logger.debug("Chat history retrieved (count=%s)", history_count)

Likely an incorrect or invalid review comment.

Comment on lines 181 to 184
self.chat_history = await self.get_memory_data()
logger.debug(f"Chat history: {self.chat_history}")
if isinstance(self.chat_history, Message):
self.chat_history = [self.chat_history]
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Oct 9, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove sensitive chat history logging

self.chat_history contains end-user conversation data. Dumping it verbatim into logs—even at DEBUG—exposes PII/regulated content and breaks our privacy stance. Please drop this line or replace it with a redacted/aggregate signal (e.g., count of messages) before shipping.

🤖 Prompt for AI Agents
In src/lfx/src/lfx/components/agents/agent.py around lines 181 to 184, remove
the direct debug logging of self.chat_history because it may contain sensitive
end-user data; instead replace that line with a non-content-specific signal such
as logging the number of messages (and optionally metadata like message types or
timestamps) after you normalize Message -> list, ensuring no message text or PII
is written to logs.

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.

Agreed that this exposes user data in a sense, but not sure I necessarily agree it's PII.

More so, we shouldn't do this due to performance issues -- don't want to serialize the entire chat history in logs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jordanrfrazier, excellent point about the performance impact! You're absolutely right that serializing the entire chat history in logs could be expensive, especially as conversations grow longer.

A lightweight alternative would be to log just the count or basic metadata instead:

logger.debug(f"Retrieved {len(self.chat_history)} chat history messages")

This gives you the debugging signal you need (confirming messages were retrieved) without the serialization overhead.


✏️ Learnings added
Learnt from: jordanrfrazier
PR: langflow-ai/langflow#10204
File: src/lfx/src/lfx/components/agents/agent.py:181-184
Timestamp: 2025-10-10T16:02:39.849Z
Learning: In the langflow codebase, avoid logging entire chat history objects in debug statements due to performance concerns from serializing large data structures. Instead, log aggregate metadata like message counts (e.g., `logger.debug(f"Retrieved {len(chat_history)} messages")`).

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. but its debug logs right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I believe it logs only when loglevel is debug.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Oct 10, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Oct 10, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Oct 13, 2025
@edwinjosechittilappilly edwinjosechittilappilly changed the title feat: udpate flows with agent with debug logs for chat history feat: update flows with agent with debug logs for chat history Oct 13, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Oct 13, 2025
@github-actions github-actions Bot added the enhancement New feature or request label Oct 13, 2025
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@Cristhianzl Cristhianzl left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Oct 13, 2025
@edwinjosechittilappilly edwinjosechittilappilly added this pull request to the merge queue Oct 13, 2025
Merged via the queue into main with commit db280e4 Oct 13, 2025
79 of 80 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the fix-templates-agents-add-logs branch October 13, 2025 18:57
korenLazar pushed a commit to kiran-kate/langflow that referenced this pull request Nov 13, 2025
…low-ai#10204)

* udpate flows

* agent memory test

* adding plauywright for memory

* agent memory test

* ✨ (Simple Agent Memory.spec.ts): update test to select the last chat message element for assertion accuracy

---------

Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
@coderabbitai coderabbitai Bot mentioned this pull request Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants