instance: granollers.okai
MODERN PROTOCOL FOR AI SYSTEMS
Open Knowledge for AI
EXPEDIENT

Overview

Internal structure that preserves the complete Detection and Resolution results of a single independent request.

Estructura interna que conserva els resultats complets de Detection i Resolution d'un únic request independent.

no active execution
EXPEDIENT Definition

An EXPEDIENT is the internal object created by resolveExpedient(question).

It preserves the complete results of Detection and Resolution performed on the question received in a single request.

An EXPEDIENT contains detected and resolved knowledge.

It is the source from which PROJECT candidates are constructed.

The complete EXPEDIENT is not returned directly to the M2M consumer.

Un EXPEDIENT és l'objecte intern creat per resolveExpedient(question).

Conserva els resultats complets de Detection i Resolution executades sobre la question rebuda en un únic request.

Un EXPEDIENT conté coneixement detectat i resolt.

És la font a partir de la qual es construeixen els PROJECT candidats.

L'EXPEDIENT complet no es retorna directament al consumidor M2M.

Request, Question and EXPEDIENT

A REQUEST is an independent invocation of OKAI SERVICE.

question is the textual input field carried by the request.

The EXPEDIENT is the internal result of processing that question through Detection and Resolution.

These three concepts are not interchangeable.

Un REQUEST és una invocació independent d'OKAI SERVICE.

question és el camp d'entrada textual transportat pel request.

L'EXPEDIENT és el resultat intern de processar aquesta question mitjançant Detection i Resolution.

Aquests tres conceptes no són intercanviables.

M2M REQUEST
    │
    └── question
          │
          ▼
resolveExpedient(question)
          │
          ▼
      EXPEDIENT
Creation and Independence

Each invocation of runWorld(question) creates a new EXPEDIENT.

The EXPEDIENT:

  • has no persistent identifier;
  • is not stored between requests;
  • does not inherit previous detections;
  • does not maintain conversational state.

The operational context of the OKAI instance must not be confused with conversational context.

Cada invocació de runWorld(question) crea un EXPEDIENT nou.

L'EXPEDIENT:

  • no té identificador persistent;
  • no s'emmagatzema entre requests;
  • no hereta deteccions anteriors;
  • no manté estat conversacional.

El context operatiu de la instància OKAI no s'ha de confondre amb el context conversacional.

EXPEDIENT Structure

resolveExpedient(question) returns an internal object containing exactly six fields.

resolveExpedient(question) retorna un objecte intern que conté exactament sis camps.

{
  "question": "...",
  "detectedEntities": [],
  "activeTerritorialContext": {},
  "resolved_detections": [],
  "detected_composition_members": [],
  "only_matched_text": {
    "known": [],
    "unknown": []
  }
}

This JSON is a schematic representation. It is not a literal API response.

Aquest JSON és una representació esquemàtica. No és una resposta literal de l'API.

question

The original textual input received by resolveExpedient.

L'entrada textual original rebuda per resolveExpedient.

detectedEntities

The explicitly detected Entities, ordered according to their final textual detection order.

Les Entities detectades explícitament, ordenades segons l'ordre textual final de detecció.

activeTerritorialContext

The active territorial context resolved for the EXPEDIENT.

El context territorial actiu resolt per a l'EXPEDIENT.

resolved_detections

The resolved packages associated with the original detections.

Els paquets resolts associats a les deteccions originals.

detected_composition_members

Composition members detected directly from the question.

Membres de composició detectats directament a partir de la question.

only_matched_text

The explicit textual coverage represented through known and unknown content.

La cobertura textual explícita representada mitjançant contingut conegut i desconegut.

Detection and Resolution

Detection and Resolution are executed during resolveExpedient(question).

Entity Detection, territorial detection, textual coverage and composition-member detection are performed once for each EXPEDIENT.

Resolution processes the detected Entities within a single resolution pass.

The resulting knowledge is preserved in the EXPEDIENT.

Subsequent projections do not execute Detection or Resolution again.

Detection i Resolution s'executen durant resolveExpedient(question).

La detecció d'Entities, la detecció territorial, la cobertura textual i la detecció de membres de composició s'executen una vegada per EXPEDIENT.

Resolution processa les Entities detectades en un únic recorregut de resolució.

El coneixement resultant es conserva a l'EXPEDIENT.

Les projeccions posteriors no tornen a executar Detection ni Resolution.

resolveExpedient(question)
          │
          ├── Detection
          ├── Territorial Context
          ├── Textual Coverage
          ├── Composition Members
          └── Resolution
                    │
                    ▼
                EXPEDIENT
