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.

Single-Agent (SA) Profile

1. Purpose

The Single-Agent (SA) Profile is the baseline execution mode for MPLP. It defines the minimal set of modules, invariants, and events required to run a single autonomous agent within a project context.

Design Principle: "One agent, one context, one plan complete traceability"

2. Profile Classification

AttributeValue
Profile IDmplp:profile:sa:1.0.0
Requirement LevelREQUIRED (base profile)
Extends(base)
Extended ByMAP Profile

3. Required Modules

All SA-compliant runtimes MUST implement:

ModuleRequirementUsage
ContextREQUIREDEnvironment and constraints
PlanREQUIREDTask decomposition
TraceREQUIREDExecution audit trail
RoleREQUIREDAgent identity
CoreREQUIREDProtocol manifest

Optional modules:

ModuleRecommendationUsage
ConfirmRECOMMENDEDUser approval
DialogOPTIONALUser conversation
ExtensionOPTIONALPlugin system

4. Invariants

From: schemas/v2/invariants/sa-invariants.yaml

4.1 Context Binding

IDRuleDescription
sa_requires_contextcontext_id is UUID v4SA requires valid Context
sa_context_must_be_activestatus == 'active'Context must be active

4.2 Plan Integrity

IDRuleDescription
sa_plan_context_bindingplan.context_id == context.context_idPlan bound to Context
sa_plan_has_stepssteps.length >= 1At least one step
sa_steps_have_valid_idssteps[*].step_id is UUID v4Valid step IDs
sa_steps_have_agent_rolesteps[*].agent_role non-emptyRole specified

4.3 Traceability

IDRuleDescription
sa_trace_not_emptyevents.length >= 1At least one event
sa_trace_context_bindingtrace.context_id == context.context_idTrace bound to Context
sa_trace_plan_bindingtrace.plan_id == plan.plan_idTrace bound to Plan

4.4 Validation Code

function validateSAProfile(sa: SARuntime): ValidationResult {
const errors: string[] = [];

// Context binding
if (!sa.context?.context_id) {
errors.push('sa_requires_context: Missing context_id');
}
if (sa.context?.status !== 'active') {
errors.push('sa_context_must_be_active: Context not active');
}

// Plan binding
if (sa.plan?.context_id !== sa.context?.context_id) {
errors.push('sa_plan_context_binding: Plan not bound to Context');
}
if (!sa.plan?.steps?.length) {
errors.push('sa_plan_has_steps: Plan has no steps');
}

// Step validation
for (const step of sa.plan?.steps || []) {
if (!step.agent_role) {
errors.push(`sa_steps_have_agent_role: Step ${step.step_id} missing role`);
}
}

return { valid: errors.length === 0, errors };
}

5. Execution Lifecycle

5.1 State Machine

5.2 Phase Descriptions

PhaseDescriptionEvents Emitted
InitializeBoot agent runtimeSAInitialized
LoadContextValidate and bind ContextSAContextLoaded
EvaluatePlanParse and validate PlanSAPlanEvaluated
ExecuteStepRun step (LLM, tool)SAStepStarted, SAStepCompleted
EmitTracePersist to PSGSATraceEmitted
CompleteFinalizeSACompleted

5.3 Sequence Diagram

6. Mandatory Events

From: schemas/v2/events/mplp-sa-event.schema.json

6.1 Event Table

PhaseEvent TypeRequired Fields
InitializeSAInitializedsa_id, timestamp
LoadContextSAContextLoadedsa_id, context_id
EvaluatePlanSAPlanEvaluatedsa_id, plan_id, step_count
ExecuteStepSAStepStartedsa_id, step_id, agent_role
ExecuteStepSAStepCompletedsa_id, step_id, status, duration_ms
EmitTraceSATraceEmittedsa_id, trace_id, events_written
CompleteSACompletedsa_id, status, total_duration_ms
ScenarioEvent TypeRationale
Step failureSAStepFailedDebug and retry logic
Token usageCostAndBudgetEventCost tracking
Tool invocationToolExecutionEventTool audit

6.3 Event Examples

SAStepCompleted:

{
"event_type": "SAStepCompleted",
"event_family": "RuntimeExecutionEvent",
"sa_id": "sa-550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2025-12-07T00:00:05.000Z",
"payload": {
"step_id": "step-123",
"agent_role": "coder",
"status": "completed",
"duration_ms": 1500,
"tokens_used": 450
}
}

SACompleted:

{
"event_type": "SACompleted",
"event_family": "RuntimeExecutionEvent",
"sa_id": "sa-550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2025-12-07T00:05:00.000Z",
"payload": {
"status": "completed",
"plan_id": "plan-123",
"steps_executed": 5,
"steps_succeeded": 5,
"steps_failed": 0,
"total_duration_ms": 30000
}
}

7. Module Interactions

7.1 Data Flow

Context > Plan > Trace    
owner_role agent_role segments
> Role <?

7.2 Module Binding Table

FromFieldToConstraint
Plancontext_idContextMUST match
Tracecontext_idContextMUST match
Traceplan_idPlanMUST match
Plan.Stepagent_roleRoleMUST exist
Contextowner_roleRoleSHOULD exist

8. Usage Scenarios

8.1 Code Refactoring

Context: "Refactor auth service" 
Plan: "Fix login bug"
Step 1: "Read error logs" (agent_role: debugger)
Step 2: "Identify root cause" (agent_role: debugger)
Step 3: "Write fix" (agent_role: coder)
Step 4: "Test fix" (agent_role: tester)

8.2 Data Analysis

Context: "Quarterly report analysis" 
Plan: "Generate Q4 report"
Step 1: "Query database" (agent_role: analyst)
Step 2: "Process data" (agent_role: analyst)
Step 3: "Create visualizations" (agent_role: reporter)

9. SDK Examples

9.1 TypeScript

interface SARuntime {
sa_id: string;
context: Context;
plan: Plan;
trace: Trace;
status: 'initializing' | 'running' | 'completed' | 'failed';
}

async function runSAProfile(context_id: string, plan_id: string): Promise<void> {
const sa: SARuntime = {
sa_id: uuidv4(),
context: await loadContext(context_id),
plan: await loadPlan(plan_id),
trace: createTrace(context_id, plan_id),
status: 'initializing'
};

// Validate SA invariants
const validation = validateSAProfile(sa);
if (!validation.valid) {
throw new Error(`SA validation failed: ${validation.errors.join(', ')}`);
}

// Emit initialization events
await emit({ event_type: 'SAInitialized', sa_id: sa.sa_id });
await emit({ event_type: 'SAContextLoaded', sa_id: sa.sa_id, context_id });
await emit({ event_type: 'SAPlanEvaluated', sa_id: sa.sa_id, plan_id });

sa.status = 'running';

// Execute steps
for (const step of sa.plan.steps) {
await emit({ event_type: 'SAStepStarted', sa_id: sa.sa_id, step_id: step.step_id });

try {
await executeStep(step);
await emit({ event_type: 'SAStepCompleted', sa_id: sa.sa_id, step_id: step.step_id, status: 'completed' });
} catch (error) {
await emit({ event_type: 'SAStepFailed', sa_id: sa.sa_id, step_id: step.step_id, error: error.message });
throw error;
}
}

// Complete
sa.status = 'completed';
await emit({ event_type: 'SACompleted', sa_id: sa.sa_id, status: 'completed' });
}

Architecture:

Profiles:

Invariants:

  • schemas/v2/invariants/sa-invariants.yaml

Document Status: Normative (Core Profile)
Profile ID: mplp:profile:sa:1.0.0
Required Modules: Context, Plan, Trace, Role, Core
Invariant Count: 9 normative rules
Event Count: 7 mandatory event types

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