Skip to content

Dangerous-pattern validator causes agent retry-loops (false positives on literal tokens) #7

Closed

Description

@SWSAmor

Summary

The executeTypescript defense-in-depth "dangerous pattern" validator
(src/validation/security-validator.ts:43-63) matches security-sensitive literal
tokens in the submitted source
— eval(, exec(/execSync/execFile, os.system,
subprocess.(run|call|Popen|check_output), import … 'child_process'. Because the match
is on raw source text, it also fires when those tokens appear in non-executable
contexts
: string literals, documentation text being written to a store, comments, or
data being analyzed.

When that happens the model receives a hard refusal and — not recognizing it as terminal —
retries reworded variants repeatedly. The 2026-06-22 cross-project log analysis
(template /dev-analyze-and-self-improve) found this as the single largest cluster:
26 occurrences / 3 sessions (modulo, paperclip-management), all retry-flagged.

Reproduction

Submit any executeTypescript whose code contains one of the blocked tokens as data —
e.g. building a Markdown note that documents the validator's own blocklist, or analyzing a
snippet that mentions subprocess.run. The call is refused even though nothing dangerous
executes. (Observed live while writing the resolution note for the consuming template's
issue aberemia24#38.)

Why it matters

  • Agents waste turns retry-looping on a non-retryable refusal.
  • The refusal text does not tell the caller it is terminal, nor how to proceed.
  • The legitimate escape hatch (skipDangerousPatternCheck: true param /
    CODE_EXECUTOR_SKIP_DANGEROUS_PATTERNS env) is under-documented at the point of failure.

Suggested directions (non-binding)

  1. Refusal message: make it explicit that the block is terminal ("do not retry; this is
    defense-in-depth, not a transient error") and name the bypass param. This alone would stop
    the retry-loops.
  2. Reduce false positives: consider not matching inside string/comment literals (the tokens
    are dangerous when executed, not when present as text/data). A lightweight tokenizer or
    skipping quoted/commented regions would cut the noise.
  3. Discoverability: surface skipDangerousPatternCheck (defense-in-depth bypass, not a
    security boundary) in the refusal message and tool description.

Context

Filed from the claude-code-developer-template self-improvement issue aberemia24#38 (pattern P1).
The consumer side is handled there (agent guidance: recognize the hard refusal, stop
retrying, use the deliberate bypass when the call is legitimate). This issue tracks the
server-side tuning. Reference: src/validation/security-validator.ts:43-63.

Activity

  1. added 2 commits that reference this issue on Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions