Skip to content

fix(harness): decode ripgrep JSON match content - #4135

Open
Htd7860 wants to merge 2 commits into
agentscope-ai:mainfrom
Htd7860:fix/harness-ripgrep-json
Open

Htd7860 wants to merge 2 commits into
agentscope-ai:mainfrom
Htd7860:fix/harness-ripgrep-json

Conversation

@Htd7860

@Htd7860 Htd7860 commented Nov 11, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Fixes #4134

Local grep results are currently parsed by slicing JSON strings at the next quote. This truncates quoted source lines and leaves escaped backslashes, tabs and line endings in the text returned to the agent.

Use the existing JSON codec to read match events, then remove the decoded line terminator. Handle both lines.text and Base64 lines.bytes, replacing invalid UTF-8 line bytes with U+FFFD. Remove the three string-extraction helpers. Search arguments, path resolution and the Java fallback are unchanged. Non-UTF-8 filenames remain unsupported; they are not resolved to replacement-character paths.

Add eleven regression cases through the public grep method using process-output fixtures, so they run without installing ripgrep. They cover quoted text, backslashes, tabs, Unicode, literal escape sequences, escaped paths, JSON whitespace, byte-encoded lines and malformed records. The real ripgrep/public grep path was also checked locally.

Validation on Windows 11 with JDK 17:

  • The eight original escaping cases fail on the original source. All eleven final regression cases pass, with no skips; the added byte-payload cases also protect against losing matches from non-UTF-8 lines.
  • mvn -T1C -pl agentscope-harness -am -Dtest='*Filesystem*Test,*FilesystemTest*,FilesystemToolTest,BoundedFileReadTest' -Dsurefire.failIfNoSpecifiedTests=false test spotless:check: 265 passed, 34 skipped by existing Windows/symlink conditions, no failures or errors. Spotless passed across the selected reactor. This is a scoped run, not the full repository suite.
  • Real ripgrep 15.2.0 with temporary files: matching paths, line numbers and text agree with five file lines, including an invalid UTF-8 byte decoded as U+FFFD. The original text probe fails on the original source.
  • Docs: 13 tests passed; npm run validate passed. npm run broken-links reports 2,230 broken links in 328 files on both the original and modified documentation, with identical results.

AI assistance was used for implementation and test preparation. A separate review agent reviewed the final commit; its byte-payload finding was fixed and re-reviewed before submission.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test); scoped validation is listed above, the full suite was not run.
  • Javadoc comments are complete and follow project conventions; no public API was added.
  • Related documentation has been updated in English and Chinese.
  • Code is ready for review.

Use the existing JSON codec so quotes, backslashes and tabs reach
grep callers as file text instead of escaped or truncated fragments.
Cover the public grep path with process-output fixtures and update
the English and Chinese filesystem guides.

Refs agentscope-ai#4134
@mintlify

mintlify Bot commented Nov 11, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 53aa0a6.

Approve preview

@CLAassistant

CLAassistant commented Nov 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

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

Labels

P1 紧急不重要

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LocalFilesystem grep corrupts JSON-escaped match text

3 participants