awe docs

Memory in depth

Structured output

Several of awe’s background jobs need a model to answer in an exact JSON shape: questions for a fact, a card for a document, a promise with a due date. This page is for developers who run awe with their own model provider and want to know how those answers are kept well-formed, and how to change a shape without a new release.

How it works

For each of these jobs awe has a named JSON Schema, called a lane. When a job runs:

  1. awe works out which provider will answer. This costs nothing.
  2. If that provider can enforce a schema, awe sends the schema with the request and the provider returns JSON that matches it.
    • Anthropic: a forced tool call with a strict input schema.
    • OpenAI-compatible providers: response_format of type json_schema with strict: true.
  3. awe checks the reply against the schema again (types, required fields, allowed values).
  4. If the provider cannot enforce a schema, awe does not try. The job makes its ordinary request instead, asks for JSON in the prompt, and picks the JSON out of the reply.

So enforcement never adds a model call. A job either gets an enforced reply or makes the one plain request it would have made anyway.

Which providers enforce

Enforced Not enforced (the job uses the plain request)
anthropic, openai, google, groq, deepseek, xai, mistral, openrouter, fireworks, together, kimi, kimi-cli, custom, awe The Claude command-line app, ollama, script providers

Which provider a job uses is set by AWE_MEMORY_EXTRACTION_PROVIDER, or by [extraction] in memory.toml. auto follows the model chosen for chat.

The lanes

Lane Used for Shape
keygen_questions The questions each stored fact answers (mem keygen and its background job) {facts: [{fact, questions: []}]}
tag_classify Giving a tag to a fact that has none {facts: [{fact, tag}]}
document_card The card that describes a Library document {sufficient, reason, title, what, answers: [], entities: [], not_about, derived_from: []}
entity_kinds Whether a name is a person, a company, a project, or not a name {entities: [{entity, kind}]}
entity_relations How two names that appear together are related {relations: [{pair, predicate, subject, confidence}]}
conversation_summary The summary that keeps a long conversation in view {decisions: [], open_asks: [], entities: [], last_state}
commitment_extract Promises in a message, and reports that one was kept. See commitments.md {commitments: [], closes: []}
extraction_facts Reserved. Fact extraction itself still returns tagged text lines {facts: [{text, tag, questions: []}]}

The default schema for each lane is built into awe.

Change a schema without a release

Put a file at .awe/schemas/<lane>.json in the awe folder, for example .awe/schemas/keygen_questions.json. The next model call for that lane uses it. No restart is needed.

  • A file that is not valid JSON is ignored with a warning, and the built-in schema is used.
  • Delete the file to go back to the built-in schema.
  • Each use of an override is noted in .awe/system.log with a line that starts [structured].

Rules a schema must follow, so that both kinds of provider accept it:

  • The top level is an object. Wrap a list in an object.
  • Every object sets "additionalProperties": false and lists every property in "required".
  • No recursion, and no numeric minimum or maximum. Put limits in the prompt.

The job that reads the reply still expects the fields it was written for, so an override can tighten or describe a shape but cannot rename its fields.

Turn it off

Switch Effect
AWE_STRUCTURED_MODE=off in .env No lane asks for enforcement. Every job uses the plain request
Automatic If a provider rejects the enforcement fields, awe stops using enforcement for that lane until the next restart and logs one warning

Check it

Run one batch of question writing against a provider that enforces, then look at the log:

./awe-core mem keygen --batches 1

mem keygen needs facts that have no questions yet. With an enforcing provider, .awe/system.log shows a line beginning [keygen] structured lane returned. With any other provider the job still succeeds through the plain request.