Skip to content

perf: ship inspection data in the agent task to cut steps and tokens - #113

Merged
SkyeAv merged 1 commit into
mainfrom
optimize-agent-speed
Aug 24, 2026
Merged

perf: ship inspection data in the agent task to cut steps and tokens#113
SkyeAv merged 1 commit into
mainfrom
optimize-agent-speed

Conversation

@SkyeAv

@SkyeAv SkyeAv commented Aug 24, 2026

Copy link
Copy Markdown
Owner

The inner agent spent 2+ LLM steps per article calling pmc_article_context/read_table on files the
supervisor had already downloaded (fleet logs: ~4,600 such calls; 68% of articles exhausted the 20-step
budget at a median 17 steps / 549k tokens). This ships all deterministic inspection output inside the task,
tightens the prescribed workflow, and stops paying for repeated identical builds.

Pre-rendered task context

  • Adds render_task_context (src/tablassert/agent.py): the supervisor renders the article summary plus an
    8-row head preview of EVERY candidate table and EVERY Excel worksheet directly into the task text.
  • pmc_article_context / read_table stay registered as fallbacks for rows beyond a preview or a preview
    that failed; unreadable tables render a fail-visible note instead of raising, and the block is capped at
    60k chars so a pathological article cannot flood the context.

Leaner prompt + loop

  • Rewrites the INSTRUCTIONS workflow to target 4 steps or fewer (derive_configbuild_and_audit
    at most two edit rounds → final_answer); the supervisor's deterministic improve loop continues after the
    agent finishes, so quality ownership does not change.
  • Disables periodic re-planning: build_agent now defaults planning_interval=None — each smolagents
    planning turn was a full extra LLM round trip carrying the entire prompt.
  • Memoizes identical build_and_audit tool calls per instance via functools.lru_cache(maxsize=16);
    models re-ran unchanged configs despite instructions and each repeat paid a full validate+build+coverage
    pass on a fresh tempdir.

Design

  • No CLI surface changes: everything is hardcoded (matching the preference for a minimal tablassert agent
    command), and the schema-gated final answer + supervisor improve loop are untouched, so MAPPED/SKIPPED
    semantics are unchanged.
  • Accepted caveat: cached reports point at the first build's tempdir paths, which persist for the process
    lifetime (tempdirs are never cleaned mid-run), so downstream readers stay correct.

Docs

Testing

  • uv run pytest tests/test_agent_speed.py -q7 passed (previews incl. multi-sheet Excel, fail-visible
    unreadable table, truncation cap, prompt contract, planner default, cache dedupes identical builds).
  • uv run pytest tests/ -q --no-cov984 passed, 14 skipped; the one failure + one error
    (test_lib.py::test_compile_subgraph_threads_fine_phases_into_resolve_and_qc, test_qc.py import) reproduce
    on the base commit (missing qc extra in this worktree venv) and are unrelated.
  • uv run ruff check . && uv run ruff format --check . → clean; uv run pyright src/tablassert/agent.py tests/test_agent_speed.py0 errors.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 60941134-2329-48e0-af28-b19fc8b12f5a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SkyeAv
SkyeAv merged commit 7140c37 into main Aug 24, 2026
5 checks passed
SkyeAv added a commit that referenced this pull request Aug 24, 2026
Cut 13.0.0 and bump the package version in pyproject.toml, uv.lock, and
CITATION.cff.

Major: three breaking changes since 12.1.0. The inlined supporting study now
carries current Biolink Study metadata with disjoint ids and names and no `#`
composition; biolink-model 4.4.4 types the statistical edge slots, so
`effect_size` ships as a real JSON number and `statistical_significance_qualifier`
rides the edge as a bare enum token (both 99099a1); and an unpaired
`effect_size`/`effect_type` half is now DROPPED with an
`UnpairedEffectAnnotationWarning` instead of failing the section, retiring the
`annotation-effect-size-without-type` / `annotation-effect-type-without-size`
codes (#105). Also ships the two final-graph QC assertion sets (#106, #107), the
resolve_batch single-materialization win (#110), and the agent's task
pre-rendering, planning-off, improve-round cap, and build memoization (#113).

The legacy TableConfigs importer (#105) is deliberately absent from the
changelog: it landed and was removed (58787f4) inside this window, so it never
appeared in a released version and is a net no-op for users.

main was red at 7140c37; fixed here so the release is cuttable. Both failures
are #112 fixtures/expectations written against biolink-model 4.4.3 and merged
after the 4.4.4 bump landed:

- The vendored DAKP configs listed `AffinityMeasurement` in `avoid:`, a class
  4.4.4 renamed to `ProteinLigandAssayResult`. DAKP generates `avoid` as the
  sorted complement of each side's prioritize tuple, so the old name is a 4.4.3
  generation artifact rather than an intentional deviation; rewritten in place
  and recorded in the fixture README.
- test_copysign_transformation_in_pipeline asserted `effect_size == "-0.85"`,
  the pre-4.4.4 `{:.4g}` string form. It is a real JSON number now.

Deliberate Biolink departures are untouched: p-value columns keep their
controlled scientific notation despite the model typing them `float`, and
`approval_ids` remains a curated pending pass-through.

docs/cli.md's validate-kgx section still printed `biolink-model 4.4.3` and
claimed `effect_size`/`effect_type` were pending; rewritten around the fields
that are actually pending today (`approval_ids` plus the KGX denormalized
carryovers), noting the pair graduated when 4.4.4 shipped #1774.

Testing:
- uv run pytest -q -> 1047 passed, 15 skipped (94% coverage)
- uv run ruff check . && uv run ruff format --check . && uv run pyright -> clean / 0 errors

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HZQ8rLfhvtyErcq9S4Ao6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant