Errors and recovery

A redundant formal field diagnosis that agrees with the core is combined with the retained issue, including its sources, candidates, questions and suggestion references. A claim that contradicts a formal proof remains MODEL_OUTPUT_INVALID, with a candidate location where available. An inference targeting an inputs/extensions container or its descendants is also invalid; use a real semantic location for an unconfirmed assumption. Ordinary invalid business values remain normal field results and data issues.

Technical failures throw IntentError rather than returning truncated candidates or infrastructure failures as normal success. Field issues remain in a normal result's issues.

If there is no result, check for an exception. If the result lacks an order ID, inspect fieldResults and issues first. Timeout, authentication failure, and missing user information need different recovery actions. If Codex cannot start or has no tools, begin with registration diagnostics.

ExampleObservable resultAction
Select orderId without schemaRejected Promise, SCHEMA_NOT_CONFIGUREDConfigure a Schema and recreate the instance, or omit field selection
Required ID missing from user inputNormal IntentResult with field/issue reportsAsk the user; do not treat missing business data as network failure
Change only VIP=false; previous discount=15 violates its new ruleNormal result, discount invalidatedDo not consume the old value; select discount and supply a valid value next turn

Recovery is identify code/issue → repair input/configuration → make an explicit new call → inspect the new result. It is not automatic retry. See MCP envelopes.

Structure failures use MODEL_OUTPUT_INVALID with stage='validation' and bounded JSON Pointer paths in details.violations, such as /relations, /nodes/0/action, or /observations/0/path. An invalid complete OpenAI wire candidate is a candidate failure; it is not an authentication or transport failure. Unsupported local projection shapes fail before a request with CONFIG_INVALID and an outputSchema path. Strict output does not repair missing business data or bypass source and semantic checks.

Canonical diagnostics identify an invalid related node at /relatedKeys/1, a wrong snapshot delta path at /changes/0/deltaHints/0/path, and an applied add for an existing intent at /changes/0/operation (SEMANTIC_INVARIANT). The OpenAI wire may reject these combinations earlier with STRUCTURE; callers should use the reported rule and path rather than assuming one validation stage.

Technical codeMeaning
INPUT_INVALID / CONFIG_INVALID / FIELD_UNKNOWNInvalid request, trusted configuration, or selected field
SCHEMA_INVALID / SCHEMA_NOT_CONFIGURED / SCHEMA_UNSUPPORTED_FOR_EXTRACTIONInvalid, absent, or unsupported definition
EXECUTOR_NOT_CONFIGUREDNative/executor mode has no executor
MODEL_AUTH_FAILED / MODEL_RATE_LIMITED / MODEL_REQUEST_FAILEDAuthentication, rate limit, or request failure
MODEL_REFUSED / MODEL_OUTPUT_INCOMPLETE / MODEL_OUTPUT_INVALIDRefusal, truncation, or invalid candidate structure/sources/invariants
MODEL_TIMEOUT / REQUEST_ABORTED / INSTANCE_DISPOSEDExplicit deadline, cancellation, or disposal
RESOURCE_LIMITCapacity/work exceeded; inspect available limit/allowed/unit/path in details; observed is included only when known
INTERNAL_PROCESSING_FAILEDLocal infrastructure or final output failure, stage=validation/output
HOST_REQUEST_NOT_FOUND / HOST_SUBMISSION_CONFLICTMissing handoff record, conflicting token, or different candidate

Resource checks may stop as soon as a limit is exceeded instead of measuring all remaining material. An omitted details.observed does not mean zero; display only available diagnostic properties. For example, setting limits.maxContextBytes to 16 and supplying an oversized Context can produce this safe summary:

{
  "name": "IntentError",
  "code": "RESOURCE_LIMIT",
  "message": "Resource limit exceeded.",
  "stage": "input",
  "details": {"limit": "maxContextBytes", "allowed": 16, "unit": "bytes", "path": "/context"}
}

