ontocast.stategraph.unit_context¶
Slim per-unit view of document state for the map-stage loops.
The unit render/critic loops only read a handful of document-level fields.
Passing the full :class:~ontocast.onto.state.AgentState required a deep copy
per unit (raw input bytes, docling document, every content unit, every graph),
which dominated fan-out cost. UnitLoopContext carries exactly what the
loops consume; large artifacts are shared by reference (read-only in the
loops).
Classes¶
UnitLoopContext
¶
Bases: BasePydanticModel
Document-level inputs for one unit's ontology/facts loop.
reduced_ontology_artifacts is shared by reference with the document
state — the loops only read it. retrieval_metrics is per-unit and is
folded back into the document state after the fan-out gathers.
Source code in ontocast/stategraph/unit_context.py
Attributes¶
budget_tracker = Field(default_factory=BudgetTracker)
class-attribute
instance-attribute
¶
model_config = ConfigDict(arbitrary_types_allowed=True)
class-attribute
instance-attribute
¶
ontology_context_fixed_ontology_id = ''
class-attribute
instance-attribute
¶
ontology_context_mode
instance-attribute
¶
ontology_selection_user_instruction = ''
class-attribute
instance-attribute
¶
reduced_ontology_artifacts = Field(default_factory=list)
class-attribute
instance-attribute
¶
retrieval_metrics = Field(default_factory=dict)
class-attribute
instance-attribute
¶
Methods:¶
from_agent_state(state, budget_tracker=None)
classmethod
¶
Project the loop-relevant fields off a document state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
Document-level agent state. |
required |
budget_tracker
|
BudgetTracker | None
|
Per-unit tracker LLM calls should be charged to; defaults to the document tracker (sequential pipelines). |
None
|