pdf-engine-selection

A guide to choosing different software engines while converting PDF files into Markdown text. It uses document characteristics such as whether pages are scanned, whether they contain tables or formulas, and how many pages they have.

In plain words
What is it for?
Use it to route scanned, small, or complex PDFs through appropriate extraction and layout-analysis engines, skip irrelevant stages, and audit those choices.
Why use it?
It avoids running unnecessary processing stages and can choose faster or more suitable tools for different PDFs. It also records the routing decision so the choice can be reviewed later.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/threefish-ai/negentropy/pdf-engine-selection
Clone the repo
git clone --depth 1 https://github.com/ThreeFish-AI/negentropy
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,306 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01306
Opus 5 $0.00000 $0.00653
Sonnet 5 $0.00000 $0.00261
Haiku 4.5 $0.00000 $0.00131

Measured 2d ago against content hash c9371fc4e2fe, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pdf-engine-selection scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/reference/perceives/agents/pdf-engine-selection.md · 103 lines

How it starts

The opening of the file, as written. The whole thing — 103 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PDF 引擎选择决策图

本文档可视化 parse_pdf_to_markdown Pipeline 在 Adaptive Engine Selection (PR #163, PR2)下,各 Stage 的运行时引擎路由策略。决策结果会写入 StageResult.metadata.selector_decision,便于审计与调优。

TL;DRquick_scan 产出的 DocumentCharacteristicsis_scanned / has_tables / has_formulas / page_count 等)从「死字段」变成「路由信号」。 对没必要跑的 Stage 短路,对扫描版 PDF 用 marker / docling,对小文档用 PyMuPDF 快路径,省下 docling 10s 冷启动。

决策入口

flowchart TD
    A([Stage 开始]) --> B{selector 策略}
    B -- identity --> Y[YAML 静态顺序<br/>不重排不跳过]
    B -- profile_aware --> C{characteristics<br/>是否就绪?}
    C -- 否 --> D[回退 YAML 默认<br/>reason=missing_characteristics]
    C -- 是 --> E{Stage 是否<br/>「特征驱动型」?}
    E -- 是 --> F{对应特征<br/>= False?}
    F -- 是 --> G[短路跳过<br/>返回空 output<br/>reason=no_has_*]
    F -- 否 --> H[继续路由]
    E -- 否 --> H
    H --> I{Stage 名称}
    I -- text_extraction --> J[扫描/小文档/默认 子规则]
    I -- layout_analysis --> K[简单布局快路径]
    I -- 其他 --> Y

text_extraction 子规则

flowchart TD
    A([text_extraction]) --> B{is_scanned?}
    B -- 是 --> C["重排: marker → docling → opendataloader<br/>→ pymupdf → pypdf"]
    B -- 否 --> D{page_count < 5?}
    D -- 是 --> E["快路径: 仅 pymupdf<br/>跳过 docling 10s 冷启动"]
    D -- 否 --> F[保持 YAML 顺序]
    C --> G[reason=scanned]
    E --> H["reason=small_doc_{N}p"]
    F --> I[reason=default]

layout_analysis 子规则

flowchart TD
    A([layout_analysis]) --> B{has_complex_layout<br/>= False?}
    B -- 否 --> Z[保持 YAML 顺序]
    B -- 是 --> C{is_scanned = False?}
    C -- 否 --> Z
    C -- 是 --> D{page_count < 5?}
    D -- 否 --> Z
    D -- 是 --> E["快路径: 仅 pymupdf<br/>reason=simple_layout_{N}p"]

特征驱动型 Stage 跳过表

Stage 关键特征字段 跳过条件 短路输出
table_extraction has_tables False TableExtractionOutput(tables=[], total_count=0)
formula_extraction has_formulas False FormulaExtractionOutput(formulas=[], ...)
code_detection has_code_blocks False CodeDetectionOutput(code_blocks=[], ...)
image_extraction has_images False ImageExtractionOutput(images=[], total_count=0)

Read the full file on GitHub · 103 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 103 lines · 0 tokens per session scan A c9371fc4e2fe

Subscribe to this mod's changes

pdf-engine-selection is an agent published in the GitHub repository ThreeFish-AI/negentropy (10 stars, last pushed 2d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,306 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

README

This folder consolidates, in a single location, the SoT for the project's five multi-agent roles plus the Universal Cycle skeleton. It is modeled on the role system of a Korean newspaper, and each role is self-contained in its capability boundary, I/O contract, and prompt template.

alfadur7/llm-wiki-newsroom · 0 tokens

columnist

Authors L2-2 full hub expansion + L2-2 timeline narrative + all L2-3·L2-4 content (cluster overview·theme contradiction·synthesis·trail·root overview·root contradiction). Deep cross-source sequential reading + synthesis. Performs the GROUND·APPLY·ADAPT cycle stages together. No direct external WebSearch.

alfadur7/llm-wiki-newsroom · 76 tokens

reporter

Owner of L2-1 source · L2-2 stub authoring and broad external exploration. raw input (.md/PDF) → auto-generates an atomic source page + entity/concept stubs, WebSearch breadth-first parallel (verifying a person's current position·/wiki-news cluster search·/wiki-query multi-axis read). For the cycle stages, performs…

alfadur7/llm-wiki-newsroom · 103 tokens

code-reviewer

Adversarial multi-dimensional code review — security, performance, correctness, spec compliance, maintainability. Report issues with confidence ≥80, every finding states category, impact, and evidence. Runs after component-builder in BUILD workflows.

romiluz13/cc10x · 49 tokens

planner

Create a saved execution plan or decision RFC when implementation work needs an agreement-first artifact before execution.

romiluz13/cc10x · 21 tokens

architecture-scanner

Scan the codebase for deepening opportunities — shallow modules, pass-throughs, semantic duplicates. Read-only. Produces a visual HTML report with before/after diagrams. Routes: CODEBASE-HEALTH workflow.

romiluz13/cc10x · 47 tokens