nat.atif#
Pydantic models for Agent Trajectory Interchange Format (ATIF).
Models are derived from the Harbor reference implementation (harbor-framework/harbor) and follow the ATIF RFC (0001-trajectory-format). NAT-specific relaxations are documented inline in the individual model files.
Backward-compatible aliases (ATIFStep, ATIFTrajectory, and so on)
are provided so existing code can continue to work without import changes.
Submodules#
Attributes#
Classes#
Agent system identification and configuration. |
|
Validated ancestry metadata embedded in ATIF |
|
Invocation timing metadata embedded in ATIF |
|
Validated structure for NAT-owned ATIF |
|
Validated structure for NAT-owned ATIF |
|
A single content part within a multimodal message. |
|
Image source specification for images stored as files or at remote URLs. |
|
Aggregate statistics for the entire trajectory. |
|
LLM operational and confidence data for a single step. |
|
Environment feedback/result after actions or system events. |
|
A single result within an observation. |
|
A single step in an ATIF trajectory. |
|
Reference to a delegated subagent trajectory (ATIF v1.7). |
|
A tool call within a step. |
|
ATIF trajectory — the complete interaction history of an agent run. |
Package Contents#
- class Agent(/, **data: Any)#
Bases:
pydantic.BaseModelAgent system identification and configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class AtifAncestry(/, **data: Any)#
Bases:
pydantic.BaseModelValidated ancestry metadata embedded in ATIF
extradicts.Used in two locations under the NAT convention:
Step.extra["ancestry"]— step-level: which callable produced this step (e.g. an LLM node under a parent agent).ToolCall.extra["ancestry"]— per-tool-call: which callable issued this tool invocation.
The model enforces a parent-pair invariant:
parent_nameMAY only be set whenparent_idis also set. The inverse —parent_idset,parent_nameunset — is allowed (the converter emits this when a parent’s UUID isn’t in the local name map).Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- _validate_parent_pair() Self#
- class AtifInvocationInfo(/, **data: Any)#
Bases:
pydantic.BaseModelInvocation timing metadata embedded in ATIF
extradicts.Used at
Step.extra["invocation"]for step-level timing and atToolCall.extra["invocation"]for per-tool timing.Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- validate_timestamp_pairing() Self#
- class AtifStepExtra(/, **data: Any)#
Bases:
pydantic.BaseModelValidated structure for NAT-owned ATIF
Step.extrapayload.NAT writes the following keys into
Step.extraunder this convention:ancestry(required by NAT’s converter) —AtifAncestryshape: which callable produced this step.invocation(optional) —AtifInvocationInfoshape: step-level timing.data_schema(optional, opaque dict) — the producer-declared ATOF data_schema preserved for downstream validation.
Per-tool-call ancestry and timing live on
ToolCall.extra, NOT here — they’re co-located with the tool_call they describe rather than aligned by index on the parent step. This is the v1.7-aligned layout (the spec addsextratoToolCallfor this purpose).model_config = ConfigDict(extra="allow")so callers MAY add additional keys. The requiredancestryfield documents NAT’s own convention but does not preclude other producers from emitting differentStep.extrashapes.Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- ancestry: AtifAncestry = None#
- invocation: AtifInvocationInfo | None = None#
- class AtifToolCallExtra(/, **data: Any)#
Bases:
pydantic.BaseModelValidated structure for NAT-owned ATIF
ToolCall.extrapayload.NAT writes the following keys into
ToolCall.extraunder this convention:ancestry(optional) —AtifAncestryshape: which callable issued this tool invocation.invocation(optional) —AtifInvocationInfoshape: per-tool-call timing.
model_config = ConfigDict(extra="allow")so callers MAY add additional keys.extra="allow"also means aToolCall.extrathat lacks both keys still validates — neither is required by the NAT convention.Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- ancestry: AtifAncestry | None = None#
- invocation: AtifInvocationInfo | None = None#
- class ContentPart(/, **data: Any)#
Bases:
pydantic.BaseModelA single content part within a multimodal message.
Used when a message or observation contains mixed content types (text and images). For text-only content, a plain string can still be used instead of a ContentPart array.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- type: Literal['text', 'image'] = None#
- source: ImageSource | None = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- validate_content_type() ContentPart#
Validate that the correct fields are present for each content type.
- class ImageSource(/, **data: Any)#
Bases:
pydantic.BaseModelImage source specification for images stored as files or at remote URLs.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- media_type: Literal['image/jpeg', 'image/png', 'image/gif', 'image/webp'] = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class FinalMetrics(/, **data: Any)#
Bases:
pydantic.BaseModelAggregate statistics for the entire trajectory.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Metrics(/, **data: Any)#
Bases:
pydantic.BaseModelLLM operational and confidence data for a single step.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Observation(/, **data: Any)#
Bases:
pydantic.BaseModelEnvironment feedback/result after actions or system events.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- results: list[nat.atif.observation_result.ObservationResult] = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ObservationResult(/, **data: Any)#
Bases:
pydantic.BaseModelA single result within an observation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- content: str | list[nat.atif.content.ContentPart] | None = None#
- subagent_trajectory_ref: list[nat.atif.subagent_trajectory_ref.SubagentTrajectoryRef] | None = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Step(/, **data: Any)#
Bases:
pydantic.BaseModelA single step in an ATIF trajectory.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- source: Literal['system', 'user', 'agent'] = None#
- message: str | list[nat.atif.content.ContentPart] = None#
- tool_calls: list[nat.atif.tool_call.ToolCall] | None = None#
- observation: nat.atif.observation.Observation | None = None#
- metrics: nat.atif.metrics.Metrics | None = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class SubagentTrajectoryRef(/, **data: Any)#
Bases:
pydantic.BaseModelReference to a delegated subagent trajectory (ATIF v1.7).
A ref MUST be resolvable via at least one of two mechanisms:
Embedded form —
trajectory_idmatches thetrajectory_idof an entry in the parentTrajectory.subagent_trajectoriesarray.File-ref form —
trajectory_pathreferences an external file (path, S3 URL, database identifier, etc.).
A ref MUST set at least one of
trajectory_idortrajectory_path; setting both is permitted (an embedded ref MAY also record the original file path for debug).session_idis run-scoped and informational only — it is NOT a valid resolution key (two sibling subagents MAY legitimately share asession_id).Breaking vs. v1.6: in v1.6
session_idwas required on the ref and served as the resolution key. Under v1.7 a ref of the shape{"session_id": "..."}(notrajectory_idand notrajectory_path) no longer validates. Producers MUST migrate by settingtrajectory_idfor embedded refs ortrajectory_pathfor external-file refs. Pre-v1.7 refs that already settrajectory_pathremain valid.Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- _validate_resolution_key_present() Self#
- class ToolCall(/, **data: Any)#
Bases:
pydantic.BaseModelA tool call within a step.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- ATIF_VERSION = 'ATIF-v1.7'#
- class Trajectory(/, **data: Any)#
Bases:
pydantic.BaseModelATIF trajectory — the complete interaction history of an agent run.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- schema_version: Literal['ATIF-v1.0', 'ATIF-v1.1', 'ATIF-v1.2', 'ATIF-v1.3', 'ATIF-v1.4', 'ATIF-v1.5', 'ATIF-v1.6', 'ATIF-v1.7'] = None#
- agent: nat.atif.agent.Agent = None#
- steps: list[nat.atif.step.Step] = None#
- final_metrics: nat.atif.final_metrics.FinalMetrics | None = None#
- subagent_trajectories: list[Trajectory] | None = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- to_json_dict(exclude_none: bool = True) dict[str, Any]#
Export trajectory to a dictionary suitable for JSON serialization.
- validate_step_ids() Trajectory#
Validate that step_ids are sequential starting from 1.
- validate_subagent_trajectory_ids() Trajectory#
Spec §IV: every embedded subagent MUST set
trajectory_id, andtrajectory_ids within the parent’ssubagent_trajectoriesarray MUST be unique. (session_ids, by contrast, are run-scoped and MAY collide across siblings.)
- validate_tool_call_references() Trajectory#
Validate that observation source_call_ids reference valid tool_call_ids.
- ATIFAgentConfig#
- ATIFContentPart#
- ATIFImageSource#
- ATIFFinalMetrics#
- ATIFStepMetrics#
- ATIFObservation#
- ATIFObservationResult#
- ATIFStep#
- ATIFSubagentTrajectoryRef#
- ATIFToolCall#
- ATIFTrajectory#