Spaces:
Running
Running
File size: 16,661 Bytes
2851e2e 979fcbd 2851e2e 979fcbd 2851e2e 979fcbd 3624336 979fcbd 3624336 979fcbd 3624336 979fcbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | ---
title: WAIL — Execution Control & Governance
emoji: 🛡️
colorFrom: blue
colorTo: gray
sdk: static
pinned: true
short_description: AI, Agent & MCP Execution Control & Governance Layer
---
<p align="center">
<img src="https://raw.githubusercontent.com/wailinfra/wail-runtime/main/docs/images/wail-logo.png" alt="WAIL" width="650">
</p>
<p align="center">
<strong>Runtime Control for AI, Agent & MCP Execution</strong>
</p>
<p align="center">
<a href="https://wailinfra.com">Website</a> ·
<a href="https://pypi.org/project/wail-runtime/">PyPI</a> ·
<a href="docs/getting-started.md">Getting Started</a> ·
<a href="docs/architecture.md">Architecture</a> ·
<a href="docs/runtime-control.md">Runtime Control</a> ·
<a href="docs/evidence-model.md">Evidence Model</a> ·
<a href="docs/why-wail.md">Why WAIL</a> ·
<a href="docs/telemetry.md">Telemetry</a>
</p>
**WAIL is an on-prem execution control and governance layer for AI models, agents, and MCP tools.**
An AI request can return HTTP 200 yet still behave poorly: latency rises beyond its baseline, streaming stalls, or a tool call degrades. Detecting a problem is not the same as deciding what to do next — or proving what actually happened.
WAIL wraps your existing clients and MCP sessions to observe execution, assess runtime degradation, and make supported **observe, retry, or reroute** decisions. Standard provider rerouting can apply to a **subsequent execution**. Separately, **Continuous Governance Assurance & Enforcement (CGAE)** governs authority changes **during active execution**, including intervention in affected in-progress model, agent, and MCP operations.
WAIL links observations, authorization and policy changes, decisions, enforcement actions, and verified outcomes through cryptographically signed evidence and an authoritative ledger.
**No gateway. No replacement agent framework.** Your application retains orchestration and business logic. Governance and audit workflows are supported **where enabled**. CGAE is a core WAIL capability that provides continuous governance control and enforcement throughout the execution lifecycle.
**Free Developer tier. No signup or credit card required. Python 3.12.**
```bash
pip install wail-runtime
```
---
## Quick Start
Wrap your existing AI client with WAIL.
```python
from openai import OpenAI
import wail
client = wail.wrap(OpenAI())
```
Use it exactly as you normally would.
```python
response = client.responses.create(
model="gpt-4o-mini",
input="Explain what WAIL does."
)
print(response.output_text)
```
After each request, WAIL prints a runtime summary.
```text
WAIL AI Runtime Control Layer
────────────────────────────────────────
Plan Developer
Provider openai
Model gpt-4o-mini
Duration 2,220 ms
TTFT 1,981 ms
Throughput 3.97 tok/s
Mean Token Gap 4 ms
Active Signals 0
Runtime Severity NONE
Risk Score 0.00
Dominant Surface NONE
Decision OBSERVE
Trace SAVED · 01M1BQ593...
```
Every measured execution can also generate signed runtime evidence that includes:
- runtime observations
- execution assessment
- runtime decisions
- control actions
- execution outcome
- cryptographic integrity metadata
---
## Continuous Governance Assurance & Enforcement (CGAE)
**CGAE is a core WAIL capability, not a separate product, gateway, or execution authority.** It maintains governance control throughout the lifecycle of model, agent, and MCP execution — including changes that occur **after an execution has started**.
CGAE enforcement includes:
- Evaluating authorization, policy, and execution-authority changes during an active run, not only at initial dispatch.
- Intervening in affected in-progress model calls, agent operations, and MCP tool executions when authority changes require it.
- Blocking subsequent dispatches that are no longer authorized, including across provider and Agent/MCP execution chains.
- Distinguishing an actual, verified cancellation of remote work from merely stopping local observation or waiting.
- Linking authorization, changes, decisions, enforcement attempts, actual outcomes, and responsible authority through signed chronological evidence and the authoritative ledger.
**Runtime recovery and governance enforcement are distinct:** subsequent-execution provider rerouting does not limit CGAE intervention in an already-active execution. Evidence distinguishes an attempted intervention, a local stop, and independently verified remote cancellation.
---
## Architecture

