Skip to main content

Overview

Shannon’s tool execution system provides a secure, extensible framework for integrating external capabilities into AI agents. The architecture supports three tool types with unified execution semantics.

Tool Types

MCP Tools

External HTTP APIs following Model Context Protocol

OpenAPI Tools

Auto-generated from OpenAPI 3.x specifications

Built-in Tools

Python tools with direct service access
All tool types share:
  • Unified JSON schema for parameters
  • Consistent error handling
  • Rate limiting and circuit breakers
  • Cost tracking and budget enforcement
  • Security validation

Architecture Layers

Tool Execution Architecture

Tool Registry

Registration

Tools are registered at service startup with metadata:

Discovery

Tools are exposed via HTTP API for runtime discovery:

WASI Sandboxing

Python code execution happens in WebAssembly System Interface (WASI) sandboxes for security isolation.

Architecture

WASI Sandbox Security

Security Boundaries

WASI sandboxes have no network stack:
  • ✅ Can compute, parse, transform data
  • ❌ Cannot make HTTP requests
  • ❌ Cannot open sockets
  • ❌ Cannot access external resources
Use case: Safe execution of user-provided Python code
Filesystem is mounted read-only:
  • ✅ Can read Python standard library
  • ✅ Can read allowed data files
  • ❌ Cannot write files
  • ❌ Cannot modify system files
Use case: Prevent data exfiltration and tampering
Memory usage is capped per execution:
Use case: Prevent resource exhaustion attacks
Each execution has strict time limits:
Use case: Prevent infinite loops and hanging processes

Setup

OpenAPI Tool Loader

Shannon dynamically generates tools from OpenAPI specifications.

Spec Processing

1

Fetch Spec

Retrieve OpenAPI spec from URL or inline YAML:
2

Validate & Parse

Validate OpenAPI version and structure:
3

Generate Tools

Create tool for each operation:
4

Apply Vendor Adapter

If configured, load vendor-specific transformations:

Schema Resolution

Remote $ref resolution (e.g., https://example.com/schemas/Pet.json) is not supported. Merge external schemas into a single spec file.

Vendor Adapter Integration

Vendor adapters transform requests/responses for domain-specific APIs without modifying Shannon’s core.

Execution Flow

Vendor Adapter Sequence

Adapter Loading

Transformation Examples

Field Aliasing:
Session Context Injection:
Time Range Normalization:

Rate Limiting

Per-Tool Rate Limits

Implemented with token bucket algorithm:

Global Rate Limits

Circuit Breakers

Prevent cascading failures when external services are unavailable.

Configuration

States

Circuit Breaker States Closed: Normal operation, all requests allowed Open: Service unavailable, all requests fail fast Half-Open: Testing recovery, limited requests allowed

Cost Tracking

Each tool execution tracks cost for budget enforcement.

Per-Tool Costs

Budget Enforcement

Configuration

Error Handling

Error Categories

Retry Logic

Performance Optimizations

Connection Pooling

Response Caching

Parallel Execution

Configuration:

Security Considerations

Always validate tool inputs and restrict execution based on user permissions.

Domain Allowlisting

Tool Permissions

OPA policies can gate access:

API Key Management

Monitoring & Observability

Metrics

Logging

Tracing

Next Steps

Adding Custom Tools

Learn how to add MCP, OpenAPI, and built-in tools

Vendor Adapters

Build domain-specific integrations

Configuration

Complete configuration reference

Security Best Practices

Harden your Shannon deployment