Semantic issue codes include AMBIGUOUS_REFERENCE, INTENT_INFORMATION_MISSING, CONSTRAINT_CONFLICT, RELATION_CONFLICT, CONTEXT_CONFLICT, CONTEXT_INCOMPLETE, UNCONFIRMED_INFERENCE. Field codes include FIELD_REQUIRED_MISSING, FIELD_APPLICABILITY_UNKNOWN, FIELD_CARDINALITY_MISMATCH, FIELD_VALUE_INVALID, FIELD_DEPENDENCY_MISSING, FIELD_VALIDATION_UNDETERMINED, FIELD_INVALIDATED.

Recover at the right layer

Ambiguity, missing fields, and invalid values are usually normal interpretation issues, not transport failures.

Symptom or codeInspectCaller action
SCHEMA_NOT_CONFIGUREDfields/extensions and matching definitionRecreate with correct configuration; use fields=[] when extraction is unnecessary
FIELD_UNKNOWN / SCHEMA_INVALID / CONFIG_INVALIDField names, supported rules, model/configurationCorrect input/configuration; repetition does not repair it
FIELD_REQUIRED_MISSING / FIELD_DEPENDENCY_MISSINGMissing values or condition evidenceAsk the user and supply context/baseline/selected fields
FIELD_VALUE_INVALID / FIELD_INVALIDATEDIllegal candidate or outdated inherited valueDo not consume it; obtain a valid explicit replacement
FIELD_VALIDATION_UNDETERMINEDProof capability and rule supportPreserve unknown and inspect Schema support; extra input may not help; no invented defaults or blind retry
Normal issues such as AMBIGUOUS_REFERENCEReference and candidate materialAsk the questions and return the corresponding issue/candidates
MODEL_OUTPUT_INVALIDSafe details.violations paths/rulesNative caller decides whether to recognize again; host may submit correction from explicit feedback without resetting the same validation budget
MODEL_AUTH_FAILED / MODEL_RATE_LIMITED / MODEL_REQUEST_FAILEDCredentials, permission, quota, provider status, networkRepair authentication or wait for recovery; caller chooses retry policy
MODEL_REFUSED / MODEL_OUTPUT_INCOMPLETERefusal or unfinished generationDo not parse truncated text; explicitly retry only after appropriate input/limit changes
RESOURCE_LIMITAvailable limit/allowed/unit/path in details; observed may be omittedReduce relevant material or adjust trusted limits; maxValidationChecks exhaustion ends this recognition
HOST_REQUEST_NOT_FOUNDClosed session, restart, reclaimed terminal recordPrepare again with complete material and use new requestId/token
HOST_SUBMISSION_CONFLICTMixed identities/tokens or different candidatesKeep the original handoff identity; prepare a new request instead of overwriting another submission
REQUEST_ABORTED / MODEL_TIMEOUTCaller signal or explicit timeoutMsPreserve previous state; a new recognition is explicit; default timeoutMs=0 adds no deadline
INSTANCE_DISPOSED / INTERNAL_PROCESSING_FAILEDInstance lifetime, code/stage, deployment versionRecreate disposed instances; retain a safe failure summary (the current version returns no partialResult)

Runtime does not perform these recovery actions for you. Host format correction is based on explicit feedback; missing knowledge, unknown fields, and business authorization are separate.

import {IntentError} from '@devcodex/intent-runtime';

async function parseWithErrorSummary(intent, request, signal) {
  try {return await intent.parse(request, {signal});}
  catch (error) {
    if (error instanceof IntentError) console.error(error.toJSON());
    throw error;
  }
}

Serialization includes name/code/message/stage and safe details; cause is non-enumerable. Standard technical messages are generic English without original input or keys. MCP technical failures return isError=true and text {error:...}, with no structuredContent or partialResult.

Preserve prior results and original messages. Failure does not clear application state. The caller decides technical retry and handles out-of-order requests with its own revision. Unknown fields do not trigger automatic fact generation.

This is a caller helper, not an SDK method; the caller owns Intent lifetime. The current version never produces PROCESSING_INCOMPLETE and never sets partialResult on IntentError; truncated text is not a normal result. toJSON omits partialResult by default, since complete results can contain original material. Use serialize options explicitly when needed; see IntentError.