Metadata-Version: 2.5
Name: atif
Version: 1.8.0
Summary: Pydantic models for the Agent Trajectory Interchange Format (ATIF v1.8).
Project-URL: Homepage, https://github.com/bolu61/python-atif
Project-URL: Repository, https://github.com/bolu61/python-atif
Project-URL: Issues, https://github.com/bolu61/python-atif/issues
Project-URL: Specification, https://github.com/harbor-framework/harbor/blob/main/rfcs/0001-trajectory-format.md
Author-email: bolu61 <bolu61@zjc.dev>
License-Expression: MIT
License-File: LICENSE
Keywords: agent,atif,harbor,llm,pydantic,schema,trajectory
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: pydantic>=2.9
Description-Content-Type: text/markdown

![PyPI - Version](https://img.shields.io/pypi/v/atif)
![PyPI - Downloads](https://img.shields.io/pypi/dm/atif)


# atif

Pydantic models for the [Agent Trajectory Interchange Format (ATIF)][spec], a
standardized JSON schema for logging the complete interaction history of
autonomous LLM agents (user messages, agent responses, tool calls, observations,
metrics, and embedded subagent trajectories). Implements ATIF v1.8.
This project is independent and **not an official implemention**.

## Install

```bash
pip install atif
```

## Usage

```python
from atif import Trajectory

data = {
    "schema_version": "ATIF-v1.8",
    "agent": {"name": "my-agent", "version": "1.0.0", "model_name": "claude-sonnet-4-6"},
    "steps": [
        {"step_id": 1, "source": "user", "message": "What time is it?"},
        {
            "step_id": 2,
            "source": "agent",
            "message": "Let me check.",
            "tool_calls": [
                {"tool_call_id": "c1", "function_name": "now", "arguments": {}}
            ],
            "observation": {
                "results": [{"source_call_id": "c1", "content": "2026-05-16T12:00:00Z"}]
            },
            "metrics": {"prompt_tokens": 120, "completion_tokens": 18},
        },
    ],
}

trajectory = Trajectory.model_validate(data)
print(trajectory.steps[1].tool_calls[0].function_name)  # "now"
print(trajectory.to_json_dict(exclude_none=True))
```

Validation enforces the ATIF rules: sequential `step_id`s, ISO 8601 timestamps,
agent-only fields gated on `source == "agent"`, tool-call, observation
correlation, embedded-subagent `trajectory_id` uniqueness, and
`ContentPart` text/source XOR with the source kind matching `type`.

## Versioning

`atif`'s `MAJOR.MINOR` tracks the ATIF RFC version it implements
(`1.8.x` ⇔ ATIF v1.8); `PATCH` is reserved for library-only fixes.

## AI disclosure

Parts of this project, including code, tests, and documentation, were
written with the assistance of AI tooling. Readers should be aware that
AI was involved in its production.

[spec]: https://github.com/harbor-framework/harbor/blob/main/rfcs/0001-trajectory-format.md
