Skip to main content

[!FROZEN] MPLP Protocol v1.0.0 Frozen Specification Freeze Date: 2025-12-03 Status: FROZEN (no breaking changes permitted) Governance: MPLP Protocol Governance Committee (MPGC) License: Apache-2.0 Note: Any normative change requires a new protocol version.

Runtime Trace Format

1. Purpose

The Runtime Trace Format defines the JSON structure for exporting execution data from an MPLP runtime. It is designed to be compatible with the W3C Trace Context standard while adding MPLP-specific semantics.

Design Principle: "Standard format for interoperability with observability tools"

2. Trace Structure

2.1 Hierarchy

Trace (root)
Segment (unit of work) Events (discrete points) Attributes (metadata)
Segment Events Attributes
...

2.2 Trace Object

From: schemas/v2/mplp-trace.schema.json

FieldTypeDescription
trace_idUUID v4Unique trace identifier
context_idUUID v4Parent Context reference
plan_idUUID v4Associated Plan
statusEnumTrace status
segmentsArrayList of Segments
started_atISO 8601Trace start time
ended_atISO 8601Trace end time
eventsArrayTrace-level events

2.3 Segment Object

FieldTypeDescription
segment_idUUID v4Unique segment identifier
parent_segment_idUUID v4Parent segment (for nesting)
labelStringHuman-readable label
statusEnumSegment status
operationStringOperation name
started_atISO 8601Start timestamp
ended_atISO 8601End timestamp
attributesObjectKey-value metadata
eventsArraySegment events

3. W3C Trace Context Compatibility

3.1 Mapping

W3C FieldMPLP FieldDescription
trace-idtrace_id16-byte identifier
parent-idparent_segment_idParent span reference
trace-flagssampledSampling decision
tracestateattributesVendor-specific data

3.2 HTTP Header Format

traceparent: 00-{trace_id}-{segment_id}-01
tracestate: mplp=context_id:{ctx_id};plan_id:{plan_id}

Example:

traceparent: 00-550e8400e29b41d4a716446655440000-a716446655440001-01
tracestate: mplp=context_id:ctx-550e8400;plan_id:plan-123

4. Attributes

4.1 Standard Attributes

AttributeTypeDescription
mplp.moduleStringModule originating the span
mplp.operationStringOperation name
mplp.agent_roleStringRole executing the action
mplp.step_idUUIDAssociated step
mplp.errorStringError message (if failed)
mplp.tokens_usedNumberLLM tokens consumed
mplp.duration_msNumberExecution duration

4.2 Extended Attributes

AttributeTypeDescription
mplp.tool.nameStringTool name
mplp.tool.argsObjectTool arguments
mplp.llm.modelStringLLM model name
mplp.llm.tokens_inNumberInput tokens
mplp.llm.tokens_outNumberOutput tokens

5. Complete JSON Example

{
"meta": {
"protocolVersion": "1.0.0"
},
"trace_id": "trace-550e8400-e29b-41d4-a716-446655440000",
"context_id": "ctx-550e8400-e29b-41d4-a716-446655440000",
"plan_id": "plan-550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"started_at": "2025-12-07T00:00:00.000Z",
"ended_at": "2025-12-07T00:05:00.000Z",
"segments": [
{
"segment_id": "seg-001",
"parent_segment_id": null,
"label": "Plan Execution",
"status": "completed",
"operation": "execute_plan",
"started_at": "2025-12-07T00:00:00.000Z",
"ended_at": "2025-12-07T00:05:00.000Z",
"attributes": {
"mplp.module": "plan",
"mplp.operation": "execute_plan",
"mplp.agent_role": "orchestrator"
}
},
{
"segment_id": "seg-002",
"parent_segment_id": "seg-001",
"label": "Step 1: Read error logs",
"status": "completed",
"operation": "execute_step",
"started_at": "2025-12-07T00:00:01.000Z",
"ended_at": "2025-12-07T00:01:00.000Z",
"attributes": {
"mplp.module": "plan",
"mplp.operation": "execute_step",
"mplp.step_id": "step-001",
"mplp.agent_role": "debugger",
"mplp.duration_ms": 59000
}
},
{
"segment_id": "seg-003",
"parent_segment_id": "seg-002",
"label": "LLM Call: Analyze logs",
"status": "completed",
"operation": "llm_call",
"started_at": "2025-12-07T00:00:02.000Z",
"ended_at": "2025-12-07T00:00:05.000Z",
"attributes": {
"mplp.module": "extension",
"mplp.operation": "llm_call",
"mplp.llm.model": "gpt-4",
"mplp.llm.tokens_in": 500,
"mplp.llm.tokens_out": 200,
"mplp.tokens_used": 700,
"mplp.duration_ms": 3000
}
},
{
"segment_id": "seg-004",
"parent_segment_id": "seg-002",
"label": "Tool Call: file_read",
"status": "completed",
"operation": "tool_call",
"started_at": "2025-12-07T00:00:10.000Z",
"ended_at": "2025-12-07T00:00:11.000Z",
"attributes": {
"mplp.module": "extension",
"mplp.operation": "tool_call",
"mplp.tool.name": "file_read",
"mplp.tool.args": {"path": "/var/log/auth.log"},
"mplp.duration_ms": 1000
}
}
],
"events": [
{
"event_id": "evt-001",
"event_type": "SAInitialized",
"event_family": "runtime_execution",
"timestamp": "2025-12-07T00:00:00.000Z"
},
{
"event_id": "evt-002",
"event_type": "pipeline_stage_started",
"event_family": "pipeline_stage",
"timestamp": "2025-12-07T00:00:00.000Z"
},
{
"event_id": "evt-003",
"event_type": "SACompleted",
"event_family": "runtime_execution",
"timestamp": "2025-12-07T00:05:00.000Z"
}
]
}

6. Export Formats

6.1 JSON Lines (JSONL)

For log aggregation and streaming:

{"trace_id":"trace-001","segment_id":"seg-001","operation":"execute_plan","timestamp":"2025-12-07T00:00:00.000Z"}
{"trace_id":"trace-001","segment_id":"seg-002","operation":"execute_step","timestamp":"2025-12-07T00:00:01.000Z"}
{"trace_id":"trace-001","segment_id":"seg-003","operation":"llm_call","timestamp":"2025-12-07T00:00:02.000Z"}

6.2 OpenTelemetry Protocol (OTLP)

For integration with observability platforms:

import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';

function convertToOTLP(trace: MPLPTrace): OTLPTrace {
return {
resourceSpans: [{
resource: {
attributes: [
{ key: 'mplp.context_id', value: { stringValue: trace.context_id } },
{ key: 'mplp.plan_id', value: { stringValue: trace.plan_id } }
]
},
scopeSpans: [{
scope: { name: 'mplp-runtime', version: '1.0.0' },
spans: trace.segments.map(s => ({
traceId: trace.trace_id,
spanId: s.segment_id,
parentSpanId: s.parent_segment_id,
name: s.label,
kind: 1, // INTERNAL
startTimeUnixNano: toNanos(s.started_at),
endTimeUnixNano: toNanos(s.ended_at),
attributes: Object.entries(s.attributes || {}).map(([k, v]) => ({
key: k,
value: { stringValue: String(v) }
}))
}))
}]
}]
};
}

6.3 Jaeger Format

{
"traceID": "550e8400e29b41d4a716446655440000",
"spans": [
{
"spanID": "a716446655440001",
"operationName": "execute_plan",
"startTime": 1733529600000000,
"duration": 300000000,
"tags": [
{"key": "mplp.module", "type": "string", "value": "plan"},
{"key": "mplp.agent_role", "type": "string", "value": "orchestrator"}
]
}
]
}

7. SDK Implementation

class TraceExporter {
async exportAsJSONL(trace: Trace): Promise<string> {
const lines: string[] = [];

for (const segment of trace.segments) {
lines.push(JSON.stringify({
trace_id: trace.trace_id,
segment_id: segment.segment_id,
parent_segment_id: segment.parent_segment_id,
operation: segment.operation,
label: segment.label,
status: segment.status,
started_at: segment.started_at,
ended_at: segment.ended_at,
...segment.attributes
}));
}

return lines.join('\n');
}

async exportToOTLP(trace: Trace, endpoint: string): Promise<void> {
const otlpTrace = convertToOTLP(trace);
await fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(otlpTrace)
});
}
}

Observability:

Modules:

Schemas:

  • schemas/v2/mplp-trace.schema.json
  • schemas/v2/common/trace-base.schema.json

Document Status: Normative (Export Format)
W3C Compatible: Yes (Trace Context)
Export Formats: JSON, JSONL, OTLP, Jaeger
Standard Attributes: 7 core + 5 extended

2025 Bangshi Beijing Network Technology Limited Company Licensed under the Apache License, Version 2.0.