KnowQL
Working Draft — Version 0.1.0 — August 6, 2026
Introduction
This is the specification for KnowQL, a declarative query language for agent knowledge access — SQL’s equivalent for the agentic era.
KnowQL defines a query document (one turn), a session (a multi-turn thread over a fixed scope of knowledge contexts), and the response and delivery contracts that implementations MUST honor. It does not mandate a retrieval algorithm, embedding model, storage backend, or transport beyond the JSON document shapes defined here.
A conforming implementation of KnowQL 0.1.0 MUST fulfill all normative requirements described in this specification (see Conformance). The specification is provided under the Open Web Foundation Agreement 1.0 (see Copyright and Licensing).
KnowQL was created in 2026 as part of the Pinecone Nexus platform. This open specification is published so agent frameworks, knowledge services, and tooling can implement the same contract.
This specification is developed on GitHub at pinecone-io/knowql-spec. Contributions and discussion are welcome.
This working draft is published at https://spec.knowql.org/0.1.0.
1Overview
KnowQL is the agent-facing contract for asking questions over contexts — compiled knowledge units that an implementation prepares out of band (ingest, curate, index). The agent does not specify how to retrieve; it declares what it wants to know, over which contexts, and in what form.
A query is one turn: input in, answer out. A session is a durable thread of queries over a pinned scope. There is no separate “agent” entity in the language — per-session configuration is passed at session creation and fixed for the session’s life.
1.1Example
A free-form turn over one context:
{
"ask": "Compare Q3 revenue across the targets.",
"scope": ["vantage-data-room"]
}
A structured turn that continues a session:
{
"ask": "Does Acme Corp qualify for a renewal discount?",
"session_id": "ses_…",
"shape": {
"type": "object",
"properties": {
"qualifies": { "type": "boolean" },
"discount_pct": { "type": "number" },
"reason": { "type": "string" }
},
"required": ["qualifies"]
}
}
A retrieval-only turn (no synthesis):
{
"ask": "payment terms Acme current contract",
"scope": ["ctx_contracts"],
"retrieval_only": true,
"max_retrieved": 20
}
1.2Design principles
Declarative. The query document states intent, scope, shape, and controls. Clause order does not change meaning. The engine chooses retrieval and synthesis strategy.
Turn-based. One query document produces one response document. Multi-turn conversation is a sequence of queries chained by session identity.
Grounded by default. Implementations SHOULD return citations that point back into the scoped knowledge. Retrieval-only mode returns the retrieved material itself.
Transport-agnostic document. The canonical form is JSON. HTTP bindings (paths, status codes, SSE) are RECOMMENDED shapes in this document, not the only legal transport.
Honest about determinism. Retrieval ranking and free-form synthesis are probabilistic. Structural contracts — shape conformity, retrieval-only payload layout, session scope pinning — are deterministic for a given implementation and knowledge snapshot.
1.3What 0.1.0 covers
Version 0.1.0 specifies the functional surface of a production query API:
| Area | Status |
|---|---|
ask, scope, session chaining |
Functional |
Free-form and shape (JSON Schema) answers |
Functional |
| Sync, SSE stream, background poll | Functional |
| Session pin: system prompt, guardrails, vars, models, tools | Functional |
| Per-turn model, tools, timeout, step budget, thinking level | Functional |
| Retrieval-only and compose controls | Functional |
| Citations, usage, steps, status lifecycle | Functional |
Metadata where, field-level ground, budget, temporal, joins |
Future |
1.4Out of scope
This specification does not define:
- How contexts are built (ingest, curation, manifests, indexes)
- Authentication, tenancy, or billing
- Any particular model provider or tool runtime
- Client SDKs
Implementations MAY extend the document with additional fields. Extensions MUST NOT redefine the meaning of fields defined here.
2Data Model
KnowQL 0.1.0 has three first-class entities on the query surface.
2.1Context
:: A context is a named unit of knowledge that a query may scope over. Contexts are created and curated outside KnowQL. From the query language’s point of view, a context is an opaque identifier (slug or UUID) that the implementation resolves to a queryable knowledge base.
A context is queryable when the implementation is prepared to answer over it. Implementations MUST reject a new session whose scope includes a context that is not yet queryable, unless the implementation documents a deliberate open-empty behavior for that context kind.
2.2Query
:: A query is one turn — the object created by submitting a Query Document. It carries the caller’s ask, optional per-turn controls, normalized input messages, and (once complete) output, structured result, citations, usage, and status.
Lifecycle states:
| State | Terminal | Meaning |
|---|---|---|
in_progress |
no | Accepted; execution not finished |
completed |
yes | Finished successfully |
failed |
yes | Finished with error |
cancelled |
yes | Aborted by client or system |
A query is created in in_progress and transitions to exactly one terminal state.
2.3Session
:: A session is a durable conversation: an ordered chain of queries plus a pinned configuration. Scope and session-level config are fixed at creation and apply to every subsequent turn.
A session is project-owned (or equivalent tenancy boundary) and is a top-level resource — not nested under an “agent” entity. There is no persisted agent object in KnowQL 0.1.0.
Pinned at creation (see Sessions):
scope— 1–10 context identifierssystem_prompt— optional guidance prepended every turnguardrails— optional hard constraints every turnmodels— optional default model preference listtools— optional default tool subsetvars— optional implementation-defined env / config map
Not pinned on the session: shape, retrieval-only controls, stream, background, timeout_seconds, max_steps, thinking_level. Those are per-turn.
2.4Relationship
Session 1──* Query
Session *──* Context (via fixed scope, 1–10)
Query ?──1 Query (previous_query_id chain)
Listing a session’s queries in creation order reconstructs the full conversation. There is no separate message store in the language model — each query row holds its turn’s input and output.
3Query Document
:: A Query Document is a JSON object submitted to start or continue a KnowQL turn. All fields defined in this section are part of version 0.1.0 unless marked Future.
QueryDocument :
{
"ask" : StringValue
"scope" : [ ContextRef ] ?
"previous_query_id" : QueryId ?
"session_id" : SessionId ?
"shape" : JsonSchema ?
"model" : StringValue ?
"models" : [ StringValue ] ?
"tools" : [ StringValue ] ?
"system_prompt" : StringValue ?
"guardrails" : StringValue ?
"vars" : ObjectValue ?
"stream" : BooleanValue ?
"background" : BooleanValue ?
"timeout_seconds" : NumberValue ?
"max_steps" : NumberValue ?
"thinking_level" : ThinkingLevel ?
"compose" : BooleanValue ?
"retrieval_only" : BooleanValue ?
"pointers_only" : BooleanValue ?
"chunks_only" : BooleanValue ?
"artifacts_only" : BooleanValue ?
"max_retrieved" : NumberValue ?
"max_retrieved_chars" : NumberValue ?
"workflow" : StringValue ?
"comparison_group" : StringValue ?
}
ContextRef is a string context slug or UUID. QueryId / SessionId are opaque string identifiers. JsonSchema is a JSON Schema object (see Structured Output). ThinkingLevel is one of "minimal", "low", "medium", "high".
3.1Intent
3.1.1`ask`
Required.
Natural-language question for this turn. MUST be a non-empty string after trimming. The implementation normalizes it to a single user message in the query’s input array:
[{ "role": "user", "content": "<ask text>" }]
ask is the primary semantic signal for retrieval and synthesis.
3.1.2`shape`
Optional. Per-turn.
JSON Schema describing the structured result. When present, a successful turn MUST populate output_json with a document that conforms to the schema (see Structured Output). When absent, the answer is free-form natural language in output.
shape is not pinned on the session. Each turn may supply its own, or omit it.
3.2Scope and session binding
3.2.1`scope`
Required when starting a new session. Ignored when continuing.
Array of 1–10 context identifiers. Duplicates MAY be collapsed. Implementations MUST reject:
- empty scope or more than 10 entries
- unknown or non-queryable contexts
- scopes that mix incompatible context kinds, if the implementation defines such kinds (e.g. work vs search)
scope is pinned for the session’s life. Follow-up turns MUST NOT change it.
3.2.2`previous_query_id`
Optional.
Continue the session that owns this query. The new turn is chained after that query. Implementations MUST reject an unknown or cross-tenant id.
3.2.3`session_id`
Optional.
Continue an explicit session. Equivalent in effect to continuing from the session’s latest query, unless the implementation documents otherwise.
If both previous_query_id and session_id are omitted, the turn starts a new session and scope (plus other new-session fields) MUST be honored.
If both are provided, implementations SHOULD prefer a consistent rule (e.g. require they refer to the same session) and MUST NOT silently attach to an unrelated session.
3.3Model and tools
3.3.1`model`
Optional. Per-turn.
Model selection string. The format is implementation-defined (commonly provider/model or a tier name such as standard). When omitted, the implementation default applies (session pin, then service default).
3.3.2`models`
Optional. Per-turn.
Ordered fallback list. When present, takes precedence over model. The implementation tries models in order until one serves the turn.
3.3.3`tools`
Optional. Per-turn (or session pin on create).
Subset of tools the turn may use. Empty or omitted means the implementation default tool belt. Tool names are implementation-defined.
3.4Session configuration (new session only)
These fields are honored only when the document starts a new session. On a continuing turn they MUST be ignored (or rejected — implementations SHOULD document which).
3.4.1`system_prompt`
Optional natural-language guidance prepended for every turn in the session.
3.4.2`guardrails`
Optional hard constraints appended for every turn (e.g. citation policy, safety rules).
3.4.3`vars`
Optional JSON object of implementation-defined overrides (env, model tier pins, feature flags). Opaque to the language; validated by the implementation.
3.5Delivery controls
3.5.1`stream`
Optional. Default `false`.
When true, the turn is delivered as a stream of events (see Delivery). Mutually exclusive with background.
3.5.2`background`
Optional. Default `false`.
When true, the implementation accepts the turn, returns the in_progress query document immediately, and finalizes asynchronously. The client polls by query id. Mutually exclusive with stream.
3.5.3`timeout_seconds`
Optional.
Upper bound on turn execution time in seconds. Implementations MUST define a maximum (RECOMMENDED default and ceiling: 900). Callers may only lower the effective timeout relative to that ceiling.
3.6Execution controls
3.6.1`max_steps`
Optional. Per-turn.
Maximum agentic tool-loop iterations before the engine must answer. Positive integer. When omitted, the implementation default applies.
3.6.2`thinking_level`
Optional. Per-turn.
Reasoning depth hint for models that support it:
| Value | Intent |
|---|---|
minimal |
Fastest / cheapest |
low |
Default when omitted (implementation MAY choose another default) |
medium |
Balanced |
high |
Harder reasoning; higher latency/cost |
Case-insensitive on input; implementations SHOULD normalize to lowercase. Unknown values MUST be rejected.
3.6.3`workflow`
Optional. Per-turn or session-defining.
Execution strategy selector. Values are implementation-defined. A reference mapping used by the originating implementation:
| Value | Meaning |
|---|---|
search |
Default: curated artifacts + source chunks |
search_cc |
Coding-agent strategy over the source tree |
search_rag |
Agentic RAG over the chunk index |
Legacy aliases MAY be accepted. Unknown values MUST be rejected. Implementations that expose only one strategy MAY ignore this field.
3.6.4`comparison_group`
Optional. Per-turn.
Client-generated opaque string grouping parallel turns that should share a concurrency / quota bucket (e.g. side-by-side compare). Omit for a normal single query. Semantics of grouping are implementation-defined; the field is reserved and functional where compare UIs exist.
3.7Retrieval / compose controls
See Retrieval Modes for full semantics.
| Field | Default | Effect |
|---|---|---|
compose |
true |
When false, skip synthesis; return retrieved material |
retrieval_only |
false |
Skip synthesis; return chunks + artifacts in output_json |
pointers_only |
false |
Like retrieval-only but drop verbatim text |
chunks_only |
false |
Retrieval-only; source chunks only |
artifacts_only |
false |
Retrieval-only; derived artifacts only |
max_retrieved |
none | Cap combined retrieved item count |
max_retrieved_chars |
none | Cap per-item verbatim text length |
These are per-turn and are not pinned on the session.
3.8Fields not in 0.1.0
The following names appeared in earlier drafts or are reserved for later versions. They are not required, and implementations MUST NOT treat them as part of Core 0.1.0 conformance. See Future Work.
where, ground, budget, explain, as_of, since, window, link, resolve, trace (as a request primitive), await, apply.
4Response Document
:: A Response Document is the wire form of a query after acceptance (and, when terminal, after execution). Object type is always "query".
ResponseDocument :
{
"id" : QueryId
"object" : "query"
"session_id" : SessionId
"model" : StringValue | null
"created" : NumberValue
"status" : Status
"error" : StringValue | null
"previous_query_id" : QueryId | null
"comparison" : Value | null
"feedback" : Value | null
"input" : [ Message ]
"output" : [ OutputItem ]
"output_json" : Value | null
"citations" : [ Citation ]
"steps" : [ Step ]
"rollup" : Value | null
"synthesis" : Value | null
"trace_ref" : StringValue | null
"usage" : Usage
"runtime_ms" : NumberValue
}
Status : "in_progress" | "completed" | "failed" | "cancelled"
Message :
{ "role": "user" | "assistant" | "system", "content": StringValue }
OutputItem :
{
"role": "assistant",
"content": [ { "type": "output_text", "text": StringValue } ]
}
Usage :
{
"input_tokens" : NumberValue
"output_tokens" : NumberValue
"total_tokens" : NumberValue
"cost_usd" : NumberValue ?
}
4.1Field semantics
4.1.1Identity and status
| Field | Description |
|---|---|
id |
Query id assigned at accept time |
session_id |
Owning session |
created |
Unix timestamp (seconds) of creation |
status |
Lifecycle state |
error |
Human-readable error when failed; otherwise null/absent |
previous_query_id |
Predecessor turn, if any |
model |
Model that actually served the turn (may differ from request) |
4.1.2`input`
Normalized message array for this turn. At minimum the user ask. On multi-turn sessions the implementation MAY also expose full replay history via internal fields; the durable per-turn input is this turn’s user message(s).
4.1.3`output`
Assistant output items. Empty while in_progress. On completed, free-form answers appear as output_text parts. Shape-only results MAY use empty prose with the structured document in output_json.
4.1.4`output_json`
Present when:
- The turn carried a
shapeand synthesis produced a conforming document, or - The turn ran in a retrieval mode that returns structured retrieved material.
Otherwise null or absent.
4.1.5`citations`
Array of provenance objects for the answer. Exact schema is implementation-defined; each entry SHOULD identify a source location (context, document/path, optional offsets or section path, optional score). Empty when no citations apply (e.g. pure retrieval-only with material already in output_json).
4.1.6`steps`
Agent trace: tool calls, retrieval steps, commentary. Used for streaming progress and post-hoc debugging. Shape is implementation-defined; stream events of type response.step feed this list.
4.1.7`rollup` / `synthesis` / `trace_ref`
Optional diagnostic envelopes produced by the runtime (turn totals, synthesis metadata, external trace handle). MAY be null.
4.1.8`usage`
Token accounting for the turn. total_tokens MUST equal input_tokens + output_tokens when both are reported. cost_usd is OPTIONAL; when present it is the authoritative dollar cost if the implementation dollarizes usage.
4.1.9`runtime_ms`
Wall-clock milliseconds from accept to terminal state (0 while in progress).
4.1.10`comparison` / `feedback`
Optional product fields: membership in a compare set, and viewer rating/comment. Not required for Core conformance beyond round-tripping when the implementation supports them.
4.2Example (completed free-form)
{
"id": "qry_01h…",
"object": "query",
"session_id": "ses_01h…",
"model": "anthropic/claude-sonnet-4-6",
"created": 1786051200,
"status": "completed",
"error": null,
"previous_query_id": null,
"input": [{ "role": "user", "content": "What are Acme's payment terms?" }],
"output": [
{
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Net 30 on the current MSA, with 2% 10 net 30 on renewals."
}
]
}
],
"output_json": null,
"citations": [{ "source": "contracts/acme-msa.pdf", "section_path": "§4.2" }],
"steps": [],
"usage": {
"input_tokens": 4200,
"output_tokens": 180,
"total_tokens": 4380,
"cost_usd": 0.012
},
"runtime_ms": 12400
}
4.3Example (shaped)
When shape was supplied, output_json holds the conforming object:
{
"status": "completed",
"output": [
{
"role": "assistant",
"content": [{ "type": "output_text", "text": "" }]
}
],
"output_json": {
"qualifies": true,
"discount_pct": 12.5,
"reason": "12-month renewal with >80% usage"
},
"citations": [{ "source": "pricing/tier-2.md" }]
}
4.4Errors
A terminal failed document MUST set status to "failed" and SHOULD set error to a clear message. Validation failures MAY be returned as HTTP 4xx (or transport equivalent) without creating a query, or as a failed query — implementations SHOULD be consistent and document the choice.
5Sessions
A session is the multi-turn unit of KnowQL: pinned knowledge scope plus durable query history.
5.1Creating a session
A session is created implicitly when a Query Document is submitted without previous_query_id and without session_id.
Required on create:
askscope(1–10 queryable contexts)
Optional on create (pinned):
system_prompt,guardrails,varsmodels/model(become session default preference)toolsworkflow(when the implementation treats workflow as session-defining)
The first query becomes the head of the chain. Implementations SHOULD derive a short title from the first ask for list UIs.
5.2Continuing a session
Submit a new Query Document with either:
previous_query_idset to a query in the session, orsession_idset to the session id
Continuation rules:
scopeand other session-pinned fields from the create request remain in force; new values for those fields on a continue request are ignored or rejected.- The implementation replays prior turns as conversation history so the runtime can answer in context.
- Per-turn fields (
shape, model override, retrieval controls, delivery flags,max_steps,thinking_level) apply only to the new turn.
5.3Session resource (recommended HTTP binding)
| Method | Path | Description |
|---|---|---|
GET |
/sessions |
List sessions (newest first); limit clamped |
GET |
/sessions/{id} |
Session metadata + queries in order |
DELETE |
/sessions/{id} |
Delete session and its queries |
GET |
/queries/{id} |
Fetch one query (turn) |
POST |
/query |
Submit a Query Document |
Path prefixes (e.g. /api/v0) are deployment-defined.
5.3.1Session object (informative)
{
"id": "ses_…",
"scope": ["ctx_a", "ctx_b"],
"title": "Compare Q3 revenue…",
"system_prompt": null,
"guardrails": null,
"models": ["standard"],
"tools": [],
"vars": {},
"workflow": "search",
"last_query_id": "qry_…",
"created_at": "2026-08-06T00:00:00Z",
"updated_at": "2026-08-06T00:05:00Z"
}
5.4Workspace / tenancy (informative)
Implementations MAY scope session visibility to a workspace or project. Cross-tenant access MUST be denied. Orphan sessions whose entire scope has been deleted MAY be hidden from lists.
5.5No agent entity
KnowQL 0.1.0 does not define a reusable persisted agent. Anything that looks like agent configuration is session-pinned fields on create. Clients that want reuse re-send the same create payload.
6Delivery
A turn has three delivery modes. Exactly one applies per request.
| Mode | Request flags | Accept behavior | How to get the result |
|---|---|---|---|
| Synchronous | default (stream/background false or omitted) |
Hold until terminal | Response body is the full Response Document |
| Stream | stream: true |
Open event stream | SSE (or equivalent) events, then final document |
| Background | background: true |
Return immediately | in_progress document; poll GET by query id |
stream and background are mutually exclusive. Implementations MUST reject a document that sets both true.
6.1Synchronous
- Validate and accept the Query Document.
- Create session (if needed) and query row in
in_progress. - Execute the turn.
- Return the terminal Response Document in the response body.
Suitable for short turns and simple clients. Long turns should use stream or background so intermediaries do not time out.
6.2Stream
When stream is true (or the client negotiates an event stream via transport headers), the implementation emits a sequence of events and ends with the full query document.
6.2.1Recommended SSE event types
type |
When | Purpose |
|---|---|---|
response.created |
After accept | query_id, session_id |
response.step |
During execution | Tool/retrieval progress (step_id, status, commentary) |
response.output_text.delta |
During synthesis | Incremental prose |
response.synthesis |
Optional | Synthesis stage metadata |
response.turn_rollup |
Optional | Turn totals (steps, hits) |
response.trace |
Optional | External trace handle |
response.completed |
Terminal success | Turn finished |
response.failed |
Terminal failure | Turn failed |
response.cancelled |
Terminal cancel | Turn cancelled |
query |
Stream end | Full Response Document |
Event payloads are JSON. Implementations MAY add fields but SHOULD keep type stable.
Clients that disconnect SHOULD NOT cancel the turn unless they explicitly call a cancel API; a supervisor on the server SHOULD still finalize the row so GET /queries/{id} remains accurate.
6.3Background
When background is true:
- Accept, persist
in_progress, start execution. - Return the Response Document immediately with
status: "in_progress"(RECOMMENDED HTTP status: 202 Accepted). - Client polls
GET /queries/{id}untilstatusis terminal (completed|failed|cancelled).
6.4Timeout
timeout_seconds bounds execution. Default and maximum are implementation-defined; 900 seconds (15 minutes) is the RECOMMENDED default and ceiling. On timeout the query MUST end in failed or cancelled with an explanatory error.
6.5Cancel
Implementations MAY expose a cancel operation for an in_progress query. A cancelled turn sets status to "cancelled". Cancel is Future as a standardized request field; product APIs may already support it out of band.
7Structured Output
When a turn includes shape, the engine MUST produce a structured result in addition to (or instead of) free-form prose.
7.1`shape` format
shape is a JSON Schema document (object). KnowQL 0.1.0 does not define a custom type shorthand. Draft version support is implementation-defined; implementations SHOULD accept common JSON Schema object schemas with type, properties, required, items, and nested objects/arrays.
Example:
{
"ask": "Does Acme Corp qualify for a renewal discount?",
"scope": ["ctx_contracts", "ctx_pricing_policy"],
"shape": {
"type": "object",
"properties": {
"qualifies": { "type": "boolean" },
"discount_pct": { "type": "number" },
"applicable_rules": {
"type": "array",
"items": {
"type": "object",
"properties": {
"rule_id": { "type": "string" },
"reason": { "type": "string" }
},
"required": ["rule_id", "reason"]
}
}
},
"required": ["qualifies"]
}
}
7.2Response contract
- On success,
output_jsonMUST be a JSON value that validates againstshape. outputMAY contain empty or summary prose; clients that need structure MUST readoutput_json.- If the engine cannot produce a conforming document, the turn MUST
failed(or return a validation error) rather than return a silently non-conformingoutput_json. shapeis per-turn. Omitting it on a later turn returns free-form output even if earlier turns in the session used a shape.
7.3Interaction with retrieval-only
If both shape and a retrieval-only control are set, implementations SHOULD prefer retrieval-only semantics for output_json (retrieved material envelope) and MAY ignore shape, or reject the combination. The originating implementation skips synthesis in retrieval modes; clients SHOULD NOT combine shape with retrieval_only / *_only / compose: false until a future revision defines the mix.
8Retrieval Modes
By default a turn composes: the engine retrieves relevant material and synthesizes a natural-language and/or shaped answer with citations.
Callers can disable synthesis and take the retrieved material directly.
8.1Controls
All controls are per-turn booleans or caps on the Query Document.
8.1.1Compose on (default)
No retrieval flags, or compose: true.
outputholds the prose answer (when any).output_jsonholds the shaped document whenshapewas set.citationspoint at supporting sources.
8.1.2`compose: false`
Skip synthesis. Equivalent in spirit to retrieval_only: true: return retrieved hits structured in output_json.
8.1.3`retrieval_only: true`
Skip synthesis. Populate output_json with a retrieval envelope containing both chunks (verbatim source passages) and artifacts (derived knowledge objects), subject to caps.
8.1.4`pointers_only: true`
Implies retrieval-only. Drop verbatim text; keep pointers (ids, offsets, paths, scores) so clients can fetch bodies themselves.
8.1.5`chunks_only: true`
Implies retrieval-only. Include source chunks only; artifacts is empty.
8.1.6`artifacts_only: true`
Implies retrieval-only. Include derived artifacts only; chunks is empty.
8.1.7Caps
| Field | Meaning |
|---|---|
max_retrieved |
Maximum combined number of returned items (≥ 0) |
max_retrieved_chars |
Maximum character length of per-item verbatim text |
Absent or null means no caller-imposed limit (implementation storage limits MAY still trim and SHOULD indicate truncation).
8.2Retrieval envelope (`output_json`)
When synthesis is skipped, output_json SHOULD match:
{
"answered_by": "retrieval",
"mode": "retrieval_only",
"counts": { "chunks": 0, "artifacts": 0 },
"chunks": [],
"artifacts": [],
"retrieval": {
"query_variants": [],
"keyword_query": null,
"matched_artifacts": [],
"entry_level": null,
"expand_window": 0
}
}
8.2.1Chunk item (informative)
Implementation-defined, typically:
- file / source identity (
name, path) - location (
offsets,section_path) - optional
text(omitted whenpointers_only) - optional
score
8.2.2Artifact item (informative)
Implementation-defined derived object with identity, optional text, and provenance into sources.
8.2.3Truncation
If storage or response limits require dropping items, implementations SHOULD set a flag under retrieval (e.g. truncated_for_storage: true) and update counts.
8.2.4Ambiguity
If retrieval cannot separate structural twins, implementations MAY list ambiguous names under retrieval.ambiguous_cluster so clients do not over-trust ranking.
8.3Precedence
When multiple flags are set, the following resolution is RECOMMENDED (and used by the reference implementation):
chunks_only→ no compose, kind = chunks- else
artifacts_only→ no compose, kind = artifacts - else
retrieval_onlyorpointers_only→ no compose, kind = both - else
compose === false→ no compose, kind = both - else → compose
8.4Prose output in retrieval modes
output MAY be empty or a short stub. Clients MUST treat output_json as the payload of record when answered_by is "retrieval".
9Validation
Implementations MUST validate a Query Document before (or as part of) accepting a turn. Failures that prevent creating a well-formed turn SHOULD surface as client errors without a durable query when possible.
9.1Required checks
| Condition | Outcome |
|---|---|
ask missing or blank |
Reject |
New session and scope missing, empty, or > 10 |
Reject |
| Scope entry unknown or not queryable | Reject |
| Scope mixes incompatible context kinds | Reject (if kinds exist) |
previous_query_id / session_id unknown or unauthorized |
Reject |
stream and background both true |
Reject |
timeout_seconds invalid (non-numeric, negative) |
Reject |
thinking_level not in the allowed set |
Reject |
workflow unknown |
Reject |
max_steps / caps not coercible to non-negative integers |
Reject or ignore per field rules |
9.2Soft rules
| Condition | Outcome |
|---|---|
| Session-pin fields on a continue request | Ignore or reject; MUST NOT silently repin |
model / models unknown |
Reject or fall back; document choice |
shape not a JSON object schema |
Reject |
shape + retrieval-only combination |
Prefer retrieval-only, ignore shape, or reject |
9.3Response validation
On completed with a shape, output_json MUST validate against that schema. On retrieval-only completion, output_json SHOULD carry answered_by: "retrieval".
9.4Error shape (recommended)
Transport-level errors SHOULD include a stable machine code and message:
{
"error": {
"code": "bad_request",
"message": "ask is required"
}
}
Query-level failures use status: "failed" and error string on the Response Document.
10Future Work
The following facilities are not part of KnowQL 0.1.0. They are reserved for future revisions. Implementations MAY prototype them under extension names; they MUST NOT claim Core 0.1.0 conformance on the basis of these features alone.
10.1Metadata filters — `where`
Exact-match (and later, richer) predicates over context metadata / fields.
{
"ask": "…",
"scope": ["ctx_contracts"],
"where": { "customer_id": "acme_corp_001" }
}
Status: supported in the future.
10.2Field-level grounding — `ground`
Per-field citations and confidence on shaped results.
{
"shape": { "…": "…" },
"ground": { "per_field": true, "min_confidence": "medium" }
}
Status: supported in the future. 0.1.0 provides document-level citations only.
10.3Budget envelope — `budget`
First-class token, latency, and depth controls beyond timeout_seconds, max_steps, and thinking_level.
{
"budget": { "max_tokens": 2000, "depth": "standard", "max_latency_ms": 5000 }
}
Status: supported in the future. Partial control exists today via timeout_seconds, max_steps, thinking_level, and model selection.
10.4Temporal — `as_of` / `since` / `window`
Time-travel and windowed knowledge views.
Status: supported in the future.
10.5Composition — `link` / `resolve`
Declarative cross-context joins and conflict precedence.
Status: supported in the future. 0.1.0 multi-context scope is a union of knowledge sources under one agent loop, not a join algebra.
10.6Explain — `explain`
Return an execution plan without running the turn.
Status: supported in the future. Partial observability exists via steps, rollup, and trace_ref on executed turns.
10.7Introspection
Schema discovery (__schema, context/field catalogs) as KnowQL documents.
Status: supported in the future. Implementations MAY expose catalogs via separate control-plane APIs.
10.8Textual DSL
A non-JSON surface syntax for KnowQL.
Status: supported in the future. 0.1.0 is JSON-only.
10.9Standardized cancel field
A request primitive to cancel an in-flight turn (vs out-of-band product API).
Status: supported in the future.
10.10Custom shape shorthand
Earlier drafts used a compact type language (Boolean!, Float, …). 0.1.0 standardizes on JSON Schema. A compact sugar MAY return in a later version as pure syntactic sugar over JSON Schema.
AAppendix: Conformance
A conforming implementation of KnowQL must fulfill all normative requirements described in this specification. Conformance requirements are described in this document via both descriptive assertions and key words with clearly defined meanings.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative portions of this document are to be interpreted as described in IETF RFC 2119. These key words may appear in lowercase and still retain their meaning unless explicitly declared as non-normative.
A conforming implementation of KnowQL may provide additional functionality, but must not do so where explicitly disallowed or where it would otherwise result in non-conformance.
A.1Version
This document defines KnowQL version 0.1.0 (working draft), dated August 6, 2026.
A.2Conformance levels
A.2.1Core 0.1.0
A KnowQL Core 0.1.0 conforming implementation MUST:
- Accept Query Documents with required
askand, for new sessions,scopeof 1–10 queryable contexts. - Create a session on documents that omit both
previous_query_idandsession_id, pinning scope and session config. - Continue sessions via
previous_query_idand/orsession_id. - Support free-form answers in
outputand structured answers via per-turnshape(JSON Schema) inoutput_json. - Support at least one of: synchronous completion, streaming events, or background accept-and-poll; and document which. RECOMMENDED: all three, with
stream⊥background. - Expose query lifecycle states:
in_progress,completed,failed,cancelled. - Return
usagetoken counts andruntime_mson terminal documents. - Honor retrieval-mode controls (
compose,retrieval_only,pointers_only,chunks_only,artifacts_only, caps) or clearly document a subset; if a flag is accepted it MUST follow Retrieval Modes semantics. - Reject invalid documents per Validation. 10. Not require the Future Work primitives for Core conformance.
A.2.2Extended 0.1.0
An Extended 0.1.0 implementation additionally SHOULD:
- Implement SSE event types listed in Delivery.
- Populate
citationson composed answers. - Support
model/models,tools,system_prompt,guardrails,vars,max_steps,thinking_level,timeout_seconds. - Return retrieval envelopes with
answered_by: "retrieval"when synthesis is skipped.
A.2.3Future features
Support for primitives listed in Future Work is OPTIONAL and does not expand Core 0.1.0 obligations. A future version of this specification will promote them with their own conformance clauses.
A.3Conforming algorithms
Algorithms in this specification are normative with respect to their observable results. Implementations may use any equivalent strategy.
A.4Non-normative portions
All contents of this document are normative except portions explicitly declared as non-normative or marked informative.
BAppendix: Notation Conventions
This specification uses a number of notation conventions to describe technical concepts including document structure, grammar, algorithms, and data types.
B.1B.1 Grammar Notation
This specification describes the structure of KnowQL documents using a simplified JSON grammar notation. Non-terminal production rules use the following form:
NonTerminal :
Component1 Component2
| Alternative
In this notation:
NonTerminalnames the construct being defined.- Components separated by newlines under
{ }are object fields. ?following a component means it is optional.[ ]denotes a list (JSON array).{ }denotes an object (JSON object).|separates alternatives.- Quoted strings (e.g.,
"ask") represent literal JSON string values.
B.2B.2 Algorithm Notation
Algorithms in this specification use pseudo-code with the following conventions:
Let x = expression— binds a name to a value.Assert: condition— asserts that a condition must be true; if false, the algorithm has a bug.If condition: ...— conditional branch.For each x in collection: ...— iteration.Return value— terminates the algorithm with a result.Raise error— terminates the algorithm with an error condition.
B.3B.3 Types used in prose
| Name | Meaning |
|---|---|
StringValue |
JSON string |
NumberValue |
JSON number |
BooleanValue |
JSON true/false |
ObjectValue |
JSON object |
Value |
Any JSON value |
JsonSchema |
JSON Schema document (object) |
QueryId / SessionId |
Opaque string ids |
ContextRef |
Context slug or UUID string |
CAppendix: Copyright and Licensing
Copyright © 2026 Pinecone Systems, Inc.
This specification is subject to the Open Web Foundation Agreement 1.0. See LICENSE.md and Notices.md in the repository root.
KnowQL is a trademark of Pinecone Systems, Inc. where asserted. Use of the name for conforming implementations is welcome; do not imply endorsement without permission.