Resolved Detections

resolved_detections preserves the correspondence between each original detection and its resolved Entities.

Each entry contains:

  • index
  • detected_entity
  • resolved_entities

A single detection may resolve to multiple Entities.

The complete entry constitutes one resolved package.

resolved_detections conserva la correspondència entre cada detecció original i les seves Entities resoltes.

Cada entrada conté:

  • index
  • detected_entity
  • resolved_entities

Una única detecció pot resoldre múltiples Entities.

L'entrada completa constitueix un únic resolved package.

[
  {
    "index": 0,
    "detected_entity": {},
    "resolved_entities": []
  }
]

Schematic representation, not a literal API response.

Representació esquemàtica, no resposta literal de l'API.

Multiple Detections

A single question may identify multiple Entities.

All detections belong to the same EXPEDIENT.

Each detection produces one resolved package, which may contain one or more resolved Entities.

Multiple detections do not imply multiple requests.

Una única question pot identificar múltiples Entities.

Totes les deteccions pertanyen al mateix EXPEDIENT.

Cada detecció produeix un resolved package, que pot contenir una o més Entities resoltes.

Múltiples deteccions no impliquen múltiples requests.

{
  "question": "escoles de Granollers i biblioteques municipals"
}
EXPEDIENT
│
├── Detection A
│   ├── escoles_granollers_concept
│   └── resolved:
│       └── escoles_granollers
│
└── Detection B
    ├── biblioteques_municipals
    └── resolved:
        ├── biblioteca_can_pedrals_granollers
        └── biblioteca_roca_umbert_granollers

Two detections, two resolved packages, one EXPEDIENT and one REQUEST.

Dues deteccions, dos resolved packages, un EXPEDIENT i un REQUEST.

EXPEDIENT → PROJECT

projectExpedient(expedient, resolvedDetectionsPrefix) constructs a PROJECT from an already resolved prefix.

A PROJECT is a projection of the EXPEDIENT, not a new resolution.

Different PROJECT candidates can be constructed from the same EXPEDIENT.

Projection does not rerun Detection or Resolution.

projectExpedient(expedient, resolvedDetectionsPrefix) construeix un PROJECT a partir d'un prefix ja resolt.

Un PROJECT és una projecció de l'EXPEDIENT, no una nova resolució.

Es poden construir diferents PROJECT candidats a partir del mateix EXPEDIENT.

La projecció no torna a executar Detection ni Resolution.

EXPEDIENT [A, B, C, D]
          │
          ├── PROJECT [A, B, C, D]
          ├── PROJECT [A, B, C]
          ├── PROJECT [A, B]
          └── PROJECT [A]

These PROJECT candidates are not different requests and do not create new EXPEDIENTS.

Aquests PROJECT candidats no són requests diferents ni creen EXPEDIENTS nous.

Projection Scope

Some EXPEDIENT information remains global across PROJECT candidates.

Global information:

  • question
  • only_matched_text
  • detected_composition_members
  • activeTerritorialContext

Other information is reconstructed according to the selected resolved-detection prefix.

This includes delivered detections, resolved FUNCTIONAL realities and functional relations.

The operational okai_instance is also global, but it comes from instance configuration, not from the EXPEDIENT.

Una part de la informació de l'EXPEDIENT es manté global entre PROJECT candidats.

Informació global:

  • question
  • only_matched_text
  • detected_composition_members
  • activeTerritorialContext

La resta d'informació es reconstrueix segons el prefix de deteccions resoltes seleccionat.

Això inclou les deteccions entregades, les realitats FUNCTIONAL resoltes i les relacions funcionals.

L'okai_instance operativa també és global, però prové de la configuració de la instància, no de l'EXPEDIENT.

Delivery Selection

Delivery evaluates PROJECT candidates against the contractual limit of 50,000 tokens.

It starts with the complete resolved prefix.

If the serialized WorldResultPayload exceeds the limit, Delivery tests progressively shorter prefixes.

The first prefix that fits is selected.

The original order is preserved.

No scoring, ranking, semantic prioritization or combination search is performed.

Delivery avalua els PROJECT candidats segons el límit contractual de 50.000 tokens.

Comença pel prefix resolt complet.

Si el WorldResultPayload serialitzat supera el límit, Delivery prova prefixos progressivament més curts.

Se selecciona el primer prefix que compleix el límit.

Es conserva l'ordre original.

No es realitza scoring, ranking, priorització semàntica ni cerca de combinacions.

EXPEDIENT [A, B, C, D]
          │
          ▼
