Skip to main content

agentSchema

VoltAgent Service


VoltAgent Service / agentSchema

agentSchema

Interfaces

FieldSchema

Defined in: agentSchema.ts:21

Schema definition for a single field in agent output.

Properties

type

type: FieldType

Defined in: agentSchema.ts:23

The data type of this field

description?

optional description: string

Defined in: agentSchema.ts:25

Human-readable description of what this field contains

items?

optional items: FieldSchema

Defined in: agentSchema.ts:27

For array types, the schema of array items

properties?

optional properties: AgentSchema

Defined in: agentSchema.ts:29

For object types, the nested property schemas

defaultValue?

optional defaultValue: unknown

Defined in: agentSchema.ts:31

Override null/[] default (e.g., "N/A" for summary fallback)


AgentConfig

Defined in: agentSchema.ts:43

Configuration for a schema-driven agent. Defines the agent's identity, task, and expected output structure.

Properties

id

id: string

Defined in: agentSchema.ts:45

Unique identifier for this agent (e.g., 'cdu-extractor')

name

name: string

Defined in: agentSchema.ts:47

Human-readable display name

domainKey

domainKey: string

Defined in: agentSchema.ts:49

Domain key for domain pack association

taskDescription

taskDescription: string

Defined in: agentSchema.ts:51

Description of what this agent does (used in prompt)

schema

schema: AgentSchema

Defined in: agentSchema.ts:53

Output schema defining expected JSON structure

includeAllFields?

optional includeAllFields: boolean

Defined in: agentSchema.ts:55

If true (default), always include all fields in output

additionalRules?

optional additionalRules: string[]

Defined in: agentSchema.ts:57

Additional rules to include in agent instructions

Type Aliases

FieldType

FieldType = "string" | "number" | "boolean" | "array" | "object"

Defined in: agentSchema.ts:16

Supported field types for agent output schemas


AgentSchema

AgentSchema = Record<string, FieldSchema>

Defined in: agentSchema.ts:37

Complete agent output schema mapping field names to their definitions.

Functions

generateExampleOutput()

generateExampleOutput(schema, includeAllFields): Record<string, unknown>

Defined in: agentSchema.ts:71

Generate a JSON example output from schema. Respects includeAllFields flag for consistency with rules.

Parameters

schema

AgentSchema

The agent schema

includeAllFields

boolean = true

Whether to include all fields (default true)

Returns

Record<string, unknown>


generateDeterministicRules()

generateDeterministicRules(config): string

Defined in: agentSchema.ts:129

Generate deterministic output rules from schema. Rules are derived from schema data, not hardcoded per-agent.

Field-aware: fields with explicit defaultValue get their own rule, while fields without defaultValue get type-based null/[] rules.

Parameters

config

AgentConfig

Returns

string


validateSchema()

validateSchema(schema): string[]

Defined in: agentSchema.ts:213

Validate that a schema has valid field types. Returns array of error messages (empty if valid).

Parameters

schema

AgentSchema

Returns

string[]


getSchemaKeys()

getSchemaKeys(schema): string[]

Defined in: agentSchema.ts:241

Get all field keys from a schema (including nested).

Parameters

schema

AgentSchema

Returns

string[]


getExpectedKeys()

getExpectedKeys(schema, includeAllFields): string[]

Defined in: agentSchema.ts:249

Get expected field keys based on includeAllFields flag. When includeAllFields is false, only fields with defaultValue are included.

Parameters

schema

AgentSchema

includeAllFields

boolean = true

Returns

string[]