Repository navigation
feat(agent): multi-step extraction with per-class fillable properties - #187
Merged
Merged
Conversation
- Enforcement makes an arm a value, so orchestration can be held fixed - five arms declared, with A0 split into a prose and a json sub-arm - ProviderProfile is declared in config, never inferred from a model name - prepare() reports what a provider subset removed, as a fidelity number - core stays LLM free, oold.agent pulls only stdlib today
- ChatClient protocol, so the agent depends on a shape and not on an SDK - CallLog records every call with its step, attempt and any failure - cached and reasoning tokens held apart, because they are priced apart - appends are locked, since some orchestrations fan out across threads - agent extra declared, carrying langchain-core and nothing else
Single-shot orchestration, with every difference between arms confined to the prompt sections and the request to the provider. The shared instruction is identical across arms character for character, so a measured difference cannot be a difference in wording. - the commit gate returns its filtered result, which the predecessor did not - pinning a class slot that is absent raises, so no arm runs unconstrained while being recorded as constrained - malformed JSON is not repaired, since repairing it hides a decode failure - an unported orchestration refuses rather than silently behaving as another
- "X is what Y" does not occur in the reference corpus - "rather than" replaced by "instead of" or "not" - ruff format applied to the agent package
- some deployments accept a system message, return 200 and discard it - folding is declared per client, never applied on a guess - expose the wrapped chat model so a caller can check what it was built with - adapter tests, including the token evidence for the dropped message
- prompt_hash covers the assembled turns, folding included - message folding moves to the core client, no LangChain dependency - ExtractionResult carries prompt_sha256 beside schema_sha256
- Enforcement carries a unit enumeration beside the catalogue - A2 pins both when the corpus closes both - silent when no units are offered, loud when the slot is missing - unit enumeration size goes into the record
- catalogue_text carries what the prompt shows, kept apart from the enum - identifiers stay the answer, so a rendered entry leads with its own - length mismatch is refused, or one class is described as another
- catalogue_text reached the record but never the message - tests covered the plumbing and never read the prompt, so none failed - test_prompts asserts what each condition actually shows a model
- union_schema builds one anyOf branch per class, discriminated by const - an enum pair cannot say which unit belongs to which class; a union can - prepare() degraded a union to branch 0, losing every other class - arm A4 for the union, A2-enforced-only to separate shown from enforced - branches travel on the request, so the package learns no corpus
- select step shortlists at most k classes per entity, cap in the schema - fill step re-reads the whole document, so step one is not a bottleneck - both calls logged by step, so the orchestration can be costed - shortlist recorded per entity, so a failure names which step lost it - the graph orchestrations now say why they are not ported
- commit_gate only matched a class name against a list, never the schema - validate_output uses oold.validation.instance_checks.validate_instance - repair_attempts bounds a repair loop; the errors go back verbatim - an unrepaired answer is kept with its errors, not quietly replaced - jsonschema joins the agent extra, since the gate now needs a validator
- an anyOf reached a profile that rejects one, unseen by prepare() - the degradation measure then reported fidelity 1.000 for every A4 cell - anthropic now flattens it and reports the loss, openai keeps it
- copying every property into every branch is harmless where a class narrows one slot and ruinous where it decides which of five hundred exist - the same union came to 1.5 MB on a corpus whose flat schema is 60 kB
- a flat union repeats every inherited property in every branch - on the schema.org pool that is 3047 slots against the 851 declared - nesting states an inherited property once and keeps what the hierarchy says - sibling properties and anyOf are conjoined, so no allOf is needed - multiple inheritance does not survive a tree; the first parent is kept
- a tree holds one parent; 48 of 906 schema.org classes name two or three - LocalBusiness is an Organization and a Place, and now keeps both - allOf merges to the property union, which is what inheritance means, so a provider that rejects combinators loses nothing; anyOf flattening does - every ancestor is referenced directly, because the transform cuts a chain at the second hop and a grandparent's properties never arrive
- the depth bound ends a cycle; it was also counting composition depth - an inheritance chain three classes long arrived without its grandparent - combinator nesting no longer advances reference depth - a chain six deep now keeps every property and reports no cut
- the request carries the class hierarchy; a union then states a property where it is declared and a class with two parents keeps both - only the offered classes and their ancestors reach $defs
- pooling every entity's candidates let entity A be answered with B's class - entities that shortlisted the same classes still share a call - a split call names its entities by the words the select step read them from
- semicolons joining clauses; zero in 105k words of the reference corpus - pseudo-clefts "is what", "is how", "is where"; zero in both registers - "rather than" at 280x the corpus rate, where "instead of" or "not" fits - personified machines, British spellings, aphorism as a closing beat
- a structured-output call names a tool after the schema title - without one the provider refuses before anything is sent - the first live select-then-fill run failed all 480 cells on this
- naming the selection schema made gpt-5-nano answer {"EntityCandidates": [...]}
- correct entities under a key no wrapper name held, scored zero
- a lone key whose value is a list of objects is now read as the wrapper
- an echoed schema still yields nothing, because it is not an answer
- 3 of 16 sampled nano selections were lost this way
- a branch referencing $defs offered only the discriminator literally
- llama answered {"type": X} on 99 of 99 cells and scored 0.00
- the same union inlined by the provider transform scored 0.88
- a merge is what allOf meant, and several parents merge as readily as one
- a subclass narrowing an inherited property now wins over its declarer
- plan the document in one call, then fill one call per shortlist - pin each entity's id to the plan so both steps name the same entity - pin reference slots to the ids whose class fits the property's range - leave a slot open and record it when no planned entity fits - record every edge and flag the ones whose target was never emitted
- detect, choose properties per entity, extract, link - per-entity property enum, one array per entity over its own names - extract schema and union branches trimmed to what the step kept - a detect call answering with the schema is asked again, logged apart - close_properties and plan_retry declared; the other arms are unchanged
- the step asked for every entity and never defined one - it returned about one entity per property mention - haiku planned 7.6 entities for two-entity documents, nano 3.9 - now 3.67 and 2.80, and held-out seeds match the tuned-on ones - no count in the prompt; how many is the question being asked
- with_structured_output never set strict, so a constraint was a hint - 589 recorded cells answered outside an enum the arm had pinned - decode_strict is a field; existing arms keep their meaning - strict reaches extract, repair, detect, property and insist - a required property the property step omits is asked for, not invented
- catalogue was both the enum the grammar is built from and the list the prompt prints, so withholding it from the prompt emptied the grammar - off keeps one branch per class with its units and names none of them
- composed names were not injective: A2, A2-strict and A3 shared one label, and A0-prose and A0-json shared another - qualifiers -prose, -gated, -strict, -grounded carry the three distinctions the two-part name could not - ArmName listed five of nine registered arms
- identify, available_properties, fillable_properties, extract, so a step can be run and scored alone against known-correct input - identify clears the mentions first; an agent reused across documents answered with a mention read from the one before
- ExtractionRequest.property_text, rendered one property per line by the step that chooses between them and by no other - a vocabulary question cannot be answered by rewording the question: six models reach recall 0.92 at precision 0.55, finding the values and filing them under the wrong slot
- a property all six models named was still rejected 29 per cent of the time, and the clearest case is an award on a film whose lead mentions none: agreement there is evidence about films
- ExtractionRequest.property_evidence, off because requiring it cost gpt-oss a third of its correct answers and sonnet over half - the raw answer is kept on the agent: what a model writes there says what it thought it was reading
- new ExtractionAgent.extract_narrowed(request, plan=, filling=, classes=, properties=), reusing the narrowing _multi_step already does for its own groups (with_catalogue, _trim_properties, _trim_branches) - lets a caller holding its own oracle (a corpus's true class and fillable properties, not another step's output) send the same narrowed request, instead of the full catalogue union extract() always sends - extract() itself is unchanged
- ExtractionResult.mentions, beside selected and properties_chosen - set by select_then_fill, segmented and multi_step, empty for single shot - included in describe() - the only record of the designator when the property step declines name
A call is given the ids it fills and told the others exist, so an edge has a name to point at. A model reads both lists and reports both, and the entity then arrives from the call that owns it and from one that was only told about it. Measured on 30 WDC cells: 8 id-enum violations across 5 cells, and the duplicates cost entity precision.
- the answer shape already declares every slot as an array, so the shape permitted several values and only the wording was silent - over 60 Wikidata-lead cells at claude-haiku-4-5, 8.7 per cent of the expected values are lists and none of those lists came back whole - carried by _plan_instruction, which _extract_instruction composes, so segmented and multi-step read it in the same words - names no property and no count, because how many values a document states is part of what is being measured
- over 60 Wikidata-lead cells name is the most missed expected property, absent 59 times, though the first clause states it - applies only where the plan carries a mention for that entity and the shortlist admits the slot at all - kept and never filled, so a model declining it stays correct - reported as ExtractionResult.named beside properties_chosen, so a reader can tell the slot was kept rather than chosen
The shape walk stopped at the outermost entity, so an embedded one kept an id the plan never issued and reference slots nothing constrained. It is an entity reached differently, not a value, and needs the same two constraints. The holder is still recorded first, so the embedded shape is pinned after it and never instead of it.
- an object-valued slot is one whose shape is an object with properties,
so a link declared {"type": "object"} keeps its enum of ids
- the entities a chosen embedding absorbs are the ones _compatible_ids
gives its range, the test _pin_references already applies to a link
- an entity no holder, two holders, or a holder it would itself absorb
could take stays at the top level
- the holder's call is given the absorbed id and its properties, so the
entity is written inside it rather than lost
- reported as ExtractionResult.absorbed beside named and
properties_chosen
An extraction sends the same catalogue and schema before every call of a run while only the question after them changes, and that prefix is most of the request: one recipe page cost 140,532 input tokens over six calls, of which the document was about 1,700. Only Anthropic needs telling; OpenAI caches a long prefix itself and vLLM does it server side, so the mark is decided from the model object rather than configured.
An entity that names itself nothing cannot be pointed at, so a run with no plan could assert a class and a value for everything and an edge for nothing. One recipe page came back from a single call with 43 entities, every one correctly typed, not one carrying an id and no link between them. Required with no enum where there are no planned keys to offer.
Replacing the whole slot with a scalar enum leaves a model that answers a list unconstrained by the enum and in breach of the declared type at once. One recipe filled an array-valued recipeIngredient with seventeen ids, none of them in the enum the slot had been narrowed to, and the decode constraint never engaged.
catalogue_text[i] describes catalogue[i], the pairing with_catalogue_text refuses to let drift, and with_catalogue moved one without the other. An extract call for a group of one class was sent all 63 entries beside an enum of three, six times over a single document.
- the identify step's answer shape and wording no longer ask for an id - keys are issued in the order the answer lists its entities - an item that is not an object takes no key and leaves no gap - single shot still asks the model, having no plan to assign from
- identify breaks a tie towards the class another entity can hold - generic wording: no class, property or corpus named - asks for no extra relations, which the later steps answer
LangChain reads the first choice as generations[0][0], so a deployment answering with none raises IndexError out of library code naming neither the model nor the request. A content filter or an overloaded deployment returns one, and it is a result rather than a defect, so it now reaches the run summary as a sentence.
- ChatAnthropic takes no strict and defaults to a forced tool call, so an arm named for a decode constraint ran without one - a union arm declares the type of its discriminator, which the OpenAI subset requires - a profile names the string formats it implements, so an unsupported one degrades instead of rejecting the request - the optional-property ceiling is 16, measured, against 73 required - a provider budget for enumerated slots, which the property step divides
- the extract call answers under each planned id, so nothing arrives under an id nobody issued and no discriminator has to be guessed - the property step asks once per class, sharing one enumeration between the entities of that class - a request is sized to what the provider compiles, and halved when one is refused - the catalogue a step is shown carries the classes and properties that step may write, and nothing else - a chosen property is required, and reaches inside an embedded object
- a property taking a reference names the entities it could reach and one taking an object named nothing, so the step chose between a described name and a bare one - the class and id slots are left out, since they are bookkeeping rather than something a document states - measured on one recipe page it did not change the choice, which is worth knowing: the step has the slot, its description, its range and now its contents, and still prefers the name that matches the document
- the answer is keyed by class, so each arm gets that class's own slots - per-class attribution joins the group key, so two entities do not share arms - a bare answer broadcasts to every offered class - offers are dotted leaf paths, glossed by path and then by leaf name
- the annotation said flat where the answer has been per class - a class outside the offer cost the entity its answer with no counter - a name two candidate classes share is one slot, not two, in the budget - the working is merged per batch rather than read back off the attribute - implied links ordered, so two identical runs group the same way
- weight.value and supply.requiredQuantity.value read identically before - the object a leaf sits in is where the sentence telling them apart is
- a supply carries no id, so its item edge was asserted from the HowTo too - every item and required_quantity was drawn twice, one at the wrong level - a supply naming its own procedure became a self-loop on that procedure
- dropping it left links empty for every model, right answers included - the source is <holder>-<property>-<index>, so edge and node agree - a holder still states no edge that belongs to the object inside it
Contributor
Release previewMerging this PR would release v2.4.0 (current: Changelog preview (truncated)## v2.4.0 (2026-11-29)
Preview via python-semantic-release and conventional commits. |
Contributor
📊 Benchmark ResultsClick to see benchmark comparisonThreshold: 1.3x (30% slower triggers a regression warning) Note: Benchmarks are informational only and won't fail the build. 💡 Tip: Download the |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the LLM extraction agent (the
agentextra) to main, and merges main into it so the branch sits on v2.3.3.Changes:
<holder>-<property>-<index>), not at the entity holding it. Before, every link inside a supply was asserted twice, once from the HowTo.weight.valueandsupply.requiredQuantity.valueno longer read the same.method="json_schema"; provider profiles cap optional properties and enumerated slots.Tested: 1403 passed on the merged tree,
make checkclean. oold-llm-bench main pins commit bb7ece9 of this branch and runs against it in CI.