-
Notifications
You must be signed in to change notification settings - Fork 102
feat: LoCoMo accuracy improvements — auto-read + multi-word OR #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
64f2246
04bf1d5
f852bbe
5ddf0df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,6 +225,28 @@ export async function processPreToolUse(input: PreToolUseInput, deps: ClaudePreT | |
| "python, python3, node, and curl are NOT available. " + | ||
| "You MUST rewrite your command using only the bash tools listed above and try again. " + | ||
| "For example, to parse JSON use: cat file.json | jq '.key'. To count keys: cat file.json | jq 'keys | length'."; | ||
|
|
||
| // Fast-path: a clean single-file read attempt by an unsupported interpreter | ||
| // (python/node/ruby/perl, no shell metacharacters) gets rewritten to | ||
| // `cat '<path>'` so the agent doesn't burn a turn on a RETRY. Anything with | ||
| // $(...), backticks, pipes, redirects, or chains falls through to the | ||
| // guidance below — safer than trying to rewrite composite commands. | ||
| const isReadLike = /^(?:python3?|node|deno|bun|ruby|perl)\b/.test(cmd.trim()); | ||
| const hasShellMeta = /[$`;|&<>()\\]/.test(cmd); | ||
| if (isReadLike && !hasShellMeta) { | ||
| const pathMatch = cmd.match(/~\/\.deeplake\/memory\/[\w./_-]+/) | ||
| || toolPath.match(/~\/\.deeplake\/memory\/[\w./_-]+/); | ||
| const memPath = pathMatch ? pathMatch[0] : ""; | ||
| const cleanPath = memPath ? rewritePaths(memPath) : ""; | ||
| if (cleanPath && !cleanPath.endsWith("/")) { | ||
| logFn(`unsupported command on file, converting to cat: ${cleanPath}`); | ||
| return buildAllowDecision( | ||
| `cat '${cleanPath.replace(/'/g, "'\\''")}'`, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No test exercises the new happy path — the existing tests only verify that commands with shell metacharacters still produce RETRY guidance (the negative path). Add a test that |
||
| "[DeepLake] converted unsupported interpreter read to cat", | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| logFn(`unsupported command, returning guidance: ${cmd}`); | ||
| return buildAllowDecision( | ||
| `echo ${JSON.stringify(guidance)}`, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path regex only matches
~/prefix, sopython3 /home/runner/.deeplake/memory/data.json(an absolute path) passestouchesMemory()andisReadLike, but silently falls through to RETRY guidance because neithercmd.match(...)nortoolPath.match(...)fires. Extend the regex to also match theMEMORY_PATHabsolute prefix, or userewritePathson the whole cmd/toolPath and inspect the result.