haive.core.schema.field_registryΒΆ

Field Registry for standardized field definitions across Haive.

This module provides a centralized registry of commonly used field definitions that can be referenced by nodes, engines, and schema composers. This ensures consistency and allows for selective state schema composition.

Key benefits: - Standardized field definitions across the framework - Selective inclusion in state schemas (only what’s needed) - Type safety with proper generics - Token counting integration for messages - Backwards compatibility

ClassesΒΆ

CommonFieldSets

Pre-defined sets of fields for common use cases.

FieldRegistry

Dynamic field registry for custom field definitions.

PrebuiltStates

Registry of prebuilt state schemas for common use cases.

StandardFields

Registry of standard field definitions used across Haive.

FunctionsΒΆ

get_standard_field(name, **kwargs)

Get a standard field definition by name.

Module ContentsΒΆ

class haive.core.schema.field_registry.CommonFieldSets[source]ΒΆ

Pre-defined sets of fields for common use cases.

class haive.core.schema.field_registry.FieldRegistry[source]ΒΆ

Dynamic field registry for custom field definitions.

This complements StandardFields by allowing registration of custom field definitions at runtime.

classmethod clear()[source]ΒΆ

Clear the registry (mainly for testing).

Return type:

None

classmethod get(name)[source]ΒΆ

Get a registered field definition.

Parameters:

name (str)

Return type:

haive.core.schema.field_definition.FieldDefinition | None

classmethod list_fields()[source]ΒΆ

List all registered field names.

Return type:

list[str]

classmethod register(field_def)[source]ΒΆ

Register a custom field definition.

Parameters:

field_def (haive.core.schema.field_definition.FieldDefinition)

Return type:

None

class haive.core.schema.field_registry.PrebuiltStates[source]ΒΆ

Registry of prebuilt state schemas for common use cases.

Hierarchy: - MessagesState (basic, no tokens) - MessagesStateWithTokenUsage (with token tracking)

  • LLMState (single engine + tokens + thresholds) - ToolState (tools + LLM features)

classmethod base_messages_state()[source]ΒΆ

Get basic MessagesState without token tracking.

Return type:

Any

classmethod llm_state()[source]ΒΆ

Get LLMState for single-engine LLM agents with token tracking and model awareness.

Return type:

Any

classmethod messages_with_tokens()[source]ΒΆ

Get MessagesStateWithTokenUsage for token-aware conversations.

Return type:

Any

classmethod tool_state()[source]ΒΆ

Get ToolState for tool-using agents with LLM features, tools, and token tracking.

Return type:

Any

class haive.core.schema.field_registry.StandardFields[source]ΒΆ

Registry of standard field definitions used across Haive.

Each field is defined with: - name: field name in snake_case - type: proper Python type annotation - description: human-readable description - default: default value or factory - metadata: additional field metadata

classmethod ai_message()[source]ΒΆ

Single AI message output field.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod available_nodes()[source]ΒΆ

Available graph nodes.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod context()[source]ΒΆ

Retrieved context documents.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod documents()[source]ΒΆ

Retrieved documents with metadata.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod engine_name()[source]ΒΆ

Name of the engine being used.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod human_message()[source]ΒΆ

Single human message input field.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod messages(use_enhanced=True)[source]ΒΆ

Standard messages field for conversation history.

Parameters:

use_enhanced (bool) – Whether to use the enhanced MessageList with token counting and metadata

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod observations()[source]ΒΆ

Agent observations from tools/environment.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod plan_steps()[source]ΒΆ

Generated plan steps.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod query()[source]ΒΆ

User query string.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod structured_output(model_class, field_name=None)[source]ΒΆ

Create a structured output field for a Pydantic model.

Parameters:
  • model_class (type[pydantic.BaseModel]) – The Pydantic model class

  • field_name (str | None) – Optional custom field name (defaults to snake_case model name)

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod thoughts()[source]ΒΆ

Agent reasoning thoughts.

Return type:

haive.core.schema.field_definition.FieldDefinition

classmethod tool_routes()[source]ΒΆ

Tool routing configuration.

Return type:

haive.core.schema.field_definition.FieldDefinition

haive.core.schema.field_registry.get_standard_field(name, **kwargs)[source]ΒΆ

Get a standard field definition by name.

Parameters:
  • name (str) – Standard field name (e.g., β€˜messages’, β€˜context’, β€˜query’)

  • **kwargs – Additional arguments passed to the field method

Returns:

FieldDefinition or None if field not found

Return type:

haive.core.schema.field_definition.FieldDefinition | None