fix(ask): guided template's recall step uses a valid CLI option#2565
fix(ask): guided template's recall step uses a valid CLI option#2565AmirF194 wants to merge 2 commits into
Conversation
The guided.md.tmpl step 2 told the agent to run `wren memory recall --nl "<keywords>"`, but `recall` only accepts `--query`/`-q`. `--nl` belongs to the unrelated `store` command, so following the guide as written fails with "No such option: --nl". Point the step at `--query` instead, and add a regression test that invokes the exact command the guided template emits against the real CLI parser, asserting it does not hit a usage error. Fixes Canner#2503
WalkthroughThe guided ask template now uses ChangesGuided memory recall
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@core/wren/tests/unit/test_ask_cli.py`:
- Around line 68-72: Update the command parsing in the test around recall_line
and args to use shlex.split with comments enabled, preserving quoted arguments
while stripping the inline markdown comment. Keep invoking the CLI with the
parsed arguments and the existing memory recall command.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b7c6d25b-a8d3-46ed-a724-ce8c2ddf5626
📒 Files selected for processing (2)
core/wren/src/wren/ask_templates/guided.md.tmplcore/wren/tests/unit/test_ask_cli.py
| recall_line = next( | ||
| line for line in result.output.splitlines() if "wren memory recall" in line | ||
| ) | ||
| args = recall_line.split("wren memory recall", 1)[1].split("#", 1)[0].split() | ||
| recall_result = runner.invoke(app, ["memory", "recall", *args]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Parse the emitted command with shell-aware parsing.
str.split() does not preserve quoted arguments, so a future query containing spaces would be passed as multiple CLI arguments rather than executing the exact generated command. Use shlex.split(..., comments=True) to handle the inline markdown comment and shell quoting.
Proposed fix
+import shlex
+
recall_line = next(
line for line in result.output.splitlines() if "wren memory recall" in line
)
- args = recall_line.split("wren memory recall", 1)[1].split("#", 1)[0].split()
+ args = shlex.split(
+ recall_line.split("wren memory recall", 1)[1],
+ comments=True,
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| recall_line = next( | |
| line for line in result.output.splitlines() if "wren memory recall" in line | |
| ) | |
| args = recall_line.split("wren memory recall", 1)[1].split("#", 1)[0].split() | |
| recall_result = runner.invoke(app, ["memory", "recall", *args]) | |
| import shlex | |
| recall_line = next( | |
| line for line in result.output.splitlines() if "wren memory recall" in line | |
| ) | |
| args = shlex.split( | |
| recall_line.split("wren memory recall", 1)[1], | |
| comments=True, | |
| ) | |
| recall_result = runner.invoke(app, ["memory", "recall", *args]) |
🤖 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 `@core/wren/tests/unit/test_ask_cli.py` around lines 68 - 72, Update the
command parsing in the test around recall_line and args to use shlex.split with
comments enabled, preserving quoted arguments while stripping the inline
markdown comment. Keep invoking the CLI with the parsed arguments and the
existing memory recall command.
|
Heads up on the two red checks (lint and unit tests): both fail on the same line, |
guided.md.tmplstep 2 tells the agent to runwren memory recall --nl "<keywords>".recallonly accepts--query/-q(core/wren/src/wren/memory/cli.py);--nlbelongs to the unrelatedstorecommand. Following the guided flow as written fails at option parsing.Reproduced against current HEAD (
f4b45edd,python:3.11-slimin Docker,uv sync,print(wren.__file__)confirmed the installed package is this checkout):Fix: change the template's step 2 to
--query.Added a regression test that parses the exact
wren memory recall ...line the guided template emits and invokes it against the real CLI, asserting it does not hit a click usage error (exit code 2). It fails onmain(--nlis a usage error) and passes on this branch (--queryreaches the command's own logic).Ran
tests/unit/(excludingtest_memory.py/test_mcp_server.py, matching this repo'stest-unitCI job) andruff format --check/ruff checkonsrc/: clean except a pre-existing, unrelatedNameErrorintest_redshift_semicolon.py/src/wren/connector/redshift.pythat also fails on unmodifiedmain.Did not add the
wren memory fetchmention the issue also suggests; that is a template enhancement rather than the reported bug, so leaving it for a separate change if wanted.Fixes #2503
Summary by CodeRabbit
Bug Fixes
Tests