resolveEntity
Ask Brain which entity a surface form means — the four outcomes, and why Ambiguous writes nothing.
resolveEntity(input: ResolveEntityInput): Promise<ResolveEntityResult>resolveEntity(request: EntityResolveRequest): Promise<EntityResolveResponse>Parameters
candidateNamestringrequiredThe surface form to resolve — "Priya", "P. Raman".
resolutionContextstringoptionalSurrounding text to disambiguate with. This is what separates two people called Priya.
typeHintintegeroptionalRestrict candidates to one entity type. On the wire the field is entityTypeHint.
allowCreatebooleanoptionalCreate the entity when nothing matches, instead of answering NotFound.
Returns
outcomeResolved | Created | Ambiguous | NotFoundalwaysResolved — matched an existing entity. Created — creation was allowed and nothing matched. Ambiguous — several candidates tied. NotFound — nothing matched and creation was not allowed.
tierintegeralwaysWhich resolution tier produced the answer — exact alias, normalised form, embedding similarity, and so on. Low tiers are cheap and certain.
confidencefloatalwaysConfidence in [0, 1].
entityIdstring | nullalwaysThe resolved entity — null on Ambiguous. On the wire the field is resolvedEntity.
candidateIdsstring[]alwaysThe tied candidates, populated on Ambiguous.
Example
const r = await brain.resolveEntity({
candidateName: "Priya",
resolutionContext: "the engineer who moved to Lisbon",
allowCreate: false,
});
if (r.outcome === "Ambiguous") {
const options = await Promise.all(r.candidateIds.map((id) => brain.getEntity(id)));
return askUser(options);
}When resolution is ambiguous Brain does not pick, and it does not link. The
statement that triggered the resolution is stored with no entity attached,
and nothing is logged as an error. Reading candidateIds and deciding is
the caller's job; ignoring the outcome is how a graph quietly loses its
edges.
The wire response also carries an auditId for the resolution, which the
HTTP result omits.
On the wire
Ids are fixed-width UUID bytes rather than strings, attributes is an opaque
attributesBlob, and every request carries a requestId plus an optional
actAs. See Wire client.
Was this page helpful?