Skip to content

Robot search output ignores --fields minimal and --max-tokens #63

Description

@pablontiv

Description

backscroll search --robot does not honor the documented agent-output contract for --fields minimal or --max-tokens.

runSearch builds robot output from modelResults, whose Content field is populated from the complete r.Text, and then writes the formatted lines directly. The robot branch therefore bypasses both the minimal r.Snippet projection used by JSON and the picokit formatter that enforces the token budget.

Relevant implementation: cmd/backscroll/search.go in runSearch, particularly the r.Text assignment and direct robot-line output.

Steps to Reproduce

  1. Use an index containing several long messages that match a known term.

  2. Run:

    backscroll search "<known-term>" \
      --all-projects \
      --robot \
      --fields minimal \
      --max-tokens 100 \
      --limit 10 > /tmp/backscroll-robot.out
    wc -c /tmp/backscroll-robot.out
  3. Compare with text output using the same budget:

    backscroll search "<known-term>" \
      --all-projects \
      --max-tokens 100 \
      --limit 10 > /tmp/backscroll-text.out
    wc -c /tmp/backscroll-text.out

In the observed corpus, robot output was 16,350 bytes while text output was 388 bytes under the same --max-tokens 100 budget.

Expected Behavior

  • --robot --fields minimal emits only the documented minimal fields: source path, bounded snippet, score, role, and timestamp.
  • --max-tokens bounds the complete robot payload and emits an explicit truncation indicator when results do not fit.
  • Agent callers can trust the declared output budget.

Actual Behavior

  • Robot output includes complete message content.
  • --fields minimal does not alter the robot payload.
  • --max-tokens does not constrain robot output because the branch writes directly to stdout.
  • One long high-ranked result can consume the caller's context before later relevant results are reached.

Environment

  • Backscroll version: 3.5.1
  • OS: macOS (darwin/arm64)
  • Go implementation from current main

Acceptance criteria

  • Robot mode uses the minimal snippet projection when --fields minimal is selected.
  • Robot mode exposes full content only when --fields full is selected.
  • --max-tokens applies to the complete robot payload, not independently per field or result.
  • Truncation preserves parseable result_N_field=value output and reports that additional results were omitted.
  • A regression test uses long matching messages and proves both minimal-field selection and a bounded total payload.
  • JSON and text output behavior remains unchanged.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions