Skip to content

refactor: document-agent profile protocol and TOC boundary tools - #246

Merged
EricNGOntos merged 2 commits into
mainfrom
feat/wuchengke/2026-08-03
Aug 9, 2026
Merged

refactor: document-agent profile protocol and TOC boundary tools#246
EricNGOntos merged 2 commits into
mainfrom
feat/wuchengke/2026-08-03

Conversation

@EricNGOntos

Copy link
Copy Markdown
Contributor

Summary

  • Converge document profiling executor finish ownership onto the verdict tool only (tool_call steps; legacy verdict_now coerced), and stop planner next_action from finishing/aborting the run.
  • Slim page-feature probing by dropping persisted asset_bboxes and keeping the has_asset gate.
  • Improve TOC extraction with boundary confirmation/region concurrency, persist anatomy debug artifacts, and add contract coverage for the new profile/TOC protocols.

Test plan

  • Focused worker contract tests: test_profile_agent_protocol_contract, test_doc_profile_anatomy_contract, test_toc_confirm_batch_contract, test_toc_phase2_region_concurrency_contract (37 passed)
  • Confirm CI lint / typecheck / worker tests on the PR
  • Spot-check oversized PDF profiling still reaches propose.shard_planvalidate.anatomy_mapverdict(success)
  • Spot-check TOC phase2 confirmation path still emits hierarchies without regressing empty-subsection demotion

Made with Cursor

- Added DOC_PROFILE_FILENAME to persist anatomy map artifacts for better debugging.
- Updated hierarchy_locator to retain original TOC headings while normalizing titles.
- Introduced TOC_VLM_MAX_TOKENS for consistent token limits in VLM calls.
- Refactored rendering logic in extract_toc_with_boundaries to handle multiple pages.
- Improved evidence extraction from confirmation items in VLM processing.
- Adjusted zip package writer to conditionally include TOC hierarchies based on parse track.
- Removed the obsolete 'verdict_now' action, consolidating decision-making under 'tool_call'.
- Updated prompts and instructions to clarify the executor's role in handling actions and verdicts.
- Enhanced the handling of legacy actions to ensure compatibility with the new decision structure.
- Refactored the logic in the executor to enforce 'tool_call' as the only valid action, improving clarity and maintainability.
- Adjusted the planner's behavior to treat 'verdict_now' as a non-finish signal, delegating success/abort handling to the executor.
)
from app.services.document_agent.planner.planner import _parse_profile_and_decision
from app.services.document_agent.registry import REGISTRY
from app.services.document_agent import tools as _registered_tools # noqa: F401
@EricNGOntos
EricNGOntos merged commit 5a5c986 into main Aug 9, 2026
6 checks passed
@EricNGOntos
EricNGOntos deleted the feat/wuchengke/2026-08-03 branch August 9, 2026 10:58
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.

2 participants