Skip to main content

Agents

Non-Determinism Notice

Agent endpoints use the LLM to generate definitions. Output varies between calls. All generated output must pass the deterministic compiler before registration. Agents are never on the critical execution path.


Generate Definition

POST /agents/define

Converts a natural language description into a validated MemSDL definition. The returned definition is compiler-validated but not registered or compiled. Call POST /definitions/validate, then POST /registry/definitions, then POST /compile before executing.

Request — AgentDefineRequest

FieldTypeRequiredDescription
descriptionstrRequiredNatural language description of the concept or primitive.
context.domainstrOptionalDomain hint. Examples: finance, saas, fraud_detection.
context.preferred_primitiveslistOptionalExisting primitive IDs to prefer as inputs.

Response — AgentDefineResponse

FieldTypeRequiredDescription
definitionConcept|PrimitiveAlwaysGenerated and compiler-validated definition. Not yet registered.
validationValidationResultAlwaysCompiler validation result. Check valid=True before proceeding.
warningslistOptionalNon-blocking LLM notes — ambiguities resolved, default mappings used.

Response Codes

StatusDescription
200Definition generated.
400Validation error.
401Unauthorised.

Semantic Refinement

POST /agents/semantic-refine

Closes the LLM generation loop. Takes an existing Concept definition, its SemanticGraph from POST /compile/semantic, and a refinement instruction. Returns a revised definition with updated semantic view and a diff showing meaning changes. Repeat until convergence_delta reaches 0.0.

Request — SemanticRefineRequest

FieldTypeRequiredDescription
definitiondictRequiredCurrent Concept definition to refine.
semantic_viewdictRequiredCurrent SemanticGraph from POST /compile/semantic.
instructionstrRequiredRefinement instruction. Example: 'Add volatility feature weighted at 30%'.
target_meaning_hashstrOptionalsemantic_hash to converge toward. convergence_delta tracks distance.
iterationintOptionalCurrent iteration number (1-indexed).

Response — SemanticRefineResponse

FieldTypeRequiredDescription
definitionConceptAlwaysThe refined Concept.
semantic_viewSemanticGraphAlwaysUpdated semantic view. Input for the next iteration.
validationValidationResultAlwaysCheck valid=True before proceeding to next iteration.
convergence_deltafloatOptional0.0 = converged to target_meaning_hash.

Response Codes

StatusDescription
200Refined definition.
400Validation error.
401Unauthorised.