Documentation Index
Fetch the complete documentation index at: https://mintlify.com/lean-dojo/LeanDojo-v2/llms.txt
Use this file to discover all available pages before exploring further.
ExternalAgent is the quickest path to theorem proving in LeanDojo v2 when local GPU resources are unavailable, or when you want to benchmark frontier-scale models like DeepSeek-Prover-V2-671B without managing model weights. It skips the training stage entirely — there is no trainer, no fine-tuning loop, and no checkpoint management. Instead, it delegates all inference to the HuggingFace Inference API via an ExternalProver, making it straightforward to swap in any model accessible through that API.
Class Definition
ExternalAgent extends BaseAgent. It does not build Lean dependencies during tracing (_get_build_deps() returns False) and initialises an ExternalProver backed by the specified HuggingFace Inference API model when prove() is called.
Constructor
ExternalAgent accepts only a single constructor parameter. It does not expose a database_path argument; the underlying DynamicDatabase is always initialised with its default path.
The HuggingFace Inference API model identifier. The optional
:<provider>
suffix selects a specific inference backend — for example, :novita routes
requests through the Novita inference provider. Any model accessible via the
HF Inference API can be used here.Behaviour
| Method | Detail |
|---|---|
_get_build_deps() | Always returns False. Dependency tracing is skipped to keep setup fast. |
_setup_prover() | Constructs ExternalProver(model_name=self.model_name). |
| Training | Not supported. ExternalAgent has no self.trainer; calling train() will raise an AttributeError. |
For gated models, set the
HF_TOKEN environment variable to a valid
HuggingFace access token before calling prove(). The :novita suffix in
the default model name routes requests to the Novita inference provider, which
hosts the 671B parameter DeepSeek-Prover-V2 model.Example
The following example is adapted fromexamples/external_api.py. No training step is required — prove(whole_proof=True) queries the API model directly for each sorry theorem:
setup_github_repository(), the repository is traced and all sorry theorems are extracted from the database. prove() then iterates over each unproved sorry theorem and queries the API model for a proof.
Whole-Proof Generation
whole_proof=True, prove_theorem() calls self.prover.generate_whole_proof(theorem) and prints the result. Tactic search via a Pantograph Server is bypassed entirely, which reduces API round-trips and is faster for models that can reliably produce complete proofs.
Using a Different Model
Swap in any other model available on the HuggingFace Inference API by changingmodel_name: