Skip to content

Split giant renderers and functions; add type hints along the way #104

Closed as not planned

Description

@lanyue-llk

Problem

Worst functions:

Function Location Lines
main lexbench/report.py:78 1,523
build_report browser_use/report.py:2859 1,166
build web_search/report.py:450 879
build_webarena_replay_report trajectory_replay/webarena_report.py:1396 794
validate lexbench/verification.py:36 778
generate_webmainbench_full web_fetch/report.py:3846 629
check browser_use/report_check.py 612
_assemble refresh_assembly.py:1116 553
execute_steps public_webarena/executor.py:208 517
run_evaluation public_webarena/runner.py:658 485

The largest files are web_fetch/report.py (4.5k lines) and browser_use/report.py (4.1k). browser_use/report.py relies on function-local imports to dodge an import cycle. About 1,200 of 1,900 functions in web_fetch, lexbench and web_search have no type hints.

Proposal

  • One module per route class.
  • Runner stages split into prepare, session, agent and finalize.
  • A per-site login strategy table instead of if/elif chains.
  • Type hints added on touched code; a type checker (pyright or mypy) introduced on fully typed packages.

Risk: medium per PR. Depends on: the English-source migration for each renderer, so each file is rewritten once.


Part of the refactor roadmap: #87

Activity

  1. added
    refactor
    on Oct 29, 2026
  2. lanyue-llk commented on Oct 30, 2026

    @lanyue-llk
    ContributorAuthor

    Carried over from #88 (closed by #119): add a synthetic LexBench report builder and a golden snapshot for it. harness/lexbench/report.py main() currently needs a full saved-profile evidence tree, so no test can build the report; the split here should expose a builder that tests/test_golden_reports.py can call.

  3. lanyue-llk commented on Nov 4, 2026

    @lanyue-llk
    ContributorAuthor

    Closing: the Lexbench golden test was delivered by #207. Further splitting of large renderers is not needed for main functionality, so it is left unless a file blocks real work.

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

    refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions