@bluefly/openstandardagents 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +1 -1
- package/.github/AGENTS.md +245 -0
- package/.github/agents/github-issue-triage.ossa.yaml +99 -0
- package/.github/agents/github-pr-triage.ossa.yaml +137 -0
- package/.github/workflows/issue-sync-to-gitlab.yml +138 -0
- package/.github/workflows/pr-triage-to-gitlab.yml +164 -0
- package/.version.json +1 -1
- package/.wiki-config.json +1 -1
- package/CHANGELOG.md +33 -0
- package/CONTRIBUTING.md +102 -3
- package/README.md +17 -10
- package/dist/services/release-automation/schemas/release.schema.js +1 -1
- package/dist/services/release-automation/webhook.service.js +3 -3
- package/dist/services/release-automation/webhook.service.js.map +1 -1
- package/dist/services/runtime/claude/claude-adapter.d.ts +1 -1
- package/dist/services/runtime/claude/claude-adapter.d.ts.map +1 -1
- package/dist/services/runtime/claude/claude-adapter.js +1 -1
- package/dist/services/runtime/claude/claude-adapter.js.map +1 -1
- package/dist/spec/v0.2.9/a2a-protocol.md +1337 -0
- package/dist/spec/v0.2.9/agent.md +1946 -0
- package/dist/spec/v0.2.9/capabilities/index.yaml +25 -0
- package/dist/spec/v0.2.9/capabilities/memory.yaml +251 -0
- package/dist/spec/v0.2.9/capability-schema.md +576 -0
- package/dist/spec/v0.2.9/compliance-profiles.md +533 -0
- package/dist/spec/v0.2.9/conformance-testing.md +1527 -0
- package/dist/spec/v0.2.9/gitlab-duo-integration.md +621 -0
- package/dist/spec/v0.2.9/ossa-0.2.9.schema.json +3699 -0
- package/dist/spec/v0.2.9/runtime-semantics.md +464 -0
- package/dist/spec/v0.2.9/security-model.md +1245 -0
- package/dist/spec/v0.2.9/semantic-conventions.md +347 -0
- package/dist/spec/v0.2.9/types.ts +522 -0
- package/dist/types/policy.d.ts +377 -0
- package/dist/types/policy.d.ts.map +1 -0
- package/dist/types/policy.js +84 -0
- package/dist/types/policy.js.map +1 -0
- package/dist/utils/version.js +1 -1
- package/docs/specs/policy-dsl.md +925 -0
- package/examples/adk-integration/code-review-workflow.yml +1 -1
- package/examples/adk-integration/customer-support.yml +1 -1
- package/examples/adk-integration/data-pipeline.yml +1 -1
- package/examples/advanced/reasoning-agent.yaml +136 -0
- package/examples/advanced/workflows/hybrid-model-strategy.yaml +1 -1
- package/examples/agent-manifests/critics/critic-agent.yaml +1 -1
- package/examples/agent-manifests/governors/governor-agent.yaml +1 -1
- package/examples/agent-manifests/integrators/integrator-agent.yaml +1 -1
- package/examples/agent-manifests/judges/judge-agent.yaml +1 -1
- package/examples/agent-manifests/monitors/monitor-agent.yaml +1 -1
- package/examples/agent-manifests/orchestrators/orchestrator-agent.yaml +1 -1
- package/examples/agent-manifests/sample-compliant-agent.yaml +1 -1
- package/examples/agent-manifests/workers/worker-agent.yaml +1 -1
- package/examples/agents-md/code-agent.ossa.json +100 -0
- package/examples/agents-md/monorepo-agent.ossa.yaml +180 -0
- package/examples/anthropic/claude-assistant.ossa.json +1 -1
- package/examples/autogen/multi-agent.ossa.json +1 -1
- package/examples/claude-code/code-reviewer.ossa.yaml +1 -1
- package/examples/claude-code/ossa-validator.ossa.yaml +2 -2
- package/examples/common_npm/agent-router.ossa.yaml +1 -1
- package/examples/common_npm/agent-router.v0.2.2.ossa.yaml +1 -1
- package/examples/crewai/research-team.ossa.json +1 -1
- package/examples/cursor/code-review-agent.ossa.json +1 -1
- package/examples/drupal/gitlab-ml-recommender.ossa.yaml +1 -1
- package/examples/drupal/gitlab-ml-recommender.v0.2.2.ossa.yaml +1 -1
- package/examples/extensions/agents-md-v1.yml +175 -0
- package/examples/extensions/drupal-v1.yml +1 -1
- package/examples/extensions/kagent-v1.yml +1 -1
- package/examples/getting-started/hello-world-complete.ossa.yaml +1 -1
- package/examples/integration-patterns/agent-to-agent-orchestration.ossa.yaml +4 -4
- package/examples/kagent/compliance-validator.ossa.yaml +1 -1
- package/examples/kagent/cost-optimizer.ossa.yaml +1 -1
- package/examples/kagent/documentation-agent.ossa.yaml +1 -1
- package/examples/kagent/k8s-troubleshooter-v1.ossa.yaml +1 -1
- package/examples/kagent/k8s-troubleshooter-v1.v0.2.2.ossa.yaml +1 -1
- package/examples/kagent/k8s-troubleshooter.ossa.yaml +1 -1
- package/examples/kagent/security-scanner.ossa.yaml +1 -1
- package/examples/langchain/chain-agent.ossa.json +1 -1
- package/examples/langflow/workflow-agent.ossa.json +1 -1
- package/examples/langgraph/state-machine-agent.ossa.json +1 -1
- package/examples/llamaindex/rag-agent.ossa.json +1 -1
- package/examples/migration-guides/from-langchain-to-ossa.yaml +4 -4
- package/examples/multi-agent/conditional-router.ossa.yaml +1 -1
- package/examples/multi-agent/parallel-execution.ossa.yaml +1 -1
- package/examples/multi-agent/sequential-pipeline.ossa.yaml +1 -1
- package/examples/openai/basic-agent.ossa.yaml +1 -1
- package/examples/openai/multi-tool-agent.ossa.json +1 -1
- package/examples/openai/swarm-agent.ossa.json +1 -1
- package/examples/production/document-analyzer-openai.yml +1 -1
- package/examples/quickstart/support-agent.ossa.yaml +1 -1
- package/examples/templates/ossa-compliance.yaml +1 -1
- package/examples/vercel/edge-agent.ossa.json +1 -1
- package/llms.txt +1 -1
- package/package.json +5 -3
- package/scripts/README.md +25 -0
- package/scripts/compliance-audit.ts +796 -0
- package/scripts/generate-agents-catalog.ts +2 -1
- package/scripts/generate-api-docs.ts +2 -1
- package/scripts/generate-examples-docs.ts +2 -1
- package/scripts/generate-llms-ctx.sh +2 -2
- package/spec/v0.2.9/a2a-protocol.md +1337 -0
- package/spec/v0.2.9/agent.md +1946 -0
- package/spec/v0.2.9/capabilities/index.yaml +25 -0
- package/spec/v0.2.9/capabilities/memory.yaml +251 -0
- package/spec/v0.2.9/capability-schema.md +576 -0
- package/spec/v0.2.9/compliance-profiles.md +533 -0
- package/spec/v0.2.9/conformance-testing.md +1527 -0
- package/spec/v0.2.9/gitlab-duo-integration.md +621 -0
- package/spec/v0.2.9/ossa-0.2.9.schema.json +3699 -0
- package/spec/v0.2.9/runtime-semantics.md +464 -0
- package/spec/v0.2.9/security-model.md +1245 -0
- package/spec/v0.2.9/semantic-conventions.md +347 -0
- package/spec/v0.2.9/types.ts +522 -0
- package/test-results/junit.xml +184 -146
- package/.github/workflows/pr-comment.yml +0 -33
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
# OSSA Runtime Semantics Specification
|
|
2
|
+
|
|
3
|
+
**Version**: 0.2.9
|
|
4
|
+
**Status**: Draft
|
|
5
|
+
**Last Updated**: 2025-12-04
|
|
6
|
+
|
|
7
|
+
This document defines the formal runtime semantics for OSSA-compliant agent execution. All OSSA runtime implementations MUST conform to these semantics.
|
|
8
|
+
|
|
9
|
+
## 1. Turn Lifecycle
|
|
10
|
+
|
|
11
|
+
An OSSA agent turn consists of 7 sequential phases:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
15
|
+
│ TURN LIFECYCLE │
|
|
16
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
17
|
+
│ │
|
|
18
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
19
|
+
│ │ 1. INIT │──▶│ 2. NORM │──▶│ 3. RESOL │──▶│ 4. INFER │ │
|
|
20
|
+
│ │ │ │ │ │ │ │ │ │
|
|
21
|
+
│ │ Generate │ │ Normalize│ │ Resolve │ │ LLM Call │ │
|
|
22
|
+
│ │ IDs │ │ Message │ │ Tools │ │ │ │
|
|
23
|
+
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
|
|
24
|
+
│ │ │
|
|
25
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
|
|
26
|
+
│ │ 7. EMIT │◀──│ 6. PERSIST│◀──│ 5. EXEC │◀────────┘ │
|
|
27
|
+
│ │ │ │ │ │ │ │
|
|
28
|
+
│ │ Observe │ │ State │ │ Tools │ │
|
|
29
|
+
│ │ │ │ │ │ │ │
|
|
30
|
+
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
31
|
+
│ │
|
|
32
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Phase 1: Initialization (INIT)
|
|
36
|
+
|
|
37
|
+
**Purpose**: Generate runtime identifiers and establish context.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
interface InitPhase {
|
|
41
|
+
// MUST generate per spec.identity configuration
|
|
42
|
+
interaction_id: string; // New UUID per turn
|
|
43
|
+
session_id: string; // From context or new
|
|
44
|
+
instance_id: string; // Stable per pod/process
|
|
45
|
+
|
|
46
|
+
// MUST extract from context
|
|
47
|
+
trace_context: W3CTraceContext | null;
|
|
48
|
+
baggage: W3CBaggage | null;
|
|
49
|
+
|
|
50
|
+
// MUST record
|
|
51
|
+
turn_number: number;
|
|
52
|
+
started_at: ISO8601Timestamp;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Invariants**:
|
|
57
|
+
- `interaction_id` MUST be unique across all turns
|
|
58
|
+
- `session_id` MUST be consistent within a conversation
|
|
59
|
+
- `instance_id` MUST be stable for the agent instance lifetime
|
|
60
|
+
|
|
61
|
+
### Phase 2: Message Normalization (NORM)
|
|
62
|
+
|
|
63
|
+
**Purpose**: Transform input into canonical message format.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
interface NormalizedMessage {
|
|
67
|
+
role: 'user' | 'system' | 'assistant' | 'tool';
|
|
68
|
+
content: string | ContentPart[];
|
|
69
|
+
metadata: {
|
|
70
|
+
source: 'user' | 'api' | 'delegation';
|
|
71
|
+
original_format: string;
|
|
72
|
+
normalized_at: ISO8601Timestamp;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type ContentPart = TextPart | ImagePart | FilePart;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Rules**:
|
|
80
|
+
1. All inputs MUST be converted to `NormalizedMessage`
|
|
81
|
+
2. Content MUST be sanitized per `spec.safety.content_filtering`
|
|
82
|
+
3. Multi-modal content MUST be split into `ContentPart[]`
|
|
83
|
+
4. Original format MUST be preserved in metadata
|
|
84
|
+
|
|
85
|
+
### Phase 3: Tool Resolution (RESOL)
|
|
86
|
+
|
|
87
|
+
**Purpose**: Resolve available tools from manifest and MCP servers.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
interface ResolvedTool {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
input_schema: JSONSchema;
|
|
94
|
+
source: ToolSource;
|
|
95
|
+
transport: 'function' | 'http' | 'mcp' | 'grpc';
|
|
96
|
+
timeout_ms: number;
|
|
97
|
+
retry_policy: RetryPolicy;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type ToolSource =
|
|
101
|
+
| { type: 'manifest'; tool_index: number }
|
|
102
|
+
| { type: 'mcp'; server_uri: string; capability: string }
|
|
103
|
+
| { type: 'delegation'; agent_id: string };
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Rules**:
|
|
107
|
+
1. Tools MUST be resolved from `spec.tools[]` array
|
|
108
|
+
2. MCP tools MUST be discovered via `tools/list` call
|
|
109
|
+
3. Tool schemas MUST be validated against JSON Schema
|
|
110
|
+
4. Unavailable tools MUST be excluded with warning
|
|
111
|
+
|
|
112
|
+
### Phase 4: LLM Inference (INFER)
|
|
113
|
+
|
|
114
|
+
**Purpose**: Execute LLM call with resolved context.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
interface InferenceRequest {
|
|
118
|
+
model: string; // From spec.llm.model
|
|
119
|
+
messages: NormalizedMessage[]; // Conversation history
|
|
120
|
+
tools: ResolvedTool[]; // Available tools
|
|
121
|
+
system_prompt: string; // From spec.role or spec.prompts
|
|
122
|
+
parameters: LLMParameters; // From spec.llm.parameters
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface InferenceResponse {
|
|
126
|
+
content: string | null;
|
|
127
|
+
tool_calls: ToolCallRequest[];
|
|
128
|
+
finish_reason: 'stop' | 'length' | 'tool_use' | 'content_filter';
|
|
129
|
+
usage: TokenUsage;
|
|
130
|
+
model: string; // Actual model used
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Rules**:
|
|
135
|
+
1. System prompt MUST include `spec.role`
|
|
136
|
+
2. Few-shot examples from `spec.prompts.few_shot_examples` MUST be prepended
|
|
137
|
+
3. Token limits from `spec.constraints` MUST be enforced
|
|
138
|
+
4. Timeout from `spec.constraints.timeout_seconds` MUST be enforced
|
|
139
|
+
|
|
140
|
+
### Phase 5: Tool Execution (EXEC)
|
|
141
|
+
|
|
142
|
+
**Purpose**: Execute requested tool calls.
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
interface ToolExecution {
|
|
146
|
+
call_id: string;
|
|
147
|
+
tool_name: string;
|
|
148
|
+
input: unknown;
|
|
149
|
+
started_at: ISO8601Timestamp;
|
|
150
|
+
completed_at: ISO8601Timestamp;
|
|
151
|
+
result: ToolResult;
|
|
152
|
+
retries: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
type ToolResult =
|
|
156
|
+
| { status: 'success'; output: unknown }
|
|
157
|
+
| { status: 'error'; error: ToolError }
|
|
158
|
+
| { status: 'timeout'; partial_output?: unknown };
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Execution Order**:
|
|
162
|
+
1. Tool calls MAY execute in parallel if `spec.tools[].parallel: true`
|
|
163
|
+
2. By default, tools execute sequentially in request order
|
|
164
|
+
3. Failed tools MUST be retried per `spec.reliability.retry`
|
|
165
|
+
4. Circuit breaker MUST trip after threshold failures
|
|
166
|
+
|
|
167
|
+
**Rules**:
|
|
168
|
+
1. Each tool call MUST have unique `call_id`
|
|
169
|
+
2. Tool input MUST validate against tool's `input_schema`
|
|
170
|
+
3. Tool output MUST be serializable to JSON
|
|
171
|
+
4. Sensitive outputs MUST be redacted per `spec.security.output_filtering`
|
|
172
|
+
|
|
173
|
+
### Phase 6: State Persistence (PERSIST)
|
|
174
|
+
|
|
175
|
+
**Purpose**: Persist state changes atomically.
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
interface StatePersistence {
|
|
179
|
+
mode: 'none' | 'session' | 'persistent';
|
|
180
|
+
storage: StateStorage;
|
|
181
|
+
changes: StateChange[];
|
|
182
|
+
transaction_id: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface StateChange {
|
|
186
|
+
key: string;
|
|
187
|
+
previous_value: unknown | null;
|
|
188
|
+
new_value: unknown;
|
|
189
|
+
operation: 'set' | 'delete' | 'append';
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Transaction Semantics**:
|
|
194
|
+
1. All state changes within a turn MUST be atomic
|
|
195
|
+
2. On failure, all changes MUST be rolled back
|
|
196
|
+
3. State MUST be isolated per `spec.state.isolation_level`:
|
|
197
|
+
- `read_uncommitted`: No isolation
|
|
198
|
+
- `read_committed`: See only committed state
|
|
199
|
+
- `serializable`: Full isolation (default)
|
|
200
|
+
|
|
201
|
+
### Phase 7: Observability Emission (EMIT)
|
|
202
|
+
|
|
203
|
+
**Purpose**: Emit telemetry data.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
interface ObservabilityEmission {
|
|
207
|
+
// Tracing
|
|
208
|
+
span: OTelSpan;
|
|
209
|
+
|
|
210
|
+
// Metrics
|
|
211
|
+
metrics: {
|
|
212
|
+
tokens_input: number;
|
|
213
|
+
tokens_output: number;
|
|
214
|
+
latency_ms: number;
|
|
215
|
+
tool_calls: number;
|
|
216
|
+
errors: number;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// Logging
|
|
220
|
+
log_entries: LogEntry[];
|
|
221
|
+
|
|
222
|
+
// Activity Stream (if enabled)
|
|
223
|
+
event?: CloudEvent;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Rules**:
|
|
228
|
+
1. Span MUST include all attributes from semantic-conventions.md
|
|
229
|
+
2. Metrics MUST NOT include high-cardinality attributes
|
|
230
|
+
3. Logs MUST be correlated via `trace_id` and `span_id`
|
|
231
|
+
4. CloudEvents MUST conform to spec/v0.2.9/cloudevents.md
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 2. Error Handling
|
|
236
|
+
|
|
237
|
+
### Error Code Taxonomy
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
type ErrorCode =
|
|
241
|
+
// Input Errors (4xx equivalent)
|
|
242
|
+
| 'VALIDATION_ERROR' // Invalid input format
|
|
243
|
+
| 'SCHEMA_VIOLATION' // Input doesn't match schema
|
|
244
|
+
| 'CONTENT_FILTERED' // Content blocked by safety
|
|
245
|
+
| 'POLICY_VIOLATION' // Violates agent policy
|
|
246
|
+
|
|
247
|
+
// Execution Errors (5xx equivalent)
|
|
248
|
+
| 'TOOL_ERROR' // Tool execution failed
|
|
249
|
+
| 'TOOL_TIMEOUT' // Tool exceeded timeout
|
|
250
|
+
| 'LLM_ERROR' // LLM provider error
|
|
251
|
+
| 'LLM_TIMEOUT' // LLM exceeded timeout
|
|
252
|
+
| 'STATE_ERROR' // State persistence failed
|
|
253
|
+
|
|
254
|
+
// Resource Errors
|
|
255
|
+
| 'RATE_LIMITED' // Rate limit exceeded
|
|
256
|
+
| 'QUOTA_EXCEEDED' // Token/request quota exceeded
|
|
257
|
+
| 'CIRCUIT_OPEN' // Circuit breaker tripped
|
|
258
|
+
|
|
259
|
+
// Agent Errors
|
|
260
|
+
| 'MAX_TURNS_EXCEEDED' // Hit spec.constraints.max_turns
|
|
261
|
+
| 'MAX_TOKENS_EXCEEDED' // Hit spec.constraints.max_tokens
|
|
262
|
+
| 'DELEGATION_FAILED' // Child agent failed
|
|
263
|
+
| 'ESCALATION_REQUIRED'; // Needs human intervention
|
|
264
|
+
|
|
265
|
+
interface OSSAError {
|
|
266
|
+
code: ErrorCode;
|
|
267
|
+
message: string;
|
|
268
|
+
details?: Record<string, unknown>;
|
|
269
|
+
recoverable: boolean;
|
|
270
|
+
retry_after_ms?: number;
|
|
271
|
+
escalation?: EscalationAction;
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Recovery Strategies
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
type RecoveryStrategy =
|
|
279
|
+
| 'retry' // Retry with backoff
|
|
280
|
+
| 'fallback' // Use fallback value/tool
|
|
281
|
+
| 'skip' // Skip and continue
|
|
282
|
+
| 'escalate' // Escalate to human/supervisor
|
|
283
|
+
| 'abort'; // Abort turn/session
|
|
284
|
+
|
|
285
|
+
interface ErrorHandler {
|
|
286
|
+
error_codes: ErrorCode[];
|
|
287
|
+
strategy: RecoveryStrategy;
|
|
288
|
+
max_retries?: number;
|
|
289
|
+
fallback_value?: unknown;
|
|
290
|
+
escalation_target?: string;
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Default Error Handling
|
|
295
|
+
|
|
296
|
+
| Error Code | Default Strategy | Retries |
|
|
297
|
+
|------------|------------------|---------|
|
|
298
|
+
| `VALIDATION_ERROR` | abort | 0 |
|
|
299
|
+
| `TOOL_ERROR` | retry | 3 |
|
|
300
|
+
| `TOOL_TIMEOUT` | retry | 2 |
|
|
301
|
+
| `LLM_ERROR` | retry | 3 |
|
|
302
|
+
| `LLM_TIMEOUT` | retry | 2 |
|
|
303
|
+
| `RATE_LIMITED` | retry | 3 (with backoff) |
|
|
304
|
+
| `CIRCUIT_OPEN` | fallback | 0 |
|
|
305
|
+
| `MAX_TURNS_EXCEEDED` | escalate | 0 |
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## 3. State Semantics
|
|
310
|
+
|
|
311
|
+
### Isolation Levels
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
type IsolationLevel =
|
|
315
|
+
| 'read_uncommitted' // Can see uncommitted changes
|
|
316
|
+
| 'read_committed' // Only see committed changes
|
|
317
|
+
| 'repeatable_read' // Consistent reads within turn
|
|
318
|
+
| 'serializable'; // Full isolation (default)
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Transaction Boundaries
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
Turn Start ─────────────────────────────────────────── Turn End
|
|
325
|
+
│ │
|
|
326
|
+
│ ┌─────────────────────────────────────────────┐ │
|
|
327
|
+
│ │ TRANSACTION BOUNDARY │ │
|
|
328
|
+
│ │ │ │
|
|
329
|
+
│ │ state.get() ──▶ compute ──▶ state.set()│ │
|
|
330
|
+
│ │ │ │
|
|
331
|
+
│ │ ALL changes atomic │ │
|
|
332
|
+
│ │ ROLLBACK on any failure │ │
|
|
333
|
+
│ │ │ │
|
|
334
|
+
│ └─────────────────────────────────────────────┘ │
|
|
335
|
+
│ │
|
|
336
|
+
└──────────────────────────────────────────────────────┘
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### State Operations
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
interface StateOperations {
|
|
343
|
+
// Read operations
|
|
344
|
+
get<T>(key: string): Promise<T | null>;
|
|
345
|
+
getMany<T>(keys: string[]): Promise<Map<string, T>>;
|
|
346
|
+
exists(key: string): Promise<boolean>;
|
|
347
|
+
|
|
348
|
+
// Write operations (within transaction)
|
|
349
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
350
|
+
delete(key: string): Promise<void>;
|
|
351
|
+
append<T>(key: string, value: T): Promise<void>;
|
|
352
|
+
|
|
353
|
+
// Transaction control
|
|
354
|
+
checkpoint(): Promise<string>; // Save point
|
|
355
|
+
rollback(checkpoint?: string): Promise<void>;
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Rollback Behavior
|
|
360
|
+
|
|
361
|
+
1. **Automatic Rollback**: On unhandled error, all state changes roll back
|
|
362
|
+
2. **Partial Rollback**: Can rollback to named checkpoint
|
|
363
|
+
3. **No Rollback**: `isolation_level: read_uncommitted` disables rollback
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## 4. Multi-Turn Behavior
|
|
368
|
+
|
|
369
|
+
### Turn Chaining
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
interface TurnChain {
|
|
373
|
+
// Continue if LLM requests tool use
|
|
374
|
+
continue_on_tool_use: boolean; // default: true
|
|
375
|
+
|
|
376
|
+
// Max consecutive tool turns before response required
|
|
377
|
+
max_tool_turns: number; // default: 10
|
|
378
|
+
|
|
379
|
+
// Require user confirmation between turns
|
|
380
|
+
confirm_between_turns: boolean; // default: false
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Conversation Memory
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
interface ConversationMemory {
|
|
388
|
+
// How many messages to include in context
|
|
389
|
+
window_size: number; // default: 20
|
|
390
|
+
|
|
391
|
+
// Token budget for history
|
|
392
|
+
max_history_tokens: number; // default: 4000
|
|
393
|
+
|
|
394
|
+
// Summarization strategy when window exceeded
|
|
395
|
+
summarization: 'truncate' | 'summarize' | 'sliding';
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 5. Delegation Semantics
|
|
402
|
+
|
|
403
|
+
### Agent-to-Agent Handoff
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
interface Delegation {
|
|
407
|
+
type: 'handoff' | 'parallel' | 'supervisor';
|
|
408
|
+
target_agent: string;
|
|
409
|
+
input: unknown;
|
|
410
|
+
context_propagation: ContextPropagation;
|
|
411
|
+
timeout_ms: number;
|
|
412
|
+
on_failure: 'retry' | 'fallback' | 'escalate';
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
interface ContextPropagation {
|
|
416
|
+
// What to pass to child agent
|
|
417
|
+
include_session_id: boolean; // default: true
|
|
418
|
+
include_history: boolean; // default: false
|
|
419
|
+
include_state: boolean; // default: false
|
|
420
|
+
custom_context: Record<string, unknown>;
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Delegation Patterns
|
|
425
|
+
|
|
426
|
+
1. **Handoff**: Transfer control completely to target agent
|
|
427
|
+
2. **Parallel**: Execute multiple agents concurrently
|
|
428
|
+
3. **Supervisor**: Parent monitors child execution
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## 6. Compliance Requirements
|
|
433
|
+
|
|
434
|
+
### MUST Requirements
|
|
435
|
+
|
|
436
|
+
1. Runtime MUST generate unique `interaction_id` per turn
|
|
437
|
+
2. Runtime MUST enforce `spec.constraints.max_turns`
|
|
438
|
+
3. Runtime MUST enforce `spec.constraints.timeout_seconds`
|
|
439
|
+
4. Runtime MUST emit OpenTelemetry spans per semantic-conventions.md
|
|
440
|
+
5. Runtime MUST rollback state on unhandled errors
|
|
441
|
+
6. Runtime MUST validate tool inputs against schemas
|
|
442
|
+
|
|
443
|
+
### SHOULD Requirements
|
|
444
|
+
|
|
445
|
+
1. Runtime SHOULD support all isolation levels
|
|
446
|
+
2. Runtime SHOULD implement circuit breaker pattern
|
|
447
|
+
3. Runtime SHOULD support W3C trace context propagation
|
|
448
|
+
4. Runtime SHOULD emit CloudEvents for activity streams
|
|
449
|
+
|
|
450
|
+
### MAY Requirements
|
|
451
|
+
|
|
452
|
+
1. Runtime MAY implement custom error handlers
|
|
453
|
+
2. Runtime MAY support additional state backends
|
|
454
|
+
3. Runtime MAY implement conversation summarization
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## References
|
|
459
|
+
|
|
460
|
+
- [OSSA Schema v0.2.9](./ossa-0.2.9.schema.json)
|
|
461
|
+
- [Semantic Conventions](./semantic-conventions.md)
|
|
462
|
+
- [OpenTelemetry Specification](https://opentelemetry.io/docs/specs/)
|
|
463
|
+
- [CloudEvents Specification](https://cloudevents.io/)
|
|
464
|
+
- [W3C Trace Context](https://www.w3.org/TR/trace-context/)
|