Skip to content

Align shared file operand extraction with built-in tool argument decoding #2094

Closed

Description

@JAORMX

Problem

tool.LocalFileOperands can extract a different file operand from the one a built-in tool actually uses. Fix this in the existing shared extraction/decoding path, separately from AGENTS hierarchy work.

At baseline 3222c2fb808d4140d19b2979a73dd2a6b2cc4398:

  • LocalFileOperands unmarshals arguments into a map and looks up exact lowercase keys.
  • session.ParseArgs uses json.Unmarshal; built-in tools pass structs, whose field matching accepts case variants.
  • For example, ReadTool.Execute passes its decoded args.Path to the workspace.

Given:

{"path":"website/a.ts","Path":"services/a.ts"}

The helper extracts website/a.ts, while the built-in struct decoder selects the later services/a.ts value. Checking only that extraction returned a complete, nonempty operand set does not catch this mismatch.

Impact and existing callers

The shared helper already feeds contextual action review and evidence selection:

  • engine/agent/actionreview.go:417 and :459
  • internal/app/contextual_evidence.go:143 and :150

Review these callers to establish the actual impact and preserve their contracts. This report establishes a decoding mismatch; it does not claim a demonstrated filesystem-permission bypass.

PR #2092 proposes reusing this helper for instruction applicability under #2090. That feature must not check guidance for one target while executing against another. The underlying defect predates hierarchy and should not be fixed by adding hierarchy-specific parsing.

Scope

Make shared operand extraction agree with actual built-in argument decoding, or consistently reject ambiguous operands before effects. Prefer extending existing helpers and validation rather than introducing another target interface or parser framework.

Account for single-path tools and Copy/Move's two operands. Preserve the helper's restricted Shell-script recognition and its refusal to infer workspace semantics from arbitrary custom/MCP arguments. Do not broaden Shell affected-path inference.

Acceptance

  • For accepted built-in arguments, extracted operands match the effective operands used by the tool; ambiguous or invalid inputs cannot become successful coverage of a different target.
  • Regression tests cover ordinary lowercase keys, case variants, conflicting case-variant keys in both orders, duplicate-key/null behavior, malformed operand values, and complete Copy/Move operand sets. Expected behavior is checked against actual built-in decoding rather than a second copy of extraction logic.
  • Existing contextual-review/evidence callers are audited, with a focused boundary regression proving they cannot silently select evidence for a different executed target in the reported case.
  • Existing Shell recognition and custom/MCP non-inference behavior remain covered; no new authority is inferred from arbitrary payload fields.
  • The hierarchy plan records this dependency and the invariant that applicability checks match effective executed operands. Its eventual dispatch test verifies that invariant without duplicating the helper's full unit suite.

Non-goals

No AGENTS hierarchy implementation, general JSON-schema enforcement, new instruction subsystem, or broad parser cleanup. Preserve existing permission, hook, and argument-validation boundaries.

Evidence here is source inspection; no runtime permission-bypass qualification is claimed.

Activity

  1. JAORMX commented on Oct 5, 2026

    @JAORMX
    ContributorAuthor

    Fixed by merged PR #2095 (f8b2d7f). CI passed, including the full race suite. The hierarchy-plan dependency amendment belongs to the separate, unmerged PR #2092 and does not block closing this bug fix.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions