Skip to content

Add compact and delta modes for AX read_page snapshots #968

@shaun0927

Description

@shaun0927

배경

OpenChrome은 DOM mode에 compact serializer와 delta compression이 있지만, AX mode는 큰 accessibility tree를 그대로 포맷한 뒤 output limit에서 truncate하거나 명시적 DOM fallback을 수행한다. agent-browser는 AX snapshot에서 compact, maxDepth, selector, diff_snapshot을 제공해 ref/value 중심으로 토큰을 줄인다.

목표

read_page mode="ax"에 opt-in compact/delta 기능을 추가해 AX 기반 워크플로우의 토큰 사용량을 줄인다.

구현 범위

  • read_page 입력 schema에 AX 전용 compact?: boolean을 추가한다.
  • mode="ax" compact=true일 때 다음 라인만 보존한다.
    • ref가 있는 interactive/content node 라인
    • value/name/state가 의미 있게 있는 라인
    • 위 라인들의 ancestor 라인
  • 기존 filter="interactive", depth, ref_id, fallback 동작과 조합 가능해야 한다.
  • compression="delta"mode="ax"에서도 동작하도록 AX snapshot cache key를 DOM cache와 분리한다.
  • delta가 noisy하거나 변화율이 큰 경우 기존처럼 full compact AX로 fallback한다.

비범위

  • 기본 AX 출력 포맷 변경
  • DOM mode delta 알고리즘 대규모 교체
  • LLM 요약 기반 compression 도입

성공 기준

  • compact=false 또는 미지정 시 기존 AX 출력이 유지된다.
  • compact=true는 fixture 기준 AX 출력 문자 수를 baseline 대비 최소 30% 줄이되, 모든 ref-bearing interactive line은 유지한다.
  • compression="delta"는 같은 URL/같은 tab의 반복 AX read에서 변경분만 반환한다.
  • URL 변경, 대규모 DOM 변경, cache miss에서는 full snapshot으로 안전하게 fallback한다.

테스트 계획

단위/통합 테스트

  • AX fixture/mock으로 다음을 검증한다.
    • no-ref wrapper만 있는 가지는 compact 결과에서 제거된다.
    • ref가 있는 버튼/링크와 ancestor는 유지된다.
    • checked/disabled/expanded/selected 등 상태 라인은 유지된다.
    • ref_id scoped AX read에서도 compact가 적용된다.
  • AX delta store가 DOM snapshot store와 key collision을 일으키지 않는지 테스트한다.
  • 기존 read_page mode="ax" 테스트가 변경 없이 통과해야 한다.

OpenChrome 실검증

  1. local fixture에 깊은 wrapper 구조와 버튼/입력/상태 변화 요소를 만든다.
  2. read_page baseline:
    {"tabId":"<tab>","mode":"ax","filter":"all"}
  3. compact read:
    {"tabId":"<tab>","mode":"ax","filter":"all","compact":true}
  4. compact 결과가 baseline보다 짧고, 버튼/입력 ref와 ancestor 문맥은 유지되는지 확인한다.
  5. 버튼 클릭 또는 JS로 상태 변경 후:
    {"tabId":"<tab>","mode":"ax","compact":true,"compression":"delta"}
  6. 결과가 변경된 라인 중심의 delta를 반환하는지 확인한다.
  7. 다른 URL로 이동 후 같은 호출이 full snapshot으로 fallback하는지 확인한다.

리스크와 완화

  • 리스크: compact가 문맥을 너무 많이 제거해 LLM이 의미를 잃을 수 있다.
    • 완화: ancestor 라인은 항상 보존하고 기본값은 opt-in으로 둔다.
  • 리스크: AX tree line diff는 DOM보다 순서 변동이 커 noisy할 수 있다.
    • 완화: 변화율 threshold를 두고 초과 시 full compact AX 반환.

Curated scope, overlap handling, and verification checklist

Scope classification

  • Canonical lane: page-state reading and semantic observation.
  • Primary deliverable: Add compact and delta modes for AX read_page snapshots.
  • Open PR: none currently linked in the active priority map; verify GitHub again before implementation.
  • Detected labels: enhancement, performance.
  • Affected OpenChrome surfaces from issue text: read_page, act, interact.
  • Non-goal: breaking existing tool response compatibility, changing defaults without opt-in, or adding server-side autonomous planning.

Overlap and conflict resolution

  • No explicit related issue references were found in the body; still check current open PRs/issues before implementation.
  • Keep this issue aligned with OpenChrome's MCP/CDP-first, additive, deterministic-tool-server direction.
  • If an existing open PR already implements part of this scope, update that PR or mark the overlap explicitly before starting new work.
  • Do not absorb adjacent benchmark, dashboard, security, or skill-memory work unless the original issue text requires it.

Implementation checklist

  • Restate the exact contract for Add compact and delta modes for AX read_page snapshots in code/docs before changing behavior.
  • Keep default page-state responses compatible unless the issue explicitly defines an opt-in mode.
  • Bound output size and expose diagnostics/metadata only where documented.
  • Test fresh/stale state, noisy page fixtures, accessibility/DOM compatibility, and no live DOM mutation when snapshot-only.
  • Add regression coverage for the issue-specific happy path, failure path, default/disabled path, and artifact/output bounds.
  • Update user-facing docs or inline tool descriptions when hosts must choose a new flag, mode, policy, or workflow.

Success criteria

  • The implementation satisfies the primary deliverable without broadening into non-goals.
  • Existing default behavior remains backward-compatible or the issue explicitly documents the compatibility break.
  • Failure cases return bounded, actionable diagnostics rather than silent fallback or unbounded dumps.
  • Tests/benchmarks cover the concrete surface named in this issue, not only helper utilities.
  • Any produced artifact is deterministic, redacted, and small enough for merge review or stored behind handles.

Post-merge OpenChrome live verification checklist

  • Run the documented local OpenChrome fixture or smoke path for Add compact and delta modes for AX read_page snapshots and capture the exact command/tool calls.
  • Verify read_page behavior matches the issue goal in both the enabled path and the default/disabled compatibility path.
  • Inspect generated artifacts/logs/responses for bounded size, redaction, source links, and clear failure diagnostics.
  • Record sanitized output excerpts, artifact paths, and any benchmark/latency/payload numbers in merge verification notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformancePerformance, latency, throughput, or resource-use improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions