fix(prompts): name every type in suggest_entities, not just the JVM ones - #79
Open
johnsonr wants to merge 2 commits into
Open
fix(prompts): name every type in suggest_entities, not just the JVM ones#79johnsonr wants to merge 2 commits into
johnsonr wants to merge 2 commits into
Conversation
…hitecture Maps KnowledgeType onto CoALA's memory taxonomy, catalogues the mechanism decisions CoALA leaves open that DICE answers, and states scope honestly (decision loop, working-memory management, executable skills are the agent framework's job). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWLCsrVSJHggsSMf6XJZHC
The template read `domainType.clazz.simpleName`, and `clazz` exists only on
JvmType. Every DynamicType — the schema-declared types, which are most of them
in a configured world — rendered with an EMPTY name under "Entity types must
only come from the following list". A prompt that names none of its types
cannot be obeyed, and Jinjava logged one "Cannot resolve property 'clazz'" per
type per chunk: 396 warnings in one appliance's log.
`ownLabel` is the right key. For a JvmType it IS the simple name, so those
render exactly as before; it is also what extracted labels are matched back
against (DrivineNamedEntityDataRepository.save matches entity.labels() against
jvmTypes.map { it.ownLabel }).
The same template's `context.directions` was a vestige of a field that no
longer exists on SourceAnalysisContext — the block never rendered, and logged
198 more warnings. promptVariables are spread at the top level of the template
model, so plain `directions` makes the extension point real: it renders what a
caller supplies and stays silent when none did.
The new test renders the template with a DynamicType schema and fails on the
old one, in both respects.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdQPAxBM1m7CG645DKeMYa
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.
The bug
suggest_entities.jinjarendered the list of permitted types withdomainType.clazz.simpleName.clazzexists only onJvmType— aDynamicTypehasname/ownLabeland noclazz.So every schema-declared type (in a configured world, most of them) rendered as an empty name directly under:
The model is then told "You must be sure that every entity is of one of the types above" and "Use the most specific domain type possible" against a list that names nothing. Jinjava logged one warning per type per chunk — 396 in one appliance's log:
A second, separate defect in the same file:
context.directions(198 more warnings).SourceAnalysisContexthas nodirections— its fields areschema, entityResolver, contextId, knownEntities, relations, promptVariables, sourceLocator, perspective, mintNewEntities, mintedEntityProperties. It is a vestige of the fieldSourceAnalysisConfigcarried in the predecessor project; the conditional has been permanently false, so that instruction never reached a prompt. (KnowledgeGraphBuilder's KDoc still promises the context holds "schema and directions for analysis".)Together these were every template warning in that log.
The change
domainType.clazz.simpleName→domainType.ownLabel, and the parents chainmap(attribute='clazz') | map(attribute='simpleName')→map(attribute='ownLabel').ownLabelis the correct key in both directions: for aJvmTypeit is the simple name, so JVM types render byte-for-byte as before; and it is what extracted labels are matched against on the write side —DrivineNamedEntityDataRepository.savematchesentity.labels()againstdataDictionary.jvmTypes.map { it.ownLabel }.context.directions→directions.promptVariablesare spread at the top level of the template model (LlmEntityExtractor:mapOf("context" to context, "chunk" to chunk) + context.promptVariables), so this renders whatever a caller supplied viawithPromptVariablesand stays silent otherwise — turning dead markup into a working extension point. Deleting the block outright is the alternative if you'd rather not keep it.Tests
New
SuggestEntitiesTemplateTestrenders the template throughJinjavaTemplateRendereragainst aDynamicTypeschema and asserts the label, description and properties all appear, plus that directions render when supplied and are absent when not.Verified it bites: reverted to the old template → both tests fail; restored → both pass. Existing
PropositionExtractionTemplateTest(24 tests) still green.Note
embabel-object-graphcarries a copy of this template with the sameclazzdefect (pluspropose_facts.jinja) — fixed there separately. Itsdirectionsreference is correct, because itsSourceAnalysisConfigreally does have that field; that is where this one was inherited from.🤖 Generated with Claude Code
https://claude.ai/code/session_01CdQPAxBM1m7CG645DKeMYa