WAIL operates around the execution path rather than replacing it.
For direct model execution, WAIL observes and controls provider requests.
For agent and MCP execution, WAIL can represent the active workload as an **Agent Run** containing connected agent, model, and MCP tool execution units.
Delegation, call, and join relationships preserve how execution moved through the run.
---
## What WAIL Does
- **Detect Runtime Issues** — Observe AI execution and identify abnormal latency, streaming behavior, errors, timeouts, tool failures, and other runtime degradation.
- **Assess Execution Health** — Determine how serious a runtime issue is and whether it justifies intervention.
- **Evaluate Alternatives** — Compare observed models, providers, or configured recovery paths when another execution path may be needed.
- **Control Runtime Execution** — Retry or reroute when runtime conditions and policy justify intervention; otherwise preserve the application's current execution path.
- **Track Agent Execution** — Represent agent, model, and MCP tool activity as connected execution units within an Agent Run.
- **Track Execution Relationships** — Preserve delegation, call, and join relationships across multi-agent execution.
- **Apply MCP Runtime Recovery** — Observe MCP tool execution and apply configured retry or reroute behavior when runtime control requires it.
- **Verify Recovery** — Preserve the relationship between the execution that produced a recovery decision and the execution where recovery was applied, including the resulting recovery state.
- **Record What Happened** — Produce signed, verifiable runtime and Agent Run evidence for observations, decisions, actions, execution relationships, and outcomes.
- **Support Governance** — Preserve structured incident and execution records for governance, audit, and compliance workflows where enabled.
### Runtime Control Loop
```text
Runtime measurements
↓
Baseline + anomaly detection
↓
Risk / severity evaluation
↓
Candidate scoring
↓
Runtime decision
↓
Intervention when required
↓
Recovery application / verification
↓
Signed execution evidence
```
WAIL does not route requests simply because another model, provider, or execution target scores better.
Candidate evaluation informs runtime control; intervention remains driven by observed runtime conditions and control policy.
---
## Agent & MCP Execution
WAIL extends its execution model across existing agent orchestration and MCP sessions without becoming the orchestrator itself.
A WAIL Agent Run can preserve:
- agent execution units
- model execution units
- MCP tool execution units
- delegation relationships
- model/tool call relationships
- fan-in and join relationships
- underlying execution trace IDs
- run status
- run-level runtime intelligence where applicable
- runtime recovery and recovery-verification evidence where applicable
- cryptographic integrity metadata
A simplified execution graph can look like this:
```text
Coordinator Agent
│
├── delegates ──> Research Agent
│ │
│ ├── calls ──> Model
│ │
│ └── calls ──> MCP Tool
│
├── delegates ──> Verification Agent
│ │
│ ├── calls ──> Model
│ │
│ └── calls ──> MCP Tool
│
└──────────── joins ────────────┐
▼
Synthesis Agent
```
The application remains responsible for orchestration and business logic.
WAIL records and evaluates the runtime execution around it.
### Agent & MCP Runtime Output
WAIL preserves runtime visibility at both the **individual execution level** and the **Agent Run level**.
An MCP tool execution is observed as its own runtime execution:
```text
WAIL AI Runtime Control Layer · 20:37:41
────────────────────────────────────────
Plan Pro
Execution Type MCP Tool
Agent runtime_worker_agent
Tool wail_probe
Duration 106 ms
TTFT --
Throughput --
Mean Token Gap --
Active Signals 0
Runtime Severity NONE
Risk Score 0.00
Dominant Surface NONE
Decision OBSERVE
Trace SAVED · 01M46J933...
```
The complete multi-agent execution is also represented as an Agent Run:
```text
WAIL AI Runtime Control Layer · 20:37:42
────────────────────────────────────────
Plan Developer
Execution Type Agent Run
Run run_222738885...
Agent Units 2
Model Units 1
MCP Tool Units 1
Relations 3
Status COMPLETED
Signed Evidence SAVED
```
This gives WAIL two connected levels of evidence:
```text
Individual Execution
│
├── Model Trace
└── MCP Tool Trace
│
▼
Agent Run
│
├── Agent Units
├── Model Units
├── MCP Tool Units
├── Relations
└── Signed Evidence
```
Individual model and MCP tool executions remain independently traceable, while the Agent Run preserves how those executions were connected as a single execution graph.
---
## MCP Integration
WAIL wraps an existing MCP client session rather than replacing the MCP transport or server.
```python
from wail.mcp.adapter import wrap_mcp
mcp_client = wrap_mcp(
session,
transport="stdio",
service="mcp",
env="production",
)
```
Here, `session` is an already initialized MCP `ClientSession`.
Tool calls continue through the wrapped MCP client:
```python
result = await mcp_client.call_tool(
"inspect_repository",
arguments={"path": "."},
)
```
When the call occurs inside an active WAIL execution context, WAIL can preserve the MCP operation as a tool execution unit and associate its trace with the active Agent Run.
### MCP Recovery Routes
A backup MCP tool can be configured as an alternate runtime path:
```python
mcp_client = wrap_mcp(
session,
transport="stdio",
routes={
"primary_tool": "backup_tool",
},
service="mcp",
env="production",
)
```
When runtime conditions naturally produce a supported recovery decision, WAIL can apply the recovery on the subsequent execution and preserve evidence linking the source execution to the applied recovery.
---
## Agent Run
WAIL creates an execution boundary around existing agent orchestration:
```python
import wail
with wail.execution_run(
attributes={
"orchestration": "coordinator_worker",
}
) as run:
run_id = run.run_id
```
Agent Runs do not replace the application's orchestration model.
They provide an execution boundary for connecting agent, model, and MCP tool activity into a common runtime graph and evidence record.
Within a run, WAIL can preserve relationships including:
```text
Coordinator
│
└── delegates ──> Worker
│
├── calls ──> Model
│
└── calls ──> MCP Tool
```
More complex executions can also preserve fan-out and fan-in relationships:
```text
Coordinator
│
├── delegates ──> Agent A ──┐
├── delegates ──> Agent B ──┼── joins ──> Synthesis Agent
└── delegates ──> Agent C ──┘
```
Model and MCP tool executions associated with these agent units retain their individual runtime traces while also becoming part of the Agent Run graph.
For complete working examples, see:
- [multi_agent_mcp_evidence.py](https://github.com/wailinfra/wail-runtime/blob/main/examples/multi_agent_mcp_evidence.py)
- [multi_agent_runtime_recovery_evidence.py](https://github.com/wailinfra/wail-runtime/blob/main/examples/multi_agent_runtime_recovery_evidence.py)
---
## Runtime Recovery
WAIL distinguishes between a **recovery decision**, its later **application**, and verification of the resulting execution.
For supported runtime recovery paths:
```text
Execution N
│
▼
Runtime degradation / failure
│
▼
WAIL runtime decision
RETRY or REROUTE
│
▼
Execution N+1
│
▼
Recovery application
│
▼
Recovery verification
│
▼
Signed evidence
```
A recovery decision is therefore not treated as proof that recovery actually happened.
WAIL can preserve:
- the source run
- the source execution trace
- the selected recovery action
- the execution where recovery was applied
- the applied execution trace
- whether the recovery action was actually executed
- the resulting recovery state
This allows the evidence chain to distinguish:
```text
Decision produced
≠
Recovery applied
≠
Recovery verified
```
---
## Signed Agent Evidence
Completed Agent Runs can produce signed Agent Run evidence that preserves the connected execution rather than reducing the run to unrelated request logs.
Depending on execution state and available capabilities, Agent Run evidence can include:
- run identity and status
- agent execution units
- model execution units
- MCP tool execution units
- execution relationships
- underlying model and tool trace IDs
- run-level execution intelligence
- runtime recovery state
- recovery application and verification state
- evidence hash
- public-key fingerprint
- RSA-PSS-SHA256 signature
This evidence complements WAIL's per-execution runtime artifacts.
Individual model and tool executions remain traceable while the Agent Run preserves how those executions were related.
---
---
## Supported Providers
| Provider | Runtime Detection | Runtime Control | Runtime Evidence |
|----------|:-----------------:|:---------------:|:----------------:|
| OpenAI | ✅ | ✅ | ✅ |
| Anthropic | ✅ | ✅ | ✅ |
| Google Gemini | ✅ | ✅ | ✅ |
| OpenRouter | ✅ | ✅ | ✅ |
| Ollama | ✅ | ✅ | ✅ |
| OpenAI-compatible Local LLMs | ✅ | ✅ | ✅ |
The runtime evidence model remains consistent across all supported providers.
Agent and MCP execution support operates around these runtime integrations; MCP itself is an execution interface rather than an AI model provider.
---
## CLI
Inspect and verify runtime artifacts directly from the command line.
```bash
wail traces incidents
wail trace show <TRACE_ID>
wail verify <ARTIFACT_FILE>
```
---
## Documentation
Learn more about WAIL:
- [Getting Started](https://github.com/wailinfra/wail-runtime/blob/main/docs/getting-started.md)
- [Why WAIL](https://github.com/wailinfra/wail-runtime/blob/main/docs/why-wail.md)
- [Architecture](https://github.com/wailinfra/wail-runtime/blob/main/docs/architecture.md)
- [Runtime Control](https://github.com/wailinfra/wail-runtime/blob/main/docs/runtime-control.md)
- [Runtime Evidence Model](https://github.com/wailinfra/wail-runtime/blob/main/docs/evidence-model.md)
- [Provider Integration](https://github.com/wailinfra/wail-runtime/blob/main/docs/provider-integration.md)
- [Runtime Artifact Reference](https://github.com/wailinfra/wail-runtime/blob/main/docs/artifact-reference.md)
- [CLI Reference](https://github.com/wailinfra/wail-runtime/blob/main/docs/CLI.md)
- [Telemetry](https://github.com/wailinfra/wail-runtime/blob/main/docs/telemetry.md) |