[Bug]: OMP adapter hard-blocks curl/wget/fetch( inside quotes, grep patterns and heredocs (Pi fix from #625 never ported)

Author: taonosCreated Sep 29, 2026Updated Sep 29, 2026

Platform

Other: oh-my-pi (omp) via the OMP adapter (src/adapters/omp/plugin.ts), installed with omp plugin install context-mode.

context-mode version

1.0.169 (latest release). The flat pattern list is unchanged on both main and next.

Summary

The OMP adapter's tool_call hook still hard-blocks any bash command whose full text matches BLOCKED_BASH_PATTERNS (/\bcurl\s/, /\bwget\s/, /\bfetch\s*\(/, …) using a flat .some() match. So it blocks:

  • grep patterns (grep -n 'fetch(' client.ts)
  • quoted CLI arguments and commit messages
  • heredoc bodies that write a script to disk
  • the silent file-output escape hatch (curl -s -o file URL)

#63 fixed this for the Claude Code hook, and #625 (v1.0.141) fixed it for the Pi extension with stripQuotedContent(), isSafeCurlWget(), and per-segment checks. The OMP adapter was never ported. Its own comment still says "Identical to the Pi extension list (src/adapters/pi/extension.ts:42)", but that is no longer true.

Impact (measured)

These counts come from omp's ~/.omp/stats.db, covering the last 24h for one model (claude-opus-5-5):

  • 59 bash tool calls marked as errors.
  • 15 of the 59 were this hook.
  • 9 of those 15 were false positives: grep for fetch( in source, heredoc probe scripts, grep '^+.*curl ' over a diff, etc.

The agent has to rewrite the command and retry every time. The block reason ("Use ctx_execute, ctx_fetch_and_index…") doesn't tell it that the match was on a literal inside a grep pattern, so it often trips the hook again.

Exact prompt that triggered the bug

Any prompt that leads the agent to grep source for fetch(. Example from a real session: "find how the client passes redirect options to fetch". The agent ran:

grep -n 'fetch(\|redirect\|\.\.\.init' ov-http.mjs | head -20

Full error output

Use context-mode MCP tools (ctx_execute, ctx_fetch_and_index) instead of inline HTTP. curl/wget/fetch dump raw HTTP into the context window.

Steps to reproduce

This script calls the installed adapter's tool_call handler directly. Run it with a throwaway HOME, because the plugin entry self-registers the MCP server.

javascript
// repro.mjs
import ompPlugin from "<npm-root>/context-mode/build/adapters/omp/plugin.js";
const handlers = {};
ompPlugin({ on: (ev, fn) => { handlers[ev] = fn; } });
const cases = [
  `grep -n 'fetch(' client.ts`,
  `grep -rn "curl " scripts/`,
  `gh search issues --repo o/r "curl blocked"`,
  `git commit -m "docs: explain wget usage"`,
  "cat > /tmp/p.mjs <<'EOF'\nconst r = await fetch(u);\nEOF",
  `curl -s -o /tmp/x.json https://api.github.com/repos/o/r`,
  `curl https://example.com`,
];
for (const command of cases) {
  const r = handlers.tool_call({ toolName: "bash", input: { command } });
  console.log(r?.block ? "BLOCKED" : "allowed", "|", JSON.stringify(command));
}
$ HOME=$(mktemp -d) bun repro.mjs
BLOCKED | "grep -n 'fetch(' client.ts"
BLOCKED | "grep -rn \"curl \" scripts/"
BLOCKED | "gh search issues --repo o/r \"curl blocked\""
BLOCKED | "git commit -m \"docs: explain wget usage\""
BLOCKED | "cat > /tmp/p.mjs <<'EOF'\nconst r = await fetch(u);\nEOF"
BLOCKED | "curl -s -o /tmp/x.json https://api.github.com/repos/o/r"
BLOCKED | "curl https://example.com"

Expected, matching the Pi extension's behavior since #625: only the last line is BLOCKED.

What have you tried to fix it?

  • Confirmed on the latest release (1.0.169) and checked main and next. Both still have the flat BLOCKED_BASH_PATTERNS.some((p) => p.test(command)) in src/adapters/omp/plugin.ts.
  • Traced the fix in the Pi adapter: stripQuotedContent(), isSafeCurlWget(), and per-segment checks in src/adapters/pi/extension.ts.
  • Suggested fix: have the OMP tool_call handler reuse those two exports and the same segment loop. That would fulfil the "identical to Pi" comment. The Pi RED→GREEN cases from #625 should carry over directly.
  • Local workaround: an omp TTSR rule that warns the agent before the call. It doesn't reduce the false positives, it only makes retries cheaper.

Debug script output

scripts/ctx-debug.sh is not shipped in the npm package, so I ran it from the repo. It inspects the Claude Code plugin layout, which isn't what the OMP install uses: it reported 14 pass / 16 fail / 2 warnings, and every failure was a missing Claude-Code-plugin-root file. The full JSON also dumps other harnesses' configs, so I've left it out. The repro above exercises the affected code path directly.

Environment

  • OS: Linux (Other): Windows (WSL2), kernel 6.6
  • JS runtime: bun 1.3.14
  • omp 18.4.2