# Agents, execution and context

Build agent behavior from explicit tools, bounded execution, qualified models and provenance-aware context.

Source snapshot: bcc79fcc27c4d801c2119bef81ddcce7b4e86498

## Select protocol and execution responsibilities

AgentProtocol owns shared wire models and deterministic validation; AI Agent supplies runtime orchestration, task trees, tools, sessions and approvals. Existing lifecycle declarations and registry helpers are explicit surfaces. A host supplies the actual model route, storage, tool execution and authority. This distinction is useful when embedding an agent in an existing application: first identify the operation it may perform and the environment it may use, then select the runtime pieces needed to carry that behavior.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/context-storage/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/src/context/compiler.ts

## Compile context with provenance

The context compiler accepts classified sources, tracks digests and provenance, enforces budgets and required inputs, and separates evidence from instruction authority. Protocol V1 runs require the qualified model route and verified compiled context described by the source. Treat retrieved documents as data with known scope and freshness. ContextStorage adds pack and snapshot storage primitives; it does not automatically make every stored document appropriate for every run. Preserve the snapshot and source identity when a run is resumed or reviewed.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/context-storage/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/src/context/compiler.ts

## Bound the run and its delegated tools

The runner/task-tree surfaces preserve cancellation and failure propagation. The runtime also supports bounded epochs and explicit delegation constraints over selected history, tool subsets, budgets, timeouts and evidence. Approvals remain independent of an agent’s own plan. A practical integration should show which context was supplied, which tool was requested, why it was permitted, and what result or uncertainty returned. Keep model output, proposed action, authorized invocation and durable outcome as separate observations.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/context-storage/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/src/context/compiler.ts

## Start with one declared tool

Choose one existing operation and expose it through the intended registry or MCP boundary. Inspect its input, outcomes, scope and approval requirements before giving the agent a wider tool collection.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/context-storage/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/src/context/compiler.ts

## Trace the context packet

Follow a source through retrieval/classification, compilation, snapshot storage and run admission. Check what happens when a required source is absent, expired, over budget or bound to the wrong scope.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/context-storage/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/src/context/compiler.ts

## Inspect interruption and uncertainty

Use the owning fixture to examine cancellation, tool failure and a help/escalation request. Record the model/provider and execution environment in evidence; source support for a runtime adapter is not evidence of a successful run on it.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/context-storage/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/agents/ai-agent/src/context/compiler.ts

## Packages

- [@lssm-tech/lib.agent-collaboration](https://lssm.co/docs/packages/lib.agent-collaboration/): Tenant-safe multiplayer agent session collaboration primitives with deterministic replay.
- [@lssm-tech/module.agent-fleet](https://lssm.co/docs/packages/module.agent-fleet/): Agent fleet management module — fleet, tree, detail, tool registry, and run console surfaces.
- [@lssm-tech/lib.agent-protocol-spec](https://lssm.co/docs/packages/lib.agent-protocol-spec/): Provider-neutral durable agent help, uncertainty and common protocol definitions with exact legacy compatibility.
- [@lssm-tech/lib.ai-agent](https://lssm.co/docs/packages/lib.ai-agent/): AI agent orchestration with MCP and tool support
- [@lssm-tech/module.ai-chat](https://lssm.co/docs/packages/module.ai-chat/): AI chat interface module
- [@lssm-tech/module.context-storage](https://lssm.co/docs/packages/module.context-storage/): Context storage module with persistence adapters
- [@lssm-tech/lib.context-storage](https://lssm.co/docs/packages/lib.context-storage/): Context pack and snapshot storage primitives
- [@lssm-tech/module.execution-console](https://lssm.co/docs/packages/module.execution-console/): Operator-facing execution lane console module.
- [@lssm-tech/lib.execution-lanes](https://lssm.co/docs/packages/lib.execution-lanes/): Execution lanes orchestration contracts and runtime for ContractSpec.
- [@lssm-tech/lib.harness](https://lssm.co/docs/packages/lib.harness/): Harness orchestration, policy, evidence, and evaluation runtime.
- [@lssm-tech/lib.mobile-control](https://lssm.co/docs/packages/lib.mobile-control/): Builder mobile-control primitives for review cards, parity, and deep-link-safe actions.
- [@lssm-tech/lib.runtime-sandbox](https://lssm.co/docs/packages/lib.runtime-sandbox/): Sandboxed runtime primitives for executing governed ContractSpec workloads.
- [@lssm-tech/lib.voice](https://lssm.co/docs/packages/lib.voice/): Voice capabilities: TTS, STT, and conversational AI
- [@lssm-tech/integration.agent-durable-store](https://lssm.co/docs/packages/integration.agent-durable-store/): Durable SQLite and Postgres session and checkpoint stores for @lssm-tech/lib.ai-agent
- [@lssm-tech/integration.agent-sandbox](https://lssm.co/docs/packages/integration.agent-sandbox/): Deny-by-default Docker and development sandbox adapters for @lssm-tech/lib.ai-agent
- [@lssm-tech/integration.harness-runtime](https://lssm.co/docs/packages/integration.harness-runtime/): Runtime adapters for the ContractSpec harness system.
- [@lssm-tech/app.agent-host](https://lssm.co/docs/packages/app.agent-host/): Inspect the package guide, declared imports and source relationships.
