fix(tools): harden Grep format_output for local-model searches JSON#12
fix(tools): harden Grep format_output for local-model searches JSON#12JessicaMulein wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
Static Code Review 📊 🛑 1 quality checks failed!
|
Review Summary by QodoHarden Grep tool for malformed local model searches JSON
WalkthroughsDescription• Add _coerce_searches() method to handle double-encoded or malformed JSON strings from local models • Replace manual JSON parsing with parse_tool_arguments() helper in format_output() • Coerce searches parameter in execute() method for robustness • Add regression test for malformed string searches handling Diagramflowchart LR
A["Local Model<br/>Double-Encoded JSON"] -->|"malformed searches"| B["_coerce_searches()"]
B -->|"normalize to list"| C["format_output()"]
C -->|"safe display"| D["Tool Output"]
E["execute()"] -->|"coerce input"| F["Validated searches"]
File Changes1. cecli/tools/grep.py
|
Code Review by Qodo
1. Silent malformed searches display
|
Coerce double-encoded or malformed searches strings via parse_tool_arguments so format_output no longer crashes when qwen emits truncated inner JSON. Co-authored-by: Cursor <cursoragent@cursor.com>
4868784 to
590d360
Compare
|
Superseded by upstream PR to cecli-dev/cecli (branch rebased on upstream/main). |
|
Upstream PR opened: cecli-dev#549 |
Summary
searchesin Grepformat_output/executeusingparse_tool_argumentsand_coerce_searchesAttributeError: 'str' object has no attribute 'get'when local models emit truncated/double-encodedsearchesJSONsearchesTest plan
pytest tests/tools/test_tool_arguments.py -k grep_format_outputNote: also cherry-picked to
dev-integration(383b6fd) for BrightVision dogfood.Made with Cursor
PR Summary by Typo
Overview
This PR hardens the
Greptool'sformat_outputfunction to gracefully handle malformed or double-encoded JSON inputs, particularly from local models, preventing crashes and improving the robustness of search result processing.Key Changes
_coerce_searchesmethod to normalize and parse various forms of thesearchesparameter, including strings, lists, and dictionaries, and to handle double-encoded JSON.executemethod to utilize_coerce_searchesfor input validation and normalization.format_outputmethod to useresponses.parse_tool_argumentsfor safer parsing of tool arguments and_coerce_searchesfor processing search operations.format_outputfunction does not crash when encountering malformed string searches.Work Breakdown
To turn off PR summary, please visit Notification settings.