Trajectory: Generation rules, execution details, and field reference

Updated at:

Trajectory uses outer fields to provide retrieval, summaries, and statistics, and uses atif_content to store standardized execution details. The outer statistics cover the recognizable executions of this snapshot. Do not add summary values from different levels in ATIF to the outer fields.

What you get from the source

Source facts

Transformation

Result

Multiple model inputs, outputs, and tool messages

Identifies actual executions and repeated context, and organizes ordered steps

ATIF steps, model/tool calls, and observations

Recognizable inputs and outputs of agents and workflows

Selects business-level summaries and generates minimal message nodes when necessary

Outer input/output, and real execution nodes

Source models and usage

Deduplicates and aggregates by actual call identity

model_calls, tokens, and estimated cost

Explicit tool calls and evidence of sub-agent execution

Generates strict delegation relationships

ATIF references, embedded trajectories, and relationship index

Source business time

Normalizes to milliseconds and calculates the span

start_time/end_time/duration_ms

Missing, restricted, or ambiguous evidence

Retains expressible executions and marks quality

degraded and quality information of each node

The result summary of the first turn "Query order" is as follows.

{
  "trajectory_id": "11111111111111111111111111111111",
  "trace_id": "11111111111111111111111111111111",
  "source_kind": "otel_trace",
  "session_id": "session-demo-001",
  "input": "Query order 10001",
  "output": "Order 10001 has been shipped.",
  "model_call_count": "2",
  "tool_call_count": "1",
  "step_count": "3",
  "input_tokens": "80",
  "output_tokens": "30",
  "total_tokens": "110",
  "total_cost": "",
  "trajectory_extensions": "{\"cost\":{\"status\":\"unavailable\"}}"
}

In this example, the three steps are the user input, the agent step that issues the tool call and carries the result, and the final answer. The tokens of both actual model calls are counted. The tool result is not an additional model call. The sample model has no available price, so the tokens are retained and the cost is empty.

How to read fields

The types in the following tables are logical types after decoding. Regular SLS fields actually store strings: integers use decimal notation, flags use "0"/"1", and objects/arrays use JSON text. Unreported numeric values can be "". They cannot be automatically converted to 0.

"Common" indicates that the field exists in both snapshot sources described in this topic. "Trace custom" indicates the Trace field set that contains custom fields.

Identifiers, versions, and sources

Field

Logical type

Scope

Definition and purpose

trajectory_id

string

Common

Stable logical result ID. For Trace, it is the same as the source traceId. For Log, it is generated based on session/turn. Reference it as an opaque ID.

trace_id

string

Trace

Original Trace ID, used to look up source spans

turn_id

string

Log

Business turn ID from the source. It is not the display sequence number in a Session.

source_kind

string

Common

This topic uses otel_trace/otel_log to select the corresponding parsing and identification rules

session_id

string

Common

Session association identifier. It can be missing for Trace and must be non-empty for Log sources.

version

string

Common

ATIF format version, consistent with atif_content.schema_version. It is not a snapshot revision number.

Under the same data space, source, and trajectory_id, the snapshot with the largest numeric process_time is selected as the current snapshot. The processing time is used to compare the recency of snapshots and does not indicate causality between business calls or whether the business has ended. After a snapshot replaces an earlier version, recalculate the Session summary.

Input, output, and time

Field

Logical type/Unit

Scope

Definition and purpose

input

string

Common

User input summary of the current execution scope. It does not concatenate all history.

output

string

Common

Current user-visible answer selected based on source rules. Determine the degree of completion based on quality information.

input_empty_reason

string

Common

Can be no_non_copied_user_message when no selectable user input exists. If the current Trace has selected an explicitly empty user input, both input and this field are empty. Do not misjudge this as missing input.

start_time

int64, Unix ms

Common

Start boundary of the related execution, used for sorting and time filtering

end_time

int64, Unix ms

Common

End boundary of the related execution

duration_ms

integer, ms

Common

Non-negative value of end minus start. It is a span, not the sum of the durations of nested calls.

process_time

int64, Unix ns

Common

Processing time of this result, used for snapshot selection. It is not the source event time or the time when SLS finishes receiving the data.

output_modalities

String array

Common

Modality labels of projected outputs. An empty array does not prove that no text output exists.

output_artifacts

Object array

Common

