fix(langchain): skip non-dict rows in format_recall_content#2563
fix(langchain): skip non-dict rows in format_recall_content#2563Bartok9 wants to merge 2 commits into
Conversation
Memory recall results may include None/non-dict entries. Guard the loop so one bad hit does not abort the content envelope.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesRecall formatting
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 (2)
sdk/wren-langchain/src/wren_langchain/_format.py (1)
114-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the input annotation with the new behavior.
The guard now intentionally accepts mixed inputs, but
format_recall_contentis still annotated as accepting onlylist[dict[str, Any]]on Line 107. Update the annotation to reflect non-dictionary rows, such asSequence[object], so callers and type checkers see the actual contract.Suggested adjustment
-def format_recall_content(rows: list[dict[str, Any]]) -> str: +def format_recall_content(rows: Sequence[object]) -> str:🤖 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 `@sdk/wren-langchain/src/wren_langchain/_format.py` around lines 114 - 119, Update the input annotation of format_recall_content to represent mixed row types, such as Sequence[object], matching the existing non-dictionary row guard while preserving the current rendering behavior.sdk/wren-langchain/tests/unit/test_format_recall_content_guard.py (1)
11-17: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert numbering for every valid row.
This test verifies that the first valid row starts at
1, but it would still pass if subsequent valid rows were also numbered1. Assert that the second rendered row is numbered2to cover the new counter behavior.Suggested test assertion
- assert out.startswith('1. "') + assert out.startswith('1. "q1"') + assert '\n2. "q2"' in out🤖 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 `@sdk/wren-langchain/tests/unit/test_format_recall_content_guard.py` around lines 11 - 17, Update test_skips_non_dict_rows to assert that the second valid rendered row begins with numbering 2, while preserving the existing checks for skipped non-dictionary rows and rendered query content.
🤖 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 `@sdk/wren-langchain/src/wren_langchain/_format.py`:
- Around line 114-119: Update the input annotation of format_recall_content to
represent mixed row types, such as Sequence[object], matching the existing
non-dictionary row guard while preserving the current rendering behavior.
In `@sdk/wren-langchain/tests/unit/test_format_recall_content_guard.py`:
- Around line 11-17: Update test_skips_non_dict_rows to assert that the second
valid rendered row begins with numbering 2, while preserving the existing checks
for skipped non-dictionary rows and rendered query content.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6164ac76-d4df-4649-befb-2561bc0d4757
📒 Files selected for processing (2)
sdk/wren-langchain/src/wren_langchain/_format.pysdk/wren-langchain/tests/unit/test_format_recall_content_guard.py
CI lint fails on ruff format --check for the new unit test.
|
Closing as superseded — non-dict row skipping in |
Summary
Skip non-dict recall hits in
format_recall_contentso mixed memory payloads still render.Real behavior proof
License
sdk/wren-langchain/**Apache-2.0.Summary by CodeRabbit
Bug Fixes
Tests