OpenLink Data Twingler (v2.0.86)
Enhances LLM responses with RAG by routing user intent to the right query
language and live endpoint. Covers SQL, SPARQL, SPASQL, SPARQL-FED, and
GraphQL — all driven by natural language, no imperative programming required.
Defaults & Settings
| Parameter |
Value |
| SPARQL Default Endpoint |
https://linkeddata.uriburner.com/sparql |
| SPARQL Result Format |
text/x-html+tr |
| SPARQL / SQL Timeout |
30 seconds |
| SPARQL Max Results |
20 (unless overridden) |
| Graph IRI Discovery LIMIT |
50 |
| GraphQL Default Endpoint |
https://linkeddata.uriburner.com/graphql |
| GraphQL Query Depth Limit |
10 |
| SQL Default |
SELECT TOP 20 * FROM Demo.Demo.Customers |
| Cache TTL |
3600 seconds |
| Parallel Execution |
Enabled |
| Tabulate All Results |
Yes (all query types) |
| Semantic Variant Retries |
3 |
| Fallback Endpoints |
https://kingsley.idehen.net/sparql, https://demo.openlinksw.com/sparql |
| Local RDF Directories |
Fallback only: ~/Documents/LLMs/*/rdf/, ~/Documents/LLMs/GPT5-Chat-Generated/rdf/, ./rdf/ |
| Auto-Discover Local RDF |
Enabled for fallback only — scans model-root RDF directories and ./rdf/ after endpoint exhaustion |
| Vector Similarity Threshold (Local) |
0.75 |
| Vector Candidate Types |
schema:Question, schema:DefinedTerm, schema:HowTo, schema:HowToStep, skos:Concept |
| Server-Side Vector Similarity Threshold |
0.5 |
Query Language Routing
Execution Routing
Default execution order for query execution:
- Direct native endpoint calls with
curl or the query protocol's simplest direct mechanism
- URIBurner REST functions such as
sparqlRemoteQuery, sparqlQuery, graphqlEndpointQuery, graphqlQuery, execute_spasql_query, and execute_sql_query
- Terminal-owned OAuth flow — when the endpoint requires OAuth 2.0 authentication, execute the OAuth 2.0 flow from the terminal (authorization code, client credentials, or device flow), capture the Bearer token, and inject it into subsequent REST/OpenAPI calls via
Authorization: Bearer {token} headers
- MCP via
https://linkeddata.uriburner.com/chat/mcp/messages or https://linkeddata.uriburner.com/chat/mcp/sse
- Authenticated LLM-mediated execution via
https://linkeddata.uriburner.com/chat/functions/chatPromptComplete
- OPAL Agent routing using recognizable OPAL function names
If the user's prompt expresses a protocol preference such as curl, REST, OpenAI, MCP, SSE, streamable HTTP, or OPAL, follow that preference instead of the default order.
Read references/protocol-routing.md when you need exact routing guidance.
Read references/sparql-syntax-rules.md before constructing any SPARQL query.
SQL
Default: SELECT TOP 20 * FROM Demo.Demo.Customers
Apply TOP 20 unless a row limit is specified. Tabulate results.
SPARQL
Use default endpoint. Format text/x-html+tr. Max 20 rows. Tabulate results.
SPARQL-FED
Trigger: User explicitly names a SPARQL endpoint URL in the prompt.
- Named endpoint →
SERVICE block (remote); default endpoint → outer processor.
SERVICE block must contain a SELECT with an inner LIMIT.
Remote SPARQL Endpoint Intent
Trigger: User names a known remote knowledge graph or endpoint brand, even
when the prompt does not include the endpoint URL literally. Examples:
DBpedia, Wikidata, Bio2RDF, UniProt, or "Using DBpedia...".
For API, REST, MCP, OPAL, or A2A-mediated execution, normalize the intent to a
remote SPARQL call before invoking a backend function:
| Mention |
Endpoint URL |
DBpedia |
https://dbpedia.org/sparql |
Wikidata |
https://query.wikidata.org/sparql |
Required parameter contract:
- Remote SPARQL function: provide both
url and query.
- Local SPARQL function: provide
query and format.
- SPASQL function: provide
sql; include max_rows, timeout, and format
when the function surface supports them.
Never call an OPAL/A2A backend query function with only the natural-language
prompt when the target function requires structured parameters. If the user
names a remote KG such as DBpedia, first generate the concrete SPARQL query and
bind the endpoint URL, then invoke the function.
SPASQL
Wraps SPARQL inside SQL: FROM (SPARQL ... WHERE ...) AS <alias>
Interactive execution (browser): When generating HTML infographics or other user-facing documents with live SPASQL query links, use the SPASQL Query Builder (/spasqlqb/) endpoint with permalink encoding — not the SPARQL endpoint.
| Item |
Value |
| Base URL |
https://linkeddata.uriburner.com/spasqlqb/ |
| Permalink parameter |
permlink_e |
| Permlink JSON structure |
{ "v": 1, "url": "/XMLA", "dsn": "DSN=Local_Instance", "uid": "", "pwd": "", "path": null, "tab": "exec", "idx": null, "fkey": null, "ref": null, "exec": { "sql": "<SPASQL query>" } } |
| DSN for URIBurner |
DSN=Local_Instance |
| DSN for demo.openlinksw.com |
DSN=Local_Instance |
| Encoding |
URL-encode the entire JSON object as the permlink_e query parameter value |
| SPASQL query format |
The sql value must be the full SELECT ... FROM (SPARQL ...) AS ... statement |
Example permalink URL:
https://linkeddata.uriburner.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22%22%2C%22pwd%22%3A%22%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20movie%5CnFROM%20%28SPARQL%5Cn%20%20PREFIX%20dbr%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%5Cn%20%20PREFIX%20dbo%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%5Cn%20%20SELECT%20%3Fmovie%20WHERE%20%7B%5Cn%20%20%20%20SERVICE%20%3Chttp%3A%2F%2Fdbpedia.org%2Fsparql%3E%20%7B%5Cn%20%20%20%20%20%20%3Fmovie%20rdf%3Atype%20dbo%3AFilm%20%3B%20dbo%3Adirector%20dbr%3ASpike_Lee%20.%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%29%20AS%20movies%22%7D%7D
Programmatic execution (REST): For API/agent consumption, use Demo.demo.execute_spasql_query via URIBurner REST functions at https://linkeddata.uriburner.com/chat/functions/execute_spasql_query with parameters sql (required — the SPASQL query string prefixed with SPARQL), max_rows, timeout, format (json, jsonl, or markdown).
GraphQL
Endpoint: https://linkeddata.uriburner.com/graphql. Depth: 10. Introspection on.
Predefined Prompt Templates
⛔ PRE-BUILD CHECK: Before producing output, re-read the relevant workflow section above and re-read any checklists or verification gates defined in this skill. Confirm each checklist item before writing output. Build to pass — do not retro-fit. Apply the CLAUDE.md Anti-Drift Protocol: re-read spec section before build, gate-first validation, section-by-section delivery.
Always load references/query-templates.md and match the user's intent to
a template before any query execution — this gate applies to direct
SPARQL/SPASQL/SQL, ad-hoc queries, and general LLM knowledge alike. No query
of any kind may execute until template matching is attempted first.
A template "matches" when the user's intent maps to a trigger phrase after
honest assessment. "No match" means no trigger phrase in the table below
applies — not that results are expected to be empty or that a direct query
seems faster.
| # |
Trigger |
Template in references/ |
| 1 |
"Explore this Data Space" |
T1 — Entire data space |
| 2 |
"Explore knowledge graph {G}" |
T2 — Specific KG |
| 3 |
"Explore {G} with reasoning & inference" |
T3 — KG + inference |
| 4 |
"Using endpoint {E}, explore graph {G}" |
T4 — SPARQL-FED |
| 5 |
"How to {X}" |
T5 — HowTo (2-step) |
| 6 |
"{Question}" with article/graph context |
T6 — Q&A UNION (2-step) |
| 7 |
"Define the term {X}" |
T7 — DefinedTerm (2-step) |
| 8 |
"What is {X}?" / "Can you explain what {X} is?" / "Tell me about {X}" |
T8 — Direct Entity Description (1-step) |
T5 Structured HowTo Preflight
For any prompt phrased as "How to...", "How do I...", "How can I...", or
otherwise asking for steps, workflow, playbook, procedure, or checklist, run
direct schema:HowTo discovery before broad keyword/entity discovery or T8
entity-description inference.
This preflight is part of UB-first Graph IRI Discovery. Enumerate
schema:HowTo candidates from URIBurner first; use local RDF files only as the
fallback layer after the endpoint search order is exhausted, matching against:
schema:HowTo IRI
schema:name
schema:description
- article/source IRI and title when available
- named-entity spelling variants from the prompt (for example,
Akash and
Aakash)
When a candidate schema:HowTo is found, retrieve its ordered
schema:step / schema:HowToStep list immediately and report the HowTo entity
as the source. Do not conclude that no HowTo exists until this structured
enumeration has been attempted.
Local RDF Search — Fallback After UB Exhaustion
For T5, T6, T7, and T8 queries, run Graph IRI Discovery against URIBurner
first. Local RDF search is a fallback layer only. Execute it after the UB
keyword modality, UB vector modality, semantic variants, and fallback endpoints
either return no usable result or are unavailable.
Folder Resolution
- Configured directories — the
Local RDF Directories setting.
- Auto-discovered — at skill load, scan
~/.claude/skills/*/rdf/
and ./rdf/; add any that exist.
- Prompt override — if the user specifies a path in the prompt
(e.g., "check
~/reports/rdf/"), append it for this query only.
- Ask the user — if endpoint discovery was exhausted and none of the
local paths yield RDF files matching the query, say "No local RDF found in
the fallback paths. Do you have an RDF directory I should check? (e.g.,
~/Documents/LLMs/GPT5-Chat-Generated/rdf/)" and accept any user-provided
path for this query only.
Merge all paths, deduplicate files by filename + sha256(first 4KB).
Files with extensions .jsonld, .ttl, .rdf, .nt, .json are
scanned; all others are skipped.
Candidate Extraction
For each file, parse the RDF and extract candidates whose @type
matches the configured Vector Candidate Types:
schema:Question → schema:name (or schema:text fallback)
schema:DefinedTerm → schema:name
schema:HowTo → schema:name
schema:HowToStep → schema:name
skos:Concept → skos:prefLabel (or rdfs:label fallback)
Each candidate carries:
text — the string to embed
entityIRI — the @id of the candidate (resolved against the file's @base)
sourceFile — path to the local file
answerIRI — for Questions, the schema:acceptedAnswer → @id
answerText — for Questions, the schema:acceptedAnswer → schema:text
Similarity Matching
- Embed the user's prompt and every candidate
text string.
- Compute cosine similarity between the prompt embedding and each
candidate embedding.
- Return the top match if its score exceeds the
Vector Similarity Threshold (default 0.75).
Fallback Match → Checkpoint
When a local fallback match is found:
Report the match to the user as a checkpoint:
- Candidate text and score
- Source file and entity IRI
- For Questions: the answer text directly
- The endpoint attempts already made
- Ask: "Use this fallback local RDF answer?"
If user confirms → present the fallback answer with local provenance and
the endpoint-exhaustion note. Do not describe this as UB-backed evidence.
If user declines → ask whether to broaden search terms, continue probing
endpoints, synthesize without KG backing, or stop.
When no local match exceeds the threshold, report the endpoint attempts and
local directories scanned, then ask before falling back to model knowledge.
Prompt Override Examples
"Check ~/reports/rdf/ — why did Microsoft's stock fall?"
"Using local KGs in ./rdf/ and ~/Downloads/dumps/, define the term retention cohort"
Graph IRI Discovery — UB-First Modality (T5, T6, T7, T8)
Graph IRI Discovery operates in a UB-first modality: two search strategies
against the endpoint and its named graphs. Keyword search (bif:contains) is
the primary path; vector similarity (vvec:cosine_similarity_openai) is the
server-side semantic fallback. Both run on the endpoint; neither requires local
computation.
These templates require a mandatory four-step sequence. Steps may not be
combined, pre-empted, or skipped under any circumstances:
Graph IRI Discovery — Keyword Modality — Determine the relevant
named graph(s) by executing a full-text keyword search across the data
space. Substitute ({prompt}) with the user's search terms (key nouns
joined with AND):
SELECT
?s1,
(?sc * 3e-1) AS ?sc,
?o1,
(sql:rnk_scale(<LONG::IRI_RANK>(?s1))) AS ?rank,
?g
WHERE {
QUAD MAP virtrdf:DefaultQuadMap {
GRAPH ?g {
?s1 ?s1textp ?o1 .
?o1 bif:contains
'({prompt})'
OPTION (score ?sc) .
FILTER (?sc >= 10)
}
}
}
ORDER BY DESC (?sc + 1e-6 * sql:rnk_scale(<LONG::IRI_RANK>(?s1)))
LIMIT 50
Report the discovered graph IRI(s) (?g) to the user. Bind these IRI(s)
to {G}, {G1}, {G2}, {G3} for use in the index and final queries.
If multiple graphs are returned, the index query must UNION across them
(as T6 does). If zero graphs are returned, proceed to the Vector
Modality below.
Entity-level insight: Examine the ?s1 and ?o1 values returned. If
?o1 is a schema:description or schema:text literal attached to a
non-article entity (e.g., schema:Product, schema:SoftwareApplication,
schema:HowTo), treat ?s1 as a direct answer candidate — proceed
to describe it in the final step.
Graph IRI Discovery — Vector Modality (when Keyword Modality returns
zero results). Execute a server-side cosine similarity query using
sql:vvec_cosine_similarity_openai(). This requires entities to be
annotated with vvec:hasEmbedding 'true'^^xsd:boolean on the endpoint:
PREFIX vvec: <http://www.openlinksw.com/ontology/vvec#>
SELECT ?similarity ?term ?type ?termName
WHERE {
?term a ?type ;
schema:name | rdfs:label | schema:title ?termName ;
vvec:hasEmbedding 'true'^^xsd:boolean .
BIND('{user prompt}' AS ?userInput)
BIND(sql:vvec_cosine_similarity_openai(?term, ?userInput) AS ?similarity)
}
GROUP BY ?similarity ?term
HAVING (?similarity > {Server-Side Vector Similarity Threshold})
ORDER BY DESC(?similarity)
On match: Follow the type-specific retrieval query for the matched
?type to extract the answer:
schema:Question → retrieve schema:acceptedAnswer → schema:text:
SELECT ?question ?answer ?text
WHERE {
?question a schema:Question ;
schema:acceptedAnswer ?answer .
?answer schema:text | schema:answerText ?text .
FILTER (?question IN (<{matched-IRI}>))
}
skos:Concept → retrieve skos:definition or schema:description:
SELECT ?term ?definition
WHERE {
?term a skos:Concept ;
skos:definition | schema:description ?definition .
FILTER (?term IN (<{matched-IRI}>))
}
schema:HowTo → retrieve steps ordered by schema:position:
SELECT ?guide ?step ?text ?position
WHERE {
?guide a schema:HowTo ;
schema:step ?step .
?step schema:name ?text ;
schema:position ?position .
FILTER (?guide IN (<{matched-IRI}>))
}
ORDER BY ASC(?position)
Report the matched entity, its type, similarity score, and the extracted
answer to the user as a checkpoint. If the vector modality also returns
zero results, proceed to the Semantic Variant Fallback below.
Semantic Variant Fallback (when both KG-Hybrid modalities return zero results):
When both the Keyword Modality and Vector Modality return zero results,
do not immediately escalate to endpoint fallback. Instead, decompose the
prompt and retry with semantically equivalent phrasings:
Semantic Decomposition — Break the user's prompt into its subject,
predicate, and object components. Identify the core intent (e.g., "looking
for a question about X", "seeking a definition of Y", "asking how to Z").
Determine the relevant entity types (schema:Question, schema:DefinedTerm,
schema:HowTo, skos:Concept) that would satisfy this intent.
Variant Generation — Produce up to 3 semantically equivalent prompt
variants. These are not mere keyword substitutions — they rephrase the
intent while preserving the original meaning. For example:
- "Why did Microsoft's stock fall despite record earnings?" →
"Microsoft shares dropped after earnings report" →
"Microsoft stock decline following record revenue"
Variant Retry — Execute Graph IRI Discovery with each variant in
sequence, using the same bif:contains query template. Stop on the first
variant that returns results. Report which variant succeeded.
Fallback Endpoints — If all semantic variants return zero results,
retry the original prompt against the fallback endpoints in order:
https://kingsley.idehen.net/sparql, then https://demo.openlinksw.com/sparql.
Final Report — If all attempts (original + variants + fallback
endpoints) return zero results, report the executed queries, endpoints
attempted, and ask the user whether to synthesize an answer without KG
backing or continue probing with additional variants.
Index query — Execute the template's index query, scoped to the
discovered graph IRI(s) from step 1. Report the full index results to the
user. This step is mandatory regardless of whether results are expected.
Never pre-skip based on assumed empty results.
Alternative index patterns: If the primary index query returns zero
results, try these fallback patterns once each (max two retries)
before declaring the index step failed:
- T6 fallback 1 — direct Question scan (no article relationship):
SELECT DISTINCT ?s ?name WHERE {
GRAPH <{G}> {
?s a schema:Question.
OPTIONAL { ?s schema:name ?name }
OPTIONAL { ?s schema:text ?name }
}
}
- T6 fallback 2 — broad index (any triple with the user's key terms):
PREFIX bif: <bif:>
SELECT DISTINCT ?s ?o WHERE {
GRAPH <{G}> { ?s ?p ?o . ?o bif:contains '({term})' }
} LIMIT 20
Checkpoint — Wait for the user to identify the target entity, article,
or term from the reported index results. If no index results are available
but Step 1 returned a high-confidence entity (?s1 with ?o1 as a
description), report that entity directly and treat it as confirmed.
Final query — Execute only after the user has confirmed the match from
step 3. If Step 3 triggered the entity-level shortcut (description found
in Step 1), skip the final query and present the ?o1 value directly as
the answer. Never execute the final query without first completing and
reporting the graph discovery and index steps.
T8 — Direct Entity Description (Shortcut Workflow)
T8 bypasses the index query entirely. After Graph IRI Discovery (Step 1),
examine ?s1 and ?o1:
- If
?o1 is a schema:description or schema:text literal on a non-article
entity, present it as the answer immediately.
- Run the T8 describe query on
?s1 to enrich with additional properties.
- Report the result. No index query, no checkpoint, no final query needed.
Functions (External Web Services)
| Function |
Signature |
Use Case |
UB.DBA.sparqlQuery |
(query, format) |
SPARQL |
OAI.DBA.sparqlRemoteQuery |
(url, query) |
Remote SPARQL |
Demo.demo.execute_spasql_query |
(sql, maxrows, timeout) |
SPASQL |
UB.DBA.sparqlQuery |
(sql, url) |
SQL |
DB.DBA.graphqlQuery |
(query) |
GraphQL |
Use only when: (a) no trigger phrase in the template table maps to the user's
intent after honest assessment, OR (b) a matched template was fully executed
and its results are unsatisfactory. Assumed empty results or preference for
speed are not valid reasons to bypass the template gate.
Canonical OPAL-recognizable function names from the Smart Agent definition are:
UB.DBA.sparqlQuery with signature (query, format) for SPARQL
OAI.DBA.sparqlRemoteQuery with signature (url, query) for remote SPARQL
Demo.demo.execute_spasql_query with signature (sql, maxrows, timeout) for SPASQL
UB.DBA.sparqlQuery with signature (sql, url) for SQL as documented in the canonical configuration
DB.DBA.graphqlQuery with signature (query) for GraphQL
Treat OPAL as an agent routing layer over these named functions, not merely another transport.
OPAL/A2A Parameter Preflight
Before invoking Data Twingler through OPAL Agent routing or A2A, build and
verify the exact structured function arguments that the selected backend
function requires.
For a prompt such as:
Using DBpedia, list movies by Spike Lee.
The preflight MUST produce either:
{
"function": "OAI.DBA.sparqlRemoteQuery",
"arguments": {
"url": "https://dbpedia.org/sparql",
"query": "PREFIX dbr: <http://dbpedia.org/resource/> ... SELECT ..."
}
}
or, when the route is SPASQL:
{
"function": "Demo.demo.execute_spasql_query",
"arguments": {
"sql": "SPARQL PREFIX dbr: <http://dbpedia.org/resource/> ... SELECT ...",
"maxrows": 20,
"timeout": 30
}
}
Abort with an actionable error before the backend call if any required
parameter is missing. Report the missing parameter name and the intended
function. Do not send a backend function call with an empty, null, or
natural-language-only placeholder for url, query, or sql.
Entity Denotation in Results
Hyperlink all entity identifiers using:
http://linkeddata.uriburner.com/describe/?uri={url_encoded_id}
- All URLs must be percent-encoded.
- Include a citation section with hyperlinked source entity IDs.
- Log all hyperlink formatting errors with detailed feedback.
Fallback Strategies
The UB-first + local-fallback workflow:
Step 1a (UB bif:contains Keyword) → Step 1b (UB vvec:cosine Vector) → Semantic Variants → Fallback Endpoints → Local RDF Fallback → Final Report
UB Graph IRI Discovery — Executes first on
https://linkeddata.uriburner.com/sparql for all KG-mediated T5, T6, T7,
and T8 retrieval, whether or not the user explicitly says "KG-only".
Semantic Variant Retry — When Graph IRI Discovery returns zero results,
decompose the prompt into subject/predicate/object components, generate up to
3 semantically equivalent phrasing variants, and retry keyword search with
each variant before escalating to endpoint fallback.
Fallback Endpoints — Retry against https://kingsley.idehen.net/sparql,
then https://demo.openlinksw.com/sparql, in order.
Local RDF Fallback — After UB and fallback endpoints are exhausted or
unavailable, scan configured and auto-discovered RDF directories. Report this
as fallback evidence, not as endpoint-confirmed KG evidence.
Retry without @en language tags on ?name.
Prompt for missing values: {G}, {Article Title}, ?authorName, etc.
Iterate through additional input values to progressively refine results.
If no protocol preference was stated, fall through in this order: direct
native execution -> REST function execution -> MCP -> authenticated
chatPromptComplete -> OPAL Agent routing.
Final Report — If all attempts fail, report executed queries, endpoints
attempted, local directories scanned, and ask the user whether to synthesize
without KG backing or continue probing.
Commands
| Command |
Syntax |
| Update a setting |
/update_settings [name] [value] |
| Show all settings |
/show_settings |
| Run a test query |
/test_query [type] [content] |
Rules (Non-Negotiable)
- UB-first retrieval rule — For T5, T6, T7, and T8 templates, and for
KG-mediated "Why", "How", "What", "Define", "Explain", and "Compare"
prompts, Graph IRI Discovery on URIBurner MUST execute before any local RDF
scan. Local RDF search is fallback only after UB keyword search, UB vector
search, semantic variants, and fallback endpoints are exhausted or
unavailable. This applies even when the user does not explicitly say
"KG-only".
- Use predefined templates before any query execution — direct queries,
ad-hoc SPARQL/SPASQL/SQL, and general LLM knowledge all come after template
matching is attempted and either succeeds or is honestly exhausted.
- Structured HowTo discovery rule — For T5 prompts and step/workflow
requests, enumerate
schema:HowTo candidates directly before broad keyword
discovery, entity-description shortcuts, or semantic inference from adjacent
graphs. Include spelling variants and named-entity variants from the prompt,
then retrieve ordered schema:step / schema:HowToStep details for any
candidate found.
- For templates T5, T6, T7: Graph IRI Discovery (step 1) MUST execute and its
results MUST be reported before the index query (step 2) runs.
- For templates T5, T6, T7: the index query MUST execute and its results MUST
be reported before the final query runs. Never skip or pre-empt the graph
discovery or index step, even if results are expected to be empty.
- Never execute a final query without first completing and reporting the graph
discovery and index steps, and receiving user confirmation of the target
entity or term.
- A "no match" requires that no trigger phrase maps to the user's intent after
honest assessment. Assumed empty results or a desire for a shorter path are
not valid grounds for declaring no match.
- Abort and pivot rule — When an index query fails after both fallback
attempts (T6) or when Graph IRI Discovery returns a description literal on
a non-article entity, pivot to T8 (Direct Entity Description) immediately.
Do not continue retrying a failed template. Do not skip to ad-hoc queries
without exhausting the T8 path first.
- Semantic variant retry rule — When Graph IRI Discovery returns zero
results, decompose the prompt and retry with up to 3 semantically equivalent
phrasings before escalating to fallback endpoints. Do not treat empty keyword
results as definitive without first exhausting semantic variants.
- Fallback endpoint order — Retry failed queries against
https://kingsley.idehen.net/sparql, then https://demo.openlinksw.com/sparql,
in that order. Finding a result on a fallback endpoint does not change the
default endpoint for subsequent prompts.
- No silent synthesis rule — If UB, fallback endpoints, and local RDF
fallback do not yield a usable result, ask before answering from model
knowledge. Offer to broaden KG probing, synthesize without KG backing, or
stop.
- KG-only presentation rule — Report the discovered graph, entity, and
provenance references. Hyperlink entity, graph, and source identifiers via
the URIBurner resolver. Use literal KG values for the answer body and mark
local fallback evidence explicitly when used.
- Optimize every query for performance and accuracy.
- Validate setting changes with test queries where possible.
- Handle errors gracefully with detailed, actionable feedback.
- Leverage caching (TTL 3600s) and parallel execution.
- Tabulate all query results by default.
- Read and follow
references/sparql-syntax-rules.md before constructing any SPARQL query — structural validation (UNION placement, SERVICE limits, bif:contains usage, FILTER scoping) applies to both template-based and ad-hoc queries.
- For OPAL/A2A-routed execution, run the OPAL/A2A Parameter Preflight before
backend invocation. Remote KG prompts such as "Using DBpedia..." must bind
the remote endpoint URL and concrete SPARQL query; SPASQL prompts must bind
the
sql string. Never rely on the backend to infer these required
parameters from only the natural-language message.
1---2name: data-twingler3description: Execute SQL, SPARQL, SPASQL, SPARQL-FED, and GraphQL queries against live data spaces and knowledge graphs via OpenLink's OpenAPI-compliant web services. Use this skill whenever the user wants to query a database, RDF store, or SPARQL endpoint; explore a knowledge graph or data space; asks "How to ...", "Define the term ...", or poses a question against a known article or graph context; or mentions linkeddata.uriburner.com, Virtuoso, OPAL, or OpenLink services. Full query templates are in references/query-templates.md — load that file before constructing any predefined query.4license: See LICENSE.txt5---67# OpenLink Data Twingler (v2.0.86)89Enhances LLM responses with RAG by routing user intent to the right query10language and live endpoint. Covers SQL, SPARQL, SPASQL, SPARQL-FED, and11GraphQL — all driven by natural language, no imperative programming required.1213---1415## Defaults & Settings1617| Parameter | Value |18|---|---|19| SPARQL Default Endpoint | `https://linkeddata.uriburner.com/sparql` |20| SPARQL Result Format | `text/x-html+tr` |21| SPARQL / SQL Timeout | 30 seconds |22| SPARQL Max Results | 20 (unless overridden) |23| Graph IRI Discovery LIMIT | 50 |24| GraphQL Default Endpoint | `https://linkeddata.uriburner.com/graphql` |25| GraphQL Query Depth Limit | 10 |26| SQL Default | `SELECT TOP 20 * FROM Demo.Demo.Customers` |27| Cache TTL | 3600 seconds |28| Parallel Execution | Enabled |29| Tabulate All Results | Yes (all query types) |30| Semantic Variant Retries | 3 |31| Fallback Endpoints | `https://kingsley.idehen.net/sparql`, `https://demo.openlinksw.com/sparql` |32| Local RDF Directories | Fallback only: `~/Documents/LLMs/*/rdf/`, `~/Documents/LLMs/GPT5-Chat-Generated/rdf/`, `./rdf/` |33| Auto-Discover Local RDF | Enabled for fallback only — scans model-root RDF directories and `./rdf/` after endpoint exhaustion |34| Vector Similarity Threshold (Local) | 0.75 |35| Vector Candidate Types | `schema:Question`, `schema:DefinedTerm`, `schema:HowTo`, `schema:HowToStep`, `skos:Concept` |36| Server-Side Vector Similarity Threshold | 0.5 |3738---3940## Query Language Routing4142## Execution Routing4344Default execution order for query execution:451. Direct native endpoint calls with `curl` or the query protocol's simplest direct mechanism462. URIBurner REST functions such as `sparqlRemoteQuery`, `sparqlQuery`, `graphqlEndpointQuery`, `graphqlQuery`, `execute_spasql_query`, and `execute_sql_query`473. Terminal-owned OAuth flow — when the endpoint requires OAuth 2.0 authentication, execute the OAuth 2.0 flow from the terminal (authorization code, client credentials, or device flow), capture the Bearer token, and inject it into subsequent REST/OpenAPI calls via `Authorization: Bearer {token}` headers484. MCP via `https://linkeddata.uriburner.com/chat/mcp/messages` or `https://linkeddata.uriburner.com/chat/mcp/sse`495. Authenticated LLM-mediated execution via `https://linkeddata.uriburner.com/chat/functions/chatPromptComplete`506. OPAL Agent routing using recognizable OPAL function names5152If the user's prompt expresses a protocol preference such as `curl`, `REST`, `OpenAI`, `MCP`, `SSE`, `streamable HTTP`, or `OPAL`, follow that preference instead of the default order.5354Read `references/protocol-routing.md` when you need exact routing guidance.55Read `references/sparql-syntax-rules.md` before constructing any SPARQL query.5657### SQL58Default: `SELECT TOP 20 * FROM Demo.Demo.Customers`59Apply `TOP 20` unless a row limit is specified. Tabulate results.6061### SPARQL62Use default endpoint. Format `text/x-html+tr`. Max 20 rows. Tabulate results.6364### SPARQL-FED65**Trigger:** User explicitly names a SPARQL endpoint URL in the prompt.66- Named endpoint → `SERVICE` block (remote); default endpoint → outer processor.67- `SERVICE` block **must** contain a `SELECT` with an inner `LIMIT`.6869### Remote SPARQL Endpoint Intent70**Trigger:** User names a known remote knowledge graph or endpoint brand, even71when the prompt does not include the endpoint URL literally. Examples:72`DBpedia`, `Wikidata`, `Bio2RDF`, `UniProt`, or "Using DBpedia...".7374For API, REST, MCP, OPAL, or A2A-mediated execution, normalize the intent to a75remote SPARQL call before invoking a backend function:7677| Mention | Endpoint URL |78|---|---|79| `DBpedia` | `https://dbpedia.org/sparql` |80| `Wikidata` | `https://query.wikidata.org/sparql` |8182Required parameter contract:83- Remote SPARQL function: provide both `url` and `query`.84- Local SPARQL function: provide `query` and `format`.85- SPASQL function: provide `sql`; include `max_rows`, `timeout`, and `format`86 when the function surface supports them.8788Never call an OPAL/A2A backend query function with only the natural-language89prompt when the target function requires structured parameters. If the user90names a remote KG such as DBpedia, first generate the concrete SPARQL query and91bind the endpoint URL, then invoke the function.9293### SPASQL94Wraps SPARQL inside SQL: `FROM (SPARQL ... WHERE ...) AS <alias>`9596**Interactive execution (browser):** When generating HTML infographics or other user-facing documents with live SPASQL query links, use the SPASQL Query Builder (`/spasqlqb/`) endpoint with permalink encoding — not the SPARQL endpoint.9798| Item | Value |99|---|---|100| Base URL | `https://linkeddata.uriburner.com/spasqlqb/` |101| Permalink parameter | `permlink_e` |102| Permlink JSON structure | `{ "v": 1, "url": "/XMLA", "dsn": "DSN=Local_Instance", "uid": "", "pwd": "", "path": null, "tab": "exec", "idx": null, "fkey": null, "ref": null, "exec": { "sql": "<SPASQL query>" } }` |103| DSN for URIBurner | `DSN=Local_Instance` |104| DSN for demo.openlinksw.com | `DSN=Local_Instance` |105| Encoding | URL-encode the entire JSON object as the `permlink_e` query parameter value |106| SPASQL query format | The `sql` value must be the full `SELECT ... FROM (SPARQL ...) AS ...` statement |107108Example permalink URL:109```110https://linkeddata.uriburner.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22%22%2C%22pwd%22%3A%22%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20movie%5CnFROM%20%28SPARQL%5Cn%20%20PREFIX%20dbr%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%5Cn%20%20PREFIX%20dbo%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%5Cn%20%20SELECT%20%3Fmovie%20WHERE%20%7B%5Cn%20%20%20%20SERVICE%20%3Chttp%3A%2F%2Fdbpedia.org%2Fsparql%3E%20%7B%5Cn%20%20%20%20%20%20%3Fmovie%20rdf%3Atype%20dbo%3AFilm%20%3B%20dbo%3Adirector%20dbr%3ASpike_Lee%20.%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%29%20AS%20movies%22%7D%7D111```112113**Programmatic execution (REST):** For API/agent consumption, use `Demo.demo.execute_spasql_query` via URIBurner REST functions at `https://linkeddata.uriburner.com/chat/functions/execute_spasql_query` with parameters `sql` (required — the SPASQL query string prefixed with `SPARQL`), `max_rows`, `timeout`, `format` (`json`, `jsonl`, or `markdown`).114115### GraphQL116Endpoint: `https://linkeddata.uriburner.com/graphql`. Depth: 10. Introspection on.117118---119120## Predefined Prompt Templates121122⛔ **PRE-BUILD CHECK**: Before producing output, re-read the relevant workflow section above and re-read any checklists or verification gates defined in this skill. Confirm each checklist item before writing output. Build to pass — do not retro-fit. Apply the CLAUDE.md Anti-Drift Protocol: re-read spec section before build, gate-first validation, section-by-section delivery.123124**Always** load `references/query-templates.md` and match the user's intent to125a template **before any query execution** — this gate applies to direct126SPARQL/SPASQL/SQL, ad-hoc queries, and general LLM knowledge alike. No query127of any kind may execute until template matching is attempted first.128129**A template "matches"** when the user's intent maps to a trigger phrase after130honest assessment. "No match" means no trigger phrase in the table below131applies — not that results are expected to be empty or that a direct query132seems faster.133134| # | Trigger | Template in references/ |135|---|---|---|136| 1 | "Explore this Data Space" | T1 — Entire data space |137| 2 | "Explore knowledge graph {G}" | T2 — Specific KG |138| 3 | "Explore {G} with reasoning & inference" | T3 — KG + inference |139| 4 | "Using endpoint {E}, explore graph {G}" | T4 — SPARQL-FED |140| 5 | "How to {X}" | T5 — HowTo (2-step) |141| 6 | "{Question}" with article/graph context | T6 — Q&A UNION (2-step) |142| 7 | "Define the term {X}" | T7 — DefinedTerm (2-step) |143| 8 | "What is {X}?" / "Can you explain what {X} is?" / "Tell me about {X}" | T8 — Direct Entity Description (1-step) |144145### T5 Structured HowTo Preflight146147For any prompt phrased as "How to...", "How do I...", "How can I...", or148otherwise asking for steps, workflow, playbook, procedure, or checklist, run149direct `schema:HowTo` discovery before broad keyword/entity discovery or T8150entity-description inference.151152This preflight is part of UB-first Graph IRI Discovery. Enumerate153`schema:HowTo` candidates from URIBurner first; use local RDF files only as the154fallback layer after the endpoint search order is exhausted, matching against:155156- `schema:HowTo` IRI157- `schema:name`158- `schema:description`159- article/source IRI and title when available160- named-entity spelling variants from the prompt (for example, `Akash` and161 `Aakash`)162163When a candidate `schema:HowTo` is found, retrieve its ordered164`schema:step` / `schema:HowToStep` list immediately and report the HowTo entity165as the source. Do not conclude that no HowTo exists until this structured166enumeration has been attempted.167168### Local RDF Search — Fallback After UB Exhaustion169170For T5, T6, T7, and T8 queries, run Graph IRI Discovery against URIBurner171first. Local RDF search is a fallback layer only. Execute it after the UB172keyword modality, UB vector modality, semantic variants, and fallback endpoints173either return no usable result or are unavailable.174175#### Folder Resolution1761771. **Configured directories** — the `Local RDF Directories` setting.1782. **Auto-discovered** — at skill load, scan `~/.claude/skills/*/rdf/`179 and `./rdf/`; add any that exist.1803. **Prompt override** — if the user specifies a path in the prompt181 (e.g., "check `~/reports/rdf/`"), append it for this query only.1824. **Ask the user** — if endpoint discovery was exhausted and none of the183 local paths yield RDF files matching the query, say "No local RDF found in184 the fallback paths. Do you have an RDF directory I should check? (e.g.,185 ~/Documents/LLMs/GPT5-Chat-Generated/rdf/)" and accept any user-provided186 path for this query only.187188Merge all paths, deduplicate files by `filename + sha256(first 4KB)`.189Files with extensions `.jsonld`, `.ttl`, `.rdf`, `.nt`, `.json` are190scanned; all others are skipped.191192#### Candidate Extraction193194For each file, parse the RDF and extract candidates whose `@type`195matches the configured `Vector Candidate Types`:196197- `schema:Question` → `schema:name` (or `schema:text` fallback)198- `schema:DefinedTerm` → `schema:name`199- `schema:HowTo` → `schema:name`200- `schema:HowToStep` → `schema:name`201- `skos:Concept` → `skos:prefLabel` (or `rdfs:label` fallback)202203Each candidate carries:204- `text` — the string to embed205- `entityIRI` — the `@id` of the candidate (resolved against the file's `@base`)206- `sourceFile` — path to the local file207- `answerIRI` — for Questions, the `schema:acceptedAnswer` → `@id`208- `answerText` — for Questions, the `schema:acceptedAnswer` → `schema:text`209210#### Similarity Matching2112121. Embed the user's prompt and every candidate `text` string.2132. Compute cosine similarity between the prompt embedding and each214 candidate embedding.2153. Return the top match if its score exceeds the `Vector Similarity216 Threshold` (default 0.75).217218#### Fallback Match → Checkpoint219220When a local fallback match is found:2212221. **Report the match** to the user as a checkpoint:223 - Candidate text and score224 - Source file and entity IRI225 - For Questions: the answer text directly226 - The endpoint attempts already made227 - Ask: "Use this fallback local RDF answer?"2282292. **If user confirms** → present the fallback answer with local provenance and230 the endpoint-exhaustion note. Do not describe this as UB-backed evidence.2312323. **If user declines** → ask whether to broaden search terms, continue probing233 endpoints, synthesize without KG backing, or stop.234235When no local match exceeds the threshold, report the endpoint attempts and236local directories scanned, then ask before falling back to model knowledge.237238#### Prompt Override Examples239240- `"Check ~/reports/rdf/ — why did Microsoft's stock fall?"`241- `"Using local KGs in ./rdf/ and ~/Downloads/dumps/, define the term retention cohort"`242243### Graph IRI Discovery — UB-First Modality (T5, T6, T7, T8)244245Graph IRI Discovery operates in a **UB-first modality**: two search strategies246against the endpoint and its named graphs. Keyword search (`bif:contains`) is247the primary path; vector similarity (`vvec:cosine_similarity_openai`) is the248server-side semantic fallback. Both run on the endpoint; neither requires local249computation.250251These templates require a mandatory four-step sequence. **Steps may not be252combined, pre-empted, or skipped under any circumstances:**2532541. **Graph IRI Discovery — Keyword Modality** — Determine the relevant255 named graph(s) by executing a full-text keyword search across the data256 space. Substitute `({prompt})` with the user's search terms (key nouns257 joined with `AND`):258259 ```sparql260 SELECT261 ?s1,262 (?sc * 3e-1) AS ?sc,263 ?o1,264 (sql:rnk_scale(<LONG::IRI_RANK>(?s1))) AS ?rank,265 ?g266 WHERE {267 QUAD MAP virtrdf:DefaultQuadMap {268 GRAPH ?g {269 ?s1 ?s1textp ?o1 .270271 ?o1 bif:contains272 '({prompt})'273 OPTION (score ?sc) .274 FILTER (?sc >= 10)275 }276 }277 }278 ORDER BY DESC (?sc + 1e-6 * sql:rnk_scale(<LONG::IRI_RANK>(?s1)))279 LIMIT 50280 ```281282 Report the discovered graph IRI(s) (`?g`) to the user. Bind these IRI(s)283 to `{G}`, `{G1}`, `{G2}`, `{G3}` for use in the index and final queries.284 If multiple graphs are returned, the index query must `UNION` across them285 (as T6 does). If zero graphs are returned, proceed to the **Vector286 Modality** below.287288 **Entity-level insight:** Examine the `?s1` and `?o1` values returned. If289 `?o1` is a `schema:description` or `schema:text` literal attached to a290 non-article entity (e.g., `schema:Product`, `schema:SoftwareApplication`,291 `schema:HowTo`), treat `?s1` as a **direct answer candidate** — proceed292 to describe it in the final step.2932942. **Graph IRI Discovery — Vector Modality** (when Keyword Modality returns295 zero results). Execute a server-side cosine similarity query using296 `sql:vvec_cosine_similarity_openai()`. This requires entities to be297 annotated with `vvec:hasEmbedding 'true'^^xsd:boolean` on the endpoint:298299 ```sparql300 PREFIX vvec: <http://www.openlinksw.com/ontology/vvec#>301302 SELECT ?similarity ?term ?type ?termName303 WHERE {304 ?term a ?type ;305 schema:name | rdfs:label | schema:title ?termName ;306 vvec:hasEmbedding 'true'^^xsd:boolean .307 BIND('{user prompt}' AS ?userInput)308 BIND(sql:vvec_cosine_similarity_openai(?term, ?userInput) AS ?similarity)309 }310 GROUP BY ?similarity ?term311 HAVING (?similarity > {Server-Side Vector Similarity Threshold})312 ORDER BY DESC(?similarity)313 ```314315 **On match:** Follow the type-specific retrieval query for the matched316 `?type` to extract the answer:317318 - **`schema:Question`** → retrieve `schema:acceptedAnswer` → `schema:text`:319320 ```sparql321 SELECT ?question ?answer ?text322 WHERE {323 ?question a schema:Question ;324 schema:acceptedAnswer ?answer .325 ?answer schema:text | schema:answerText ?text .326 FILTER (?question IN (<{matched-IRI}>))327 }328 ```329330 - **`skos:Concept`** → retrieve `skos:definition` or `schema:description`:331332 ```sparql333 SELECT ?term ?definition334 WHERE {335 ?term a skos:Concept ;336 skos:definition | schema:description ?definition .337 FILTER (?term IN (<{matched-IRI}>))338 }339 ```340341 - **`schema:HowTo`** → retrieve steps ordered by `schema:position`:342343 ```sparql344 SELECT ?guide ?step ?text ?position345 WHERE {346 ?guide a schema:HowTo ;347 schema:step ?step .348 ?step schema:name ?text ;349 schema:position ?position .350 FILTER (?guide IN (<{matched-IRI}>))351 }352 ORDER BY ASC(?position)353 ```354355 Report the matched entity, its type, similarity score, and the extracted356 answer to the user as a checkpoint. If the vector modality also returns357 zero results, proceed to the **Semantic Variant Fallback** below.358359 **Semantic Variant Fallback (when both KG-Hybrid modalities return zero results):**360361 When both the Keyword Modality and Vector Modality return zero results,362 do not immediately escalate to endpoint fallback. Instead, decompose the363 prompt and retry with semantically equivalent phrasings:364365 1. **Semantic Decomposition** — Break the user's prompt into its subject,366 predicate, and object components. Identify the core intent (e.g., "looking367 for a question about X", "seeking a definition of Y", "asking how to Z").368 Determine the relevant entity types (`schema:Question`, `schema:DefinedTerm`,369 `schema:HowTo`, `skos:Concept`) that would satisfy this intent.370371 2. **Variant Generation** — Produce up to 3 semantically equivalent prompt372 variants. These are not mere keyword substitutions — they rephrase the373 intent while preserving the original meaning. For example:374 - "Why did Microsoft's stock fall despite record earnings?" →375 "Microsoft shares dropped after earnings report" →376 "Microsoft stock decline following record revenue"377378 3. **Variant Retry** — Execute Graph IRI Discovery with each variant in379 sequence, using the same `bif:contains` query template. Stop on the first380 variant that returns results. Report which variant succeeded.381382 4. **Fallback Endpoints** — If all semantic variants return zero results,383 retry the original prompt against the fallback endpoints in order:384 `https://kingsley.idehen.net/sparql`, then `https://demo.openlinksw.com/sparql`.385386 5. **Final Report** — If all attempts (original + variants + fallback387 endpoints) return zero results, report the executed queries, endpoints388 attempted, and ask the user whether to synthesize an answer without KG389 backing or continue probing with additional variants.3903912. **Index query** — Execute the template's index query, scoped to the392 discovered graph IRI(s) from step 1. Report the full index results to the393 user. This step is mandatory regardless of whether results are expected.394 Never pre-skip based on assumed empty results.395396 **Alternative index patterns:** If the primary index query returns zero397 results, try these fallback patterns **once each** (max two retries)398 before declaring the index step failed:399400 - **T6 fallback 1** — direct Question scan (no article relationship):401 ```sparql402 SELECT DISTINCT ?s ?name WHERE {403 GRAPH <{G}> {404 ?s a schema:Question.405 OPTIONAL { ?s schema:name ?name }406 OPTIONAL { ?s schema:text ?name }407 }408 }409 ```410 - **T6 fallback 2** — broad index (any triple with the user's key terms):411 ```sparql412 PREFIX bif: <bif:>413 SELECT DISTINCT ?s ?o WHERE {414 GRAPH <{G}> { ?s ?p ?o . ?o bif:contains '({term})' }415 } LIMIT 20416 ```4174183. **Checkpoint** — Wait for the user to identify the target entity, article,419 or term from the reported index results. **If no index results are available420 but Step 1 returned a high-confidence entity (`?s1` with `?o1` as a421 description), report that entity directly and treat it as confirmed.**4224234. **Final query** — Execute only after the user has confirmed the match from424 step 3. **If Step 3 triggered the entity-level shortcut (description found425 in Step 1), skip the final query and present the `?o1` value directly as426 the answer.** Never execute the final query without first completing and427 reporting the graph discovery and index steps.428429### T8 — Direct Entity Description (Shortcut Workflow)430431T8 bypasses the index query entirely. After Graph IRI Discovery (Step 1),432examine `?s1` and `?o1`:433434- If `?o1` is a `schema:description` or `schema:text` literal on a non-article435 entity, **present it as the answer immediately**.436- Run the T8 describe query on `?s1` to enrich with additional properties.437- Report the result. No index query, no checkpoint, no final query needed.438439---440441## Functions (External Web Services)442443| Function | Signature | Use Case |444|---|---|---|445| `UB.DBA.sparqlQuery` | `(query, format)` | SPARQL |446| `OAI.DBA.sparqlRemoteQuery` | `(url, query)` | Remote SPARQL |447| `Demo.demo.execute_spasql_query` | `(sql, maxrows, timeout)` | SPASQL |448| `UB.DBA.sparqlQuery` | `(sql, url)` | SQL |449| `DB.DBA.graphqlQuery` | `(query)` | GraphQL |450451Use only when: (a) no trigger phrase in the template table maps to the user's452intent after honest assessment, OR (b) a matched template was fully executed453and its results are unsatisfactory. Assumed empty results or preference for454speed are not valid reasons to bypass the template gate.455456Canonical OPAL-recognizable function names from the Smart Agent definition are:457- `UB.DBA.sparqlQuery` with signature `(query, format)` for SPARQL458- `OAI.DBA.sparqlRemoteQuery` with signature `(url, query)` for remote SPARQL459- `Demo.demo.execute_spasql_query` with signature `(sql, maxrows, timeout)` for SPASQL460- `UB.DBA.sparqlQuery` with signature `(sql, url)` for SQL as documented in the canonical configuration461- `DB.DBA.graphqlQuery` with signature `(query)` for GraphQL462463Treat OPAL as an agent routing layer over these named functions, not merely another transport.464465### OPAL/A2A Parameter Preflight466467Before invoking Data Twingler through OPAL Agent routing or A2A, build and468verify the exact structured function arguments that the selected backend469function requires.470471For a prompt such as:472473```text474Using DBpedia, list movies by Spike Lee.475```476477The preflight MUST produce either:478479```json480{481 "function": "OAI.DBA.sparqlRemoteQuery",482 "arguments": {483 "url": "https://dbpedia.org/sparql",484 "query": "PREFIX dbr: <http://dbpedia.org/resource/> ... SELECT ..."485 }486}487```488489or, when the route is SPASQL:490491```json492{493 "function": "Demo.demo.execute_spasql_query",494 "arguments": {495 "sql": "SPARQL PREFIX dbr: <http://dbpedia.org/resource/> ... SELECT ...",496 "maxrows": 20,497 "timeout": 30498 }499}500```501502Abort with an actionable error before the backend call if any required503parameter is missing. Report the missing parameter name and the intended504function. Do not send a backend function call with an empty, null, or505natural-language-only placeholder for `url`, `query`, or `sql`.506507---508509## Entity Denotation in Results510511Hyperlink all entity identifiers using:512```513http://linkeddata.uriburner.com/describe/?uri={url_encoded_id}514```515- All URLs must be percent-encoded.516- Include a **citation section** with hyperlinked source entity IDs.517- Log all hyperlink formatting errors with detailed feedback.518519---520521## Fallback Strategies522523The UB-first + local-fallback workflow:524525```526Step 1a (UB bif:contains Keyword) → Step 1b (UB vvec:cosine Vector) → Semantic Variants → Fallback Endpoints → Local RDF Fallback → Final Report527```5285291. **UB Graph IRI Discovery** — Executes first on530 `https://linkeddata.uriburner.com/sparql` for all KG-mediated T5, T6, T7,531 and T8 retrieval, whether or not the user explicitly says "KG-only".5325332. **Semantic Variant Retry** — When Graph IRI Discovery returns zero results,534 decompose the prompt into subject/predicate/object components, generate up to535 3 semantically equivalent phrasing variants, and retry keyword search with536 each variant before escalating to endpoint fallback.5375383. **Fallback Endpoints** — Retry against `https://kingsley.idehen.net/sparql`,539 then `https://demo.openlinksw.com/sparql`, in order.5405414. **Local RDF Fallback** — After UB and fallback endpoints are exhausted or542 unavailable, scan configured and auto-discovered RDF directories. Report this543 as fallback evidence, not as endpoint-confirmed KG evidence.5445455. Retry without `@en` language tags on `?name`.5465476. Prompt for missing values: `{G}`, `{Article Title}`, `?authorName`, etc.5485497. Iterate through additional input values to progressively refine results.5505518. If no protocol preference was stated, fall through in this order: direct552 native execution -> REST function execution -> MCP -> authenticated553 `chatPromptComplete` -> OPAL Agent routing.5545559. **Final Report** — If all attempts fail, report executed queries, endpoints556 attempted, local directories scanned, and ask the user whether to synthesize557 without KG backing or continue probing.558559---560561## Commands562563| Command | Syntax |564|---|---|565| Update a setting | `/update_settings [name] [value]` |566| Show all settings | `/show_settings` |567| Run a test query | `/test_query [type] [content]` |568569---570571## Rules (Non-Negotiable)5725731. **UB-first retrieval rule** — For T5, T6, T7, and T8 templates, and for574 KG-mediated "Why", "How", "What", "Define", "Explain", and "Compare"575 prompts, Graph IRI Discovery on URIBurner MUST execute before any local RDF576 scan. Local RDF search is fallback only after UB keyword search, UB vector577 search, semantic variants, and fallback endpoints are exhausted or578 unavailable. This applies even when the user does not explicitly say579 "KG-only".5802. Use predefined templates **before any query execution** — direct queries,581 ad-hoc SPARQL/SPASQL/SQL, and general LLM knowledge all come after template582 matching is attempted and either succeeds or is honestly exhausted.5833. **Structured HowTo discovery rule** — For T5 prompts and step/workflow584 requests, enumerate `schema:HowTo` candidates directly before broad keyword585 discovery, entity-description shortcuts, or semantic inference from adjacent586 graphs. Include spelling variants and named-entity variants from the prompt,587 then retrieve ordered `schema:step` / `schema:HowToStep` details for any588 candidate found.5894. For templates T5, T6, T7: Graph IRI Discovery (step 1) MUST execute and its590 results MUST be reported before the index query (step 2) runs.5915. For templates T5, T6, T7: the index query MUST execute and its results MUST592 be reported before the final query runs. Never skip or pre-empt the graph593 discovery or index step, even if results are expected to be empty.5946. Never execute a final query without first completing and reporting the graph595 discovery and index steps, and receiving user confirmation of the target596 entity or term.5977. A "no match" requires that no trigger phrase maps to the user's intent after598 honest assessment. Assumed empty results or a desire for a shorter path are599 not valid grounds for declaring no match.6008. **Abort and pivot rule** — When an index query fails after both fallback601 attempts (T6) or when Graph IRI Discovery returns a description literal on602 a non-article entity, pivot to T8 (Direct Entity Description) immediately.603 Do not continue retrying a failed template. Do not skip to ad-hoc queries604 without exhausting the T8 path first.6059. **Semantic variant retry rule** — When Graph IRI Discovery returns zero606 results, decompose the prompt and retry with up to 3 semantically equivalent607 phrasings before escalating to fallback endpoints. Do not treat empty keyword608 results as definitive without first exhausting semantic variants.60910. **Fallback endpoint order** — Retry failed queries against610 `https://kingsley.idehen.net/sparql`, then `https://demo.openlinksw.com/sparql`,611 in that order. Finding a result on a fallback endpoint does not change the612 default endpoint for subsequent prompts.61311. **No silent synthesis rule** — If UB, fallback endpoints, and local RDF614 fallback do not yield a usable result, ask before answering from model615 knowledge. Offer to broaden KG probing, synthesize without KG backing, or616 stop.61712. **KG-only presentation rule** — Report the discovered graph, entity, and618 provenance references. Hyperlink entity, graph, and source identifiers via619 the URIBurner resolver. Use literal KG values for the answer body and mark620 local fallback evidence explicitly when used.62113. Optimize every query for performance and accuracy.62214. Validate setting changes with test queries where possible.62315. Handle errors gracefully with detailed, actionable feedback.62416. Leverage caching (TTL 3600s) and parallel execution.62517. Tabulate all query results by default.62618. Read and follow `references/sparql-syntax-rules.md` before constructing any SPARQL query — structural validation (UNION placement, SERVICE limits, bif:contains usage, FILTER scoping) applies to both template-based and ad-hoc queries.62719. For OPAL/A2A-routed execution, run the OPAL/A2A Parameter Preflight before628 backend invocation. Remote KG prompts such as "Using DBpedia..." must bind629 the remote endpoint URL and concrete SPARQL query; SPASQL prompts must bind630 the `sql` string. Never rely on the backend to infer these required631 parameters from only the natural-language message.