Projected structured artifacts and source references. Consume them separately from the text output field

For Trace, input/output are selected separately: WORKFLOW/ENTRY containing recognizable messages takes precedence, followed by AGENT, and then LLM messages. Input and output can come from different levels. Historical assistant messages, tool results, pure reasoning, and tool-call-only messages are not treated as the final answer. Conflicts among multiple entries have explicit selection and degradation rules. The integration side should preferentially report a unique business entry.

For Log, input is the earliest provable user input of the current turn. When the initial request carries history, questions from earlier turns are not mistaken for the input of the current turn. output is selected based on the currently recognizable user-visible answer of the turn. A context reset does not erase executions already observed in the turn and does not change the logical ID.

When Trace completely lacks usable business time, the result can use the processing time to maintain the log time association and records business_time_unavailable. Although such fields contain numbers, they cannot be used as measured business latency.

Agent and service

Field

Logical type

Scope

Definition and purpose

agent_name

string

Common

Name of the selected representative agent. It does not mean that all steps and usage belong to it.

agent_version

string

Common

Corresponding version. When the source version is missing, the value can be unknown

agent_attributes

object

Common

Attribute extensions of the selected source. For Trace, it often contains span_id/attributes and is not guaranteed to cover all agents.

agent_names

String array

Common

Set of agent names of real execution nodes, deduplicated and sorted, excluding synthetic containers

service_names

String array

Common

Set of related service names, used for retrieval by service dimension

For Trace, the representative agent is selected from the real execution root nodes. The execution branch that clearly corresponds to the input and output of the current turn is preferred. If it cannot be uniquely determined, a stable order is determined based on the number of new steps, the start time, and the trajectory ID. The name, version, and attributes come from the same node.

A single Trace can contain multiple independent agents. Session identifiers and source extensions preferentially use non-empty values of the representative node and are supplemented from other real nodes when missing. Each source extension is taken entirely from one node. When you analyze the behavior of an agent, read the corresponding ATIF node. Do not attribute the usage of the whole Trace to the representative agent.

Models, tokens, and cost

Field

Logical type

Scope

Definition and purpose

step_count

integer

Common

Step count of the current execution, excluding copied context. It differs from the total length of all arrays in the recursive ATIF.

model_call_count

integer

Common

Number of actual model calls. Tool steps, deterministic messages, and parent agent summaries are not additional model calls.

models

String array

Common

Set of model names, deduplicated and sorted. For each call, the response model is preferred, and the request model is used as a fallback if the response model is missing.

model_calls

object

Common

Call and usage statistics organized by model name

input_tokens

integer or missing

Common

Summary of reported input tokens, including the history that the model actually processed in each call

output_tokens

integer or missing

Common

Summary of reported output tokens

total_tokens

integer or missing

Common

Sum of input and output when both summaries have values. The presence of a value does not prove that all calls reported usage.

cached_tokens

integer or missing

Common

Reported cache-hit input volume. It is a subset of input.

total_cost

decimal or missing, in CNY

Common

Estimated model cost of the current trajectory and its descendants after deduplication. It is actually stored as a plain decimal string.

model_calls uses model names as keys, and each value contains:

Relative field

Type

Description

count

integer

Number of calls to the model

tokens_in, tokens_out

integer, optional

Reported input and output summaries of the model

cached_tokens, cache_creation_input_tokens, reasoning_output_tokens

integer, optional

Reported usage of the corresponding dimension

tokens_in_reported_calls, tokens_out_reported_calls

integer

Number of calls that reported input and output usage

cached_tokens_reported_calls

integer

Number of calls that reported cache hits

cache_creation_reported_calls

integer

Number of calls that reported cache creation

reasoning_output_reported_calls

integer

Number of calls that reported reasoning output

If reported_calls is 0, no usage is reported. If it is less than count, the coverage is incomplete. Cache reads/creation belong to input and reasoning belongs to output, so they are not added to total again. Do not add up Raw usage, ATIF metrics, and outer statistics at the same time.

The cost is estimated per call based on static model prices, includes descendants with deduplication, and supports recognized cache pricing. It is not equal to the account bill and does not include free quotas, resource plans, or promotional discounts. Do not simply multiply the total tokens of the whole session by a single unit price.

trajectory_extensions.cost.status value

total_cost

Other content

complete

