Skip to content

Make full-file scan prompt contract configurable for bounded reviews #1602

Description

@e2720515-cloud

Full-file scan prompt is fixed, while --background and --rule only fill local placeholders

Version

  • open-code-review v1.12.9
  • commit: bccbc15
  • platform: darwin/arm64

Observed behavior

The scan template is embedded and loaded through internal/config/template.LoadScanDefault(). The main scan conversation contains a fixed system message and a fixed user-message wrapper. The user message accepts placeholders such as:

  • {{current_file_path}}
  • {{file_content}}
  • {{system_rule}}
  • {{plan_guidance}}
  • {{requirement_background}}

However, --background and --rule only replace those local placeholders. They do not replace the surrounding system/user instructions.

The fixed system prompt still says that the task is reviewing an ENTIRE existing source file and says to call context tools when context is insufficient. In addition, --no-plan inserts the fixed text:

(no pre-scan plan; review the entire file as usual)

This makes it difficult to run a bounded single-function or dependency-isolated scan when the caller needs a different review scope. A caller can provide a narrower background/rule, but the resulting prompt still contains the whole-file and context-tool instructions.

Why this matters

For integrations that expose only a bounded synthetic file and a restricted tool set, the caller cannot express a fully consistent contract without maintaining a private OCR build or rewriting the prompt downstream. Downstream rewriting would also make the integration behavior differ from the native OCR contract.

This issue is about prompt-contract configurability; it is not a claim that this behavior alone explains every model timeout.

Requested behavior

Please consider one of these native options:

  1. Add an explicit scan-template override (for example, a validated template file/config) covering the complete MAIN_TASK system/user messages and the no-plan sentinel; or
  2. Add a documented bounded-review mode whose system prompt, user wrapper, no-plan behavior, and tool guidance are internally consistent with the selected scope.

The existing default behavior should remain unchanged when no override/mode is supplied. Template validation should fail closed, and the override should not silently change token/tool budgets.

Reproduction

Run a scan with a narrow background/rule and no plan:

ocr scan --path path/to/file.py --no-plan \
  --background 'Review only the selected function; do not inspect other files.' \
  --rule path/to/restricted-rule.json

Inspect the generated request or enable a request capture in a local test endpoint. The request still contains the fixed whole-file review wording and the fixed no-plan sentence in addition to the narrower background/rule.

Evidence

The behavior is visible in:

  • internal/config/template/scan_template.json
  • internal/config/template/template.go
  • internal/scan/agent.go

No source changes are proposed in this issue.

Activity

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