PROJECT [A, B, C, D]
          │
          ├── ≤ 50,000 → DELIVER
          │
          └── > 50,000
                    │
                    ▼
             PROJECT [A, B, C]
                    │
                    ├── ≤ 50,000 → DELIVER
                    │
                    └── > 50,000 → ...

Token accounting applies to the final serialized WorldResultPayload, including token_control. It is not calculated exclusively from okai_message.payload.

El recompte s'aplica al WorldResultPayload final serialitzat, incloent token_control. No es calcula exclusivament a partir d'okai_message.payload.

Deferred Packages

Resolved packages excluded from the delivered PROJECT are represented as deferred.

They remain part of the resolved EXPEDIENT.

deferred does not indicate unresolved knowledge or a Detection or Resolution error.

It does not modify the EXPEDIENT.

action: new_request instructs the consumer to perform a new independent M2M request.

It does not establish conversational continuity.

Els resolved packages exclosos del PROJECT entregat es representen com a deferred.

Continuen formant part de l'EXPEDIENT resolt.

deferred no indica coneixement unresolved ni un error de Detection o Resolution.

No modifica l'EXPEDIENT.

action: new_request indica al consumidor que ha de realitzar un nou request M2M independent.

No estableix continuïtat conversacional.

EXPEDIENT
[A] [B] [C] [D]

DELIVERED PROJECT
[A] [B] [C]

DEFERRED
[D]

If a single resolved package exceeds the limit, it is an internal structural violation, not normal deferred.

Si un únic resolved package supera el límit, és una violació estructural interna, no un deferred normal.

Public M2M Exposure

The complete EXPEDIENT is an internal runtime object.

The API returns a WorldResultPayload containing an okai_message with header and payload.

The consumer observes projections of EXPEDIENT information, not the complete internal object.

L'EXPEDIENT complet és un objecte intern del runtime.

L'API retorna un WorldResultPayload que conté un okai_message amb header i payload.

El consumidor observa projeccions de la informació de l'EXPEDIENT, no l'objecte intern complet.

EXPEDIENT
    │
    ▼
PROJECT
    │
    ▼
WorldResultPayload
    │
    └── okai_message
        ├── header
        │   └── delivery.deferred
        └── payload
            ├── known
            ├── detected_as
            ├── meaning
            ├── detected_composition_members
            ├── territorial_resolution
            ├── functional_reality
            └── functional_relations

known and detected_composition_members reflect global EXPEDIENT information.

detected_as, meaning, functional_reality and functional_relations depend on the delivered PROJECT.

deferred is exposed in the header, not in the semantic payload.

known i detected_composition_members reflecteixen informació global de l'EXPEDIENT.

detected_as, meaning, functional_reality i functional_relations depenen del PROJECT entregat.

deferred s'exposa al header, no al payload semàntic.

Responsibilities and Limits

The EXPEDIENT preserves detected and resolved knowledge and provides the basis for PROJECT construction.

It does not:

  • generate the final response for the consuming AI;
  • maintain conversational state;
  • persist between requests;
  • perform scoring or semantic prioritization;
  • modify World or operational DATA.

The EXPEDIENT is an internal knowledge structure, not a conversational memory or response generator.

L'EXPEDIENT conserva coneixement detectat i resolt i proporciona la base per construir PROJECT.

No:

  • genera la resposta final per a la IA consumidora;
  • manté estat conversacional;
  • persisteix entre requests;
  • realitza scoring ni priorització semàntica;
  • modifica World ni la DATA operativa.

L'EXPEDIENT és una estructura interna de coneixement, no una memòria conversacional ni un generador de respostes.

Operational Summary / Resum Operatiu
1 REQUEST
    │
    └── question
          │
          ▼
1 EXPEDIENT
    │
    ├── Detection once
    ├── Resolution once
    └── Complete resolved knowledge
          │
          ▼
PROJECT CANDIDATES
    │
    ├── Ordered prefixes
    ├── No new Detection
    └── No new Resolution
          │
          ▼
DELIVERY
    │
    ├── 50,000-token limit
    ├── Longest valid prefix
    └── Excluded packages → deferred
          │
          ▼
1 OKAI MESSAGE

One independent request produces one EXPEDIENT.

Detection and Resolution are performed once.

Delivery may evaluate multiple PROJECT candidates, but only one PROJECT is selected for the final message.

Un request independent produeix un EXPEDIENT.

Detection i Resolution s'executen una vegada.

Delivery pot avaluar múltiples PROJECT candidats, però només se selecciona un PROJECT per al missatge final.

© 2026 Denys Sanz · Tots els drets reservats OKAI — Protocol M2M v0.3.2