Decimal string of the total cost, including the known zero value "0"

All currently known evidence can be fully priced

partial

""

observed_cost_cny stores the subtotal of the calculable part

unavailable

""

No determinable total cost

Missing required usage, unknown models, unclear pricing conditions, or gaps in execution evidence can affect the cost status. complete is limited to the known evidence of the current snapshot. Use decimal types such as Decimal for amounts in applications. Do not mix them with USD fields in the ATIF standard.

Tools, skills, and quality

Field

Logical type

Scope

Definition and purpose

tool_calls

object

Common

Statistics in the {count, errors} format, organized by tool name

tool_call_count

integer

Common

Number of actual tool calls in the current execution, excluding repeated presentations in copied context

tool_names

String array

Common

Set of tool names, deduplicated and sorted

tool_errors

integer

Common

Number of errors identified in the corresponding tool results. A missing result does not mean success.

skills

object

Common

Call statistics of recognized skill metadata, organized by stable keys such as id/name

skill_call_count

integer or missing

Common

Number of recognizable skill calls. It can be empty when no metadata exists.

skill_ids, skill_names

String array

Common

Set of recognized skill identities and names

degraded

boolean, stored as 0/1

Common

Whether data quality is degraded. It does not indicate business success or failure.

degraded_reason

string

Common

Comma-separated quality reasons. For detailed explanations, see each node.

trajectory_extensions

object

Common

Result extensions such as source extensions and cost status, read according to defined substructures

custom_fields

object

Trace custom

Mapping from custom field names to string arrays. Values are deduplicated and deterministically sorted.

custom_fields_status

string

Trace custom

complete/partial/error. It describes only the processing result of custom fields.

atif_content

object, stored as JSON text

Common

Standardized execution process. For the structure, see the following sections.

Tool errors use the status and error information of normalized observations. Original HTTP status codes are not directly applied to business success rules. A skill statistics item looks like {"id":"order-skill","name":"Order query","versions":["1.0"],"count":1}. Call intents must match actual skill metadata. Do not guess based on names.

custom_fields can look like {"order_id":["10001"],"region":["East China"]}. When no rule is configured, it can be {}. Successful processing does not prove that the source data or business is complete. Array elements retain field-level string semantics.

ATIF execution details

Decode atif_content and read it based on schema_version. The current format is ATIF-v1.7. Session display objects and outer retrieval fields are not part of the ATIF standard. The following table lists common output structures of this product. For more optional standard structures, see ATIF RFC. Always rely on the recorded version when reading.

Path

Type

Definition

schema_version

string

ATIF format version

trajectory_id

string

Identity of the current root or embedded trajectory, used to resolve references

session_id

string, optional

Source session of the current real trajectory. Synthetic roots do not carry a business session.

agent

object

Agent configuration of the current node

agent.name, agent.version

string

Two independent fields: name and version

agent.model_name

string, optional

Default model. For actual calls, also check step.model_name.

agent.tool_definitions

Object array, optional

Tool definitions reported by the source

steps

Step array

Sequential execution details of the current node

subagent_trajectories

Trajectory array, optional

Recursively embedded trajectories. A synthetic root contains multiple independent real roots.

final_metrics

object, optional

Summary of the current real node's own steps. Its descendants are not automatically added again.

extra

object, optional

Source and quality extensions

Steps and tool results

Step field

Type

Definition

step_id

integer

Step number starting from 1 within the current trajectory

timestamp

ISO time string, optional

Execution/message evidence time. The time of copied history is not guaranteed to be its original generation time.

source

string

system/user/agent. The source assistant role is mapped to agent.

message

string or content array

User-visible content. Non-text content can use content parts.

is_copied_context

boolean, optional

Whether the entry is copied context. When reading for display, you can interpret its absence as non-copied context.

model_name

string, optional

Model used by the step that owns this model call

llm_call_count

integer, optional

Number of actual model calls handled by the step. Deterministic scheduling does not fabricate model calls.

reasoning_content

string, optional

Reasoning content provided by the source. It is not hidden reasoning that is automatically filled in.

tool_calls

Object array, optional

Tool call array: tool_call_id/function_name/arguments, optionally with extra

observation.results

Object array, optional

Result array. Use source_call_id to align with the tool call IDs of the step

metrics

object, optional

prompt_tokens/completion_tokens/cached_tokens and other call metrics

extra

object, optional

Local source, artifact, or quality extensions

ATIF step of a tool interaction:

{
  "step_id": 2,
  "timestamp": "2026-01-01T00:00:00.400Z",
  "source": "agent",
  "message": "",
  "model_name": "example-chat-model",
  "llm_call_count": 1,
  "tool_calls": [
    {"tool_call_id":"call-order-001","function_name":"get_order","arguments":{"order_id":"10001"}}
  ],
  "observation": {
    "results": [{"source_call_id":"call-order-001","content":"Order 10001 has been shipped."}]
  },
  "metrics": {"prompt_tokens":30,"completion_tokens":10}
}

observation.results[ ].subagent_trajectory_ref[ ] can use trajectory_id to reference sub-trajectories explicitly delegated in the current snapshot. Tool results and sub-trajectory references are attached to the exact call step and are not matched by a shared session_id.

In ATIF multimodal content, message can be a content array, such as [{"type":"text","text":"Result description"}]. Note that the field here is text, which differs from the content field of source message Parts. Artifacts retain the provided types and references and are not automatically downloaded or executed.

Summaries and source extensions

final_metrics uses total_prompt_tokens/total_completion_tokens/total_cached_tokens to express the usage reported by the node itself. total_steps is the number of all steps of the node, including copied context. The outer step_count excludes copied context and uses the execution deduplication criteria of the snapshot.

final_metrics.extra.token_usage_completeness contains reported_calls/total_calls/complete for each dimension. The presence of a value and complete reporting are two separate judgments: a partial set of observed calls can also produce a non-empty summary.

extra.data_quality often contains degraded/reasons/diagnostic_codes, which is used to locate issues of the node. For Trace, extra.otel_trace can store span_id and source attributes, which should be looked up within the same Trace. The span can also be a model call and should be interpreted together with the source operation type. Only the selected part of source attributes is retained, and ATIF does not guarantee verbatim retention of the original request.

extra.source_terminal_reason/turn_outcome expresses the end reason and result category based on the source. Do not use it to define a general Session state machine. Source extensions are not a fixed structure that all ATIF data sources must support.

Multi-agent relationships

Field

Logical type

Scope

Definition and purpose

has_sub_agent

boolean, stored as 0/1

Common

Whether confirmed delegated trajectories exist. It does not check whether the embedded array is non-empty.

sub_agent_count

integer

Common

Number of delegation groups. A group can reference multiple sub-trajectories.

subagent_trajectory_ids

String array

Common

Set of IDs of truly delegated nodes, excluding independent roots

trajectory_relationships

object

Common

Projection of trajectory positions and real parent nodes in the current snapshot

The relationship structure is as follows:

{
  "version": 1,
  "trajectories": [
    {"trajectory_id":"parent","path":"$"},
    {"trajectory_id":"child","path":"$['subagent_trajectories'][0]","parent_trajectory_id":"parent"}
  ]
}

This snippet shows the shape of the relationship field. The corresponding ATIF must also contain an exact delegation reference from the parent step to the child.

Each real non-root node has at most one parent_trajectory_id. The order of the relationship list is consistent with the recursive order of ATIF, and siblings are stably ordered by business time and ID. Paths are valid only within this snapshot and cannot be reused in subsequent snapshots. A shared Trace, span containment, similar names, or adjacent times cannot directly create an agent delegation.

When at least two independent real trees exist, ATIF uses a synthetic root with agent={"name":"synthetic_root","version":"1"} to contain them. The synthetic root has empty steps and carries no business identity or usage. The real independent roots under it have no parent_trajectory_id. Therefore, "embedded trajectories are non-empty, but has_sub_agent=0" can be completely normal.

Storage metadata and indexes

__time__ is the SLS log time, which is usually associated with the start time of the result at second granularity. __topic__ is the topic, __source__ is the source metadata, and __pack_meta__ is the packing metadata. They are not involved in defining the business Trajectory schema and are not used as agent relationships or session primary keys.

Numeric statistics fields are configured with numeric types. IDs are used as full values. In reading solutions with scan indexes enabled, you can use scan SQL to read the complete JSON and aggregate Sessions. During scanning, you still need to convert numbers based on field semantics and retain JSON string encoding. Do not automatically parse plain text as JSON.