veris-ai 0.2.1__tar.gz → 1.1.0__tar.gz

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.

Potentially problematic release.


This version of veris-ai might be problematic. Click here for more details.

Files changed (34) hide show
  1. {veris_ai-0.2.1 → veris_ai-1.1.0}/.github/workflows/release.yml +1 -1
  2. {veris_ai-0.2.1 → veris_ai-1.1.0}/.github/workflows/test.yml +3 -4
  3. {veris_ai-0.2.1 → veris_ai-1.1.0}/.gitignore +3 -1
  4. {veris_ai-0.2.1 → veris_ai-1.1.0}/CHANGELOG.md +18 -0
  5. veris_ai-1.1.0/CLAUDE.md +185 -0
  6. veris_ai-1.1.0/PKG-INFO +448 -0
  7. veris_ai-1.1.0/README.md +412 -0
  8. veris_ai-1.1.0/examples/__init__.py +1 -0
  9. veris_ai-1.1.0/examples/import_options.py +77 -0
  10. {veris_ai-0.2.1 → veris_ai-1.1.0}/pyproject.toml +33 -8
  11. veris_ai-1.1.0/src/veris_ai/__init__.py +41 -0
  12. veris_ai-1.1.0/src/veris_ai/braintrust_tracing.py +282 -0
  13. veris_ai-1.1.0/src/veris_ai/jaeger_interface/README.md +109 -0
  14. veris_ai-1.1.0/src/veris_ai/jaeger_interface/__init__.py +26 -0
  15. veris_ai-1.1.0/src/veris_ai/jaeger_interface/client.py +133 -0
  16. veris_ai-1.1.0/src/veris_ai/jaeger_interface/models.py +153 -0
  17. veris_ai-1.1.0/src/veris_ai/tool_mock.py +199 -0
  18. veris_ai-1.1.0/src/veris_ai/utils.py +270 -0
  19. {veris_ai-0.2.1 → veris_ai-1.1.0}/tests/conftest.py +3 -0
  20. veris_ai-1.1.0/tests/fixtures/__init__.py +1 -0
  21. veris_ai-1.1.0/tests/fixtures/simple_app.py +66 -0
  22. veris_ai-1.1.0/tests/fixtures/sse_server.py +113 -0
  23. veris_ai-1.1.0/tests/test_mcp_protocol_server_mocked.py +214 -0
  24. veris_ai-1.1.0/tests/test_tool_mock.py +529 -0
  25. veris_ai-1.1.0/tests/test_utils.py +415 -0
  26. veris_ai-1.1.0/uv.lock +1609 -0
  27. veris_ai-0.2.1/PKG-INFO +0 -137
  28. veris_ai-0.2.1/README.md +0 -116
  29. veris_ai-0.2.1/src/veris_ai/__init__.py +0 -7
  30. veris_ai-0.2.1/src/veris_ai/tool_mock.py +0 -140
  31. veris_ai-0.2.1/tests/test_tool_mock.py +0 -223
  32. veris_ai-0.2.1/uv.lock +0 -524
  33. {veris_ai-0.2.1 → veris_ai-1.1.0}/LICENSE +0 -0
  34. {veris_ai-0.2.1 → veris_ai-1.1.0}/tests/__init__.py +0 -0
@@ -21,7 +21,7 @@ jobs:
21
21
  - name: Install dependencies
22
22
  run: |
23
23
  curl -LsSf https://astral.sh/uv/install.sh | sh
24
- uv sync
24
+ uv sync --all-extras
25
25
  uv pip install python-semantic-release
26
26
 
27
27
  - name: Configure Git
@@ -2,9 +2,9 @@ name: Tests
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [ main ]
6
6
  pull_request:
7
- branches: [ master ]
7
+ branches: [ main ]
8
8
 
9
9
  jobs:
10
10
  test:
@@ -27,8 +27,7 @@ jobs:
27
27
 
28
28
  - name: Install dependencies
29
29
  run: |
30
- uv venv
31
- uv pip install -e .[dev]
30
+ uv sync --all-extras
32
31
 
33
32
  - name: Run code quality checks with Ruff
34
33
  run: |
@@ -127,4 +127,6 @@ cython_debug/
127
127
  .DS_Store
128
128
 
129
129
  # Windows
130
- Thumbs.db
130
+ Thumbs.db
131
+
132
+ .scratch/
@@ -1,5 +1,23 @@
1
1
  # CHANGELOG
2
2
 
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Session ID tracking in OTEL traces: The `veris.session_id` attribute is now automatically added to all spans when a session ID is present
12
+ - Session IDs from FastAPI MCP bearer tokens are automatically embedded in traces
13
+ - Manual session management via `veris.set_session_id()` and `veris.clear_session_id()`
14
+ - Enables filtering and correlation of traces by user session in Jaeger
15
+ - New test suite for session ID tracing functionality
16
+
17
+ ### Changed
18
+ - `AgentsOTELBridgeProcessor` now imports and uses `_session_id_context` from `tool_mock`
19
+ - Trace and span creation now includes session ID attributes when available
20
+
3
21
 
4
22
  ## v0.2.1 (2025-04-18)
5
23
 
@@ -0,0 +1,185 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is the Veris AI Python SDK - a package that provides simulation capabilities through decorator-based function mocking and FastAPI MCP (Model Context Protocol) integration. The core functionality revolves around:
8
+ - `VerisSDK` class in `src/veris_ai/tool_mock.py:27` - enables environment-aware execution where functions can be mocked in simulation mode or executed normally in production
9
+ - `convert_to_type()` function in `src/veris_ai/utils.py:5` - handles sophisticated type conversion from mock responses
10
+ - `FastApiMCPParams` model in `src/veris_ai/models.py:1` - provides configuration for integrating FastAPI applications with the Model Context Protocol
11
+ - `set_fastapi_mcp()` method in `src/veris_ai/tool_mock.py:54` - configures FastAPI MCP server with automatic OAuth2-based session management
12
+
13
+ ## Development Commands
14
+
15
+ This project uses `uv` as the package manager and follows modern Python tooling practices.
16
+
17
+ ### Setup
18
+ ```bash
19
+ # Install with development dependencies
20
+ uv add "veris-ai[dev]"
21
+
22
+ # Install with FastAPI MCP integration
23
+ uv add "veris-ai[fastapi]"
24
+
25
+ # Set Python version (requires 3.11+)
26
+ pyenv local 3.11.0
27
+ ```
28
+
29
+ ### Code Quality (Primary: Ruff)
30
+ ```bash
31
+ # Lint code
32
+ ruff check .
33
+
34
+ # Auto-fix linting issues
35
+ ruff check --fix .
36
+
37
+ # Format code
38
+ ruff format .
39
+
40
+ # Check formatting only
41
+ ruff format --check .
42
+ ```
43
+
44
+ ### Type Checking
45
+ ```bash
46
+ # Run static type checking
47
+ mypy src/veris_ai tests
48
+ ```
49
+
50
+ ### Testing
51
+ ```bash
52
+ # Run all tests with coverage
53
+ pytest tests/ --cov=veris_ai --cov-report=xml --cov-report=term-missing
54
+
55
+ # Run specific test file
56
+ pytest tests/test_tool_mock.py
57
+
58
+ # Run tests with verbose output
59
+ pytest -v tests/
60
+ ```
61
+
62
+ ### Building
63
+ ```bash
64
+ # Build package distributions
65
+ uv build
66
+ ```
67
+
68
+ ## Code Architecture
69
+
70
+ ### Core Components
71
+
72
+ **VerisSDK Class** (`src/veris_ai/tool_mock.py:27`)
73
+ - Main SDK class that provides decorator functionality:
74
+ - `@veris.mock()`: Dynamic mocking that calls external endpoints for responses
75
+ - `@veris.stub()`: Simple stubbing with fixed return values
76
+ - Environment detection: Uses `ENV` environment variable to determine simulation vs production mode
77
+ - HTTP communication with mock endpoints via `httpx` (for mock decorator)
78
+ - Context extraction for session management via context variables
79
+ - Delegates type conversion to the utils module
80
+
81
+ **API Surface** (`src/veris_ai/__init__.py:5`)
82
+ - Exports single `veris` instance for public use
83
+ - Clean, minimal API design
84
+
85
+ **Type Conversion Utilities** (`src/veris_ai/utils.py:1`)
86
+ - `convert_to_type()` function handles sophisticated type conversion from mock responses
87
+ - Supports primitives, lists, dictionaries, unions, and custom types
88
+ - Modular design with separate conversion functions for each type category
89
+ - Uses Python's typing system for runtime type checking
90
+
91
+ **FastAPI MCP Integration** (`src/veris_ai/models.py:1`)
92
+ - `FastApiMCPParams` Pydantic model for configuring FastAPI MCP server integration
93
+ - Comprehensive configuration options including:
94
+ - Custom server naming and descriptions
95
+ - HTTP client configuration (base URL, headers, timeout)
96
+ - Operation filtering (include/exclude by operation ID or tag)
97
+ - Response schema documentation controls
98
+ - Authentication configuration
99
+
100
+ ### Environment Configuration
101
+
102
+ Required environment variables:
103
+ - `VERIS_MOCK_ENDPOINT_URL`: Mock endpoint URL (required)
104
+ - `VERIS_MOCK_TIMEOUT`: Request timeout in seconds (optional, default: 30.0)
105
+ - `ENV`: Set to "simulation" to enable mocking, anything else runs original functions
106
+
107
+ ### Type System
108
+
109
+ The SDK handles sophisticated type conversion from mock responses:
110
+ - Type conversion is handled by the `convert_to_type()` function in `src/veris_ai/utils.py`
111
+ - Supports primitives, lists, dictionaries, unions, and custom types
112
+ - Modular design with separate handlers for different type categories
113
+ - Uses Python's typing system for runtime type checking
114
+
115
+ ## Testing Strategy
116
+
117
+ **Test Structure**:
118
+ - `tests/conftest.py:1`: Pytest fixtures for environment mocking and context objects
119
+ - `tests/test_tool_mock.py:1`: Unit tests for the VerisSDK class and mock decorator functionality
120
+ - `tests/test_utils.py:1`: Comprehensive tests for type conversion utilities
121
+
122
+ **Key Test Fixtures**:
123
+ - `mock_context`: Provides mock context with session ID
124
+ - `simulation_env`: Sets up simulation environment variables
125
+ - `production_env`: Sets up production environment variables
126
+
127
+ **Test Coverage Areas**:
128
+ - Environment-based behavior switching
129
+ - HTTP client interactions and error handling
130
+ - Type conversion scenarios (parametrized tests)
131
+ - Configuration validation
132
+
133
+ ## Code Quality Standards
134
+
135
+ **Ruff Configuration** (80+ rules enabled):
136
+ - Line length: 100 characters
137
+ - Target: Python 3.11+
138
+ - Google-style docstring convention
139
+ - Comprehensive rule set covering style, bugs, security, and complexity
140
+ - Relaxed rules for test files (allows more flexibility in tests)
141
+
142
+ **Development Tools**:
143
+ - **Ruff**: Primary linter and formatter (replaces flake8, black, isort)
144
+ - **MyPy**: Static type checking
145
+ - **Pytest**: Testing with async support and coverage
146
+ - **Pre-commit**: Git hooks for code quality
147
+
148
+ ## CI/CD Pipeline
149
+
150
+ **Testing Workflow** (`.github/workflows/test.yml`):
151
+ - Runs on Python 3.11, 3.12, 3.13
152
+ - Code quality checks (Ruff lint/format)
153
+ - Type checking (MyPy)
154
+ - Unit tests with coverage
155
+
156
+ **Release Workflow** (`.github/workflows/release.yml`):
157
+ - Manual trigger for releases
158
+ - Semantic versioning with conventional commits
159
+ - Automated PyPI publishing
160
+ - Uses `uv build` for package building
161
+
162
+ ## Key Implementation Details
163
+
164
+ - **Decorator Pattern**: Functions are wrapped to intercept calls in simulation mode
165
+ - `mock()`: Sends function metadata to external endpoint for dynamic responses
166
+ - `stub()`: Returns predetermined values without external calls
167
+ - **Session Management**: Extracts session ID from context for request correlation
168
+ - **Error Handling**: Comprehensive HTTP and type conversion error handling
169
+ - **Async Support**: Built with async/await pattern throughout
170
+ - **Type Safety**: Full type hints and runtime type conversion validation
171
+ - **Modular Architecture**: Type conversion logic separated into utils module for better maintainability
172
+
173
+ ### FastAPI MCP Integration
174
+
175
+ The `set_fastapi_mcp()` method provides:
176
+ - **Automatic Session Handling**: OAuth2-based session ID extraction from bearer tokens
177
+ - **Context Management**: Session IDs are stored in context variables for cross-request correlation
178
+ - **Auth Config Merging**: User-provided auth configs are merged with internal session handling
179
+ - **MCP Server Access**: Configured server available via `veris.fastapi_mcp` property
180
+
181
+ Key implementation aspects:
182
+ - Creates internal OAuth2PasswordBearer scheme for token extraction
183
+ - Dependency injection for automatic session context setting
184
+ - Preserves user auth configurations while adding session management
185
+ - SSE (Server-Sent Events) support for streaming responses
@@ -0,0 +1,448 @@
1
+ Metadata-Version: 2.4
2
+ Name: veris-ai
3
+ Version: 1.1.0
4
+ Summary: A Python package for Veris AI tools
5
+ Project-URL: Homepage, https://github.com/veris-ai/veris-python-sdk
6
+ Project-URL: Bug Tracker, https://github.com/veris-ai/veris-python-sdk/issues
7
+ Author-email: Mehdi Jamei <mehdi@veris.ai>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: httpx>=0.24.0
12
+ Requires-Dist: pydantic>=2.0.0
13
+ Requires-Dist: requests>=2.31.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: black>=23.7.0; extra == 'dev'
16
+ Requires-Dist: mypy>=1.5.1; extra == 'dev'
17
+ Requires-Dist: openai-agents>=0.0.1; extra == 'dev'
18
+ Requires-Dist: pre-commit>=3.3.3; extra == 'dev'
19
+ Requires-Dist: pytest-asyncio>=0.21.1; extra == 'dev'
20
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
21
+ Requires-Dist: pytest>=7.4.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.11.4; extra == 'dev'
23
+ Provides-Extra: fastapi
24
+ Requires-Dist: fastapi; extra == 'fastapi'
25
+ Requires-Dist: fastapi-mcp; extra == 'fastapi'
26
+ Provides-Extra: instrument
27
+ Requires-Dist: braintrust; extra == 'instrument'
28
+ Requires-Dist: opentelemetry-api; extra == 'instrument'
29
+ Requires-Dist: opentelemetry-exporter-otlp; extra == 'instrument'
30
+ Requires-Dist: opentelemetry-exporter-otlp-proto-common; extra == 'instrument'
31
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc; extra == 'instrument'
32
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http; extra == 'instrument'
33
+ Requires-Dist: opentelemetry-sdk; extra == 'instrument'
34
+ Requires-Dist: wrapt; extra == 'instrument'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Veris AI Python SDK
38
+
39
+ A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
40
+
41
+ ## Installation
42
+
43
+ You can install the package using `uv`:
44
+
45
+ ```bash
46
+ # Install the package
47
+ uv add veris-ai
48
+
49
+ # Install with development dependencies
50
+ uv add "veris-ai[dev]"
51
+
52
+ # Install with FastAPI MCP integration
53
+ uv add "veris-ai[fastapi]"
54
+
55
+ # Install with tracing/instrumentation support
56
+ uv add "veris-ai[instrument]"
57
+ ```
58
+
59
+ ## Import Options
60
+
61
+ The SDK supports flexible import patterns to minimize dependencies:
62
+
63
+ ### Default Imports (Base Dependencies Only)
64
+
65
+ ```python
66
+ # These imports only require base dependencies (httpx, pydantic, requests)
67
+ from veris_ai import veris, JaegerClient, SearchQuery
68
+ ```
69
+
70
+ ### Optional Imports (Require Extra Dependencies)
71
+
72
+ ```python
73
+ # The instrument function requires the 'instrument' extra
74
+ # Install with: pip install veris-ai[instrument] or uv add "veris-ai[instrument]"
75
+ from veris_ai import instrument # Lazy-loaded, will error if deps missing
76
+ ```
77
+
78
+ ### Direct Submodule Imports
79
+
80
+ For maximum control over dependencies, you can import directly from submodules:
81
+
82
+ ```python
83
+ # Import only what you need
84
+ from veris_ai.tool_mock import veris
85
+ from veris_ai.jaeger_interface import JaegerClient
86
+ from veris_ai.braintrust_tracing import instrument # Requires [instrument] extra
87
+ ```
88
+
89
+ ## Environment Setup
90
+
91
+ The package requires the following environment variables:
92
+
93
+ ```bash
94
+ # Required: URL for the mock endpoint
95
+ VERIS_MOCK_ENDPOINT_URL=http://your-mock-endpoint.com
96
+
97
+ # Optional: Timeout in seconds (default: 30.0)
98
+ VERIS_MOCK_TIMEOUT=30.0
99
+
100
+ # Optional: Set to "simulation" to enable mock mode
101
+ ENV=simulation
102
+ ```
103
+
104
+ ## Tracing Integration
105
+
106
+ The SDK provides seamless integration with Braintrust and Jaeger/OpenTelemetry for distributed tracing.
107
+
108
+ ### Setting up Tracing
109
+
110
+ ```python
111
+ from veris_ai import instrument
112
+
113
+ # Initialize tracing instrumentation
114
+ instrument(
115
+ service_name="my-service", # or via VERIS_SERVICE_NAME env var
116
+ otlp_endpoint="http://localhost:4317" # or via VERIS_OTLP_ENDPOINT env var
117
+ )
118
+ ```
119
+
120
+ ### Session ID Tracking
121
+
122
+ When using the SDK with FastAPI MCP integration, session IDs are automatically embedded in all traces:
123
+
124
+ 1. **Automatic Session Extraction**: When a request includes an Authorization header with a bearer token, the token is automatically used as the session ID.
125
+
126
+ 2. **Trace Attribution**: All spans created during a request will include the `veris.session_id` attribute, allowing you to:
127
+ - Filter traces by session in Jaeger
128
+ - Correlate all operations within a single user session
129
+ - Debug issues specific to a particular session
130
+
131
+ 3. **Example**:
132
+ ```python
133
+ # FastAPI app with MCP integration
134
+ from fastapi import FastAPI
135
+ from veris_ai import veris, instrument
136
+
137
+ app = FastAPI()
138
+
139
+ # Set up tracing
140
+ instrument()
141
+
142
+ # Set up FastAPI MCP with session handling
143
+ veris.set_fastapi_mcp(
144
+ fastapi=app,
145
+ name="My API Server"
146
+ )
147
+
148
+ # Now all traces will automatically include session IDs from bearer tokens
149
+ ```
150
+
151
+ 4. **Manual Session Management**: You can also manually set session IDs:
152
+ ```python
153
+ veris.set_session_id("custom-session-123")
154
+ # All subsequent operations will be tagged with this session ID
155
+ veris.clear_session_id() # Clear when done
156
+ ```
157
+
158
+ The session ID tracking works seamlessly with both the mock decorators and the tracing system, providing end-to-end visibility of user sessions across your application.
159
+
160
+ ## Python Version
161
+
162
+ This project requires Python 3.11 or higher. We use [pyenv](https://github.com/pyenv/pyenv) for Python version management.
163
+
164
+ To set up the correct Python version:
165
+
166
+ ```bash
167
+ # Install Python 3.11.0 using pyenv
168
+ pyenv install 3.11.0
169
+
170
+ # Set the local Python version for this project
171
+ pyenv local 3.11.0
172
+ ```
173
+
174
+ ## Usage
175
+
176
+ ```python
177
+ from veris_ai import veris
178
+
179
+ @veris.mock()
180
+ async def your_function(param1: str, param2: int) -> dict:
181
+ """
182
+ Your function documentation here.
183
+
184
+ Args:
185
+ param1: Description of param1
186
+ param2: Description of param2
187
+
188
+ Returns:
189
+ A dictionary containing the results
190
+ """
191
+ # Your implementation here
192
+ return {"result": "actual implementation"}
193
+ ```
194
+
195
+ When `ENV=simulation` is set, the decorator will:
196
+ 1. Capture the function signature, type hints, and docstring
197
+ 2. Send this information to the mock endpoint
198
+ 3. Convert the mock response to the expected return type
199
+ 4. Return the mock result
200
+
201
+ When not in simulation mode, the original function will be executed normally.
202
+
203
+ ### Stub Decorator
204
+
205
+ For simple test scenarios where you want to return a fixed value in simulation mode, use the `@veris.stub()` decorator:
206
+
207
+ ```python
208
+ from veris_ai import veris
209
+
210
+ @veris.stub(return_value={"status": "success", "data": [1, 2, 3]})
211
+ async def get_data() -> dict:
212
+ """Get some data from external service."""
213
+ # This implementation is only called in production mode
214
+ return await fetch_from_api()
215
+
216
+ # In simulation mode: always returns {"status": "success", "data": [1, 2, 3]}
217
+ # In production mode: calls fetch_from_api()
218
+ ```
219
+
220
+ The stub decorator is useful for:
221
+ - Quick prototyping with fixed responses
222
+ - Testing with predictable data
223
+ - Bypassing external dependencies in development
224
+
225
+ ## FastAPI MCP Integration
226
+
227
+ The SDK provides integration with FastAPI applications through the Model Context Protocol (MCP). This allows your FastAPI endpoints to be exposed as MCP tools that can be used by AI agents.
228
+
229
+ ```python
230
+ from fastapi import FastAPI
231
+ from veris_ai import veris
232
+
233
+ app = FastAPI()
234
+
235
+ # Set up FastAPI MCP with automatic session handling
236
+ veris.set_fastapi_mcp(
237
+ fastapi=app,
238
+ name="My API Server",
239
+ description="My FastAPI application exposed as MCP tools",
240
+ describe_all_responses=True,
241
+ include_operations=["get_users", "create_user"],
242
+ exclude_tags=["internal"]
243
+ )
244
+
245
+ # The MCP server is now available at veris.fastapi_mcp
246
+ mcp_server = veris.fastapi_mcp
247
+ ```
248
+
249
+ ### Configuration Options
250
+
251
+ The `set_fastapi_mcp()` method accepts the following parameters:
252
+
253
+ - **fastapi** (required): Your FastAPI application instance
254
+ - **name**: Custom name for the MCP server (defaults to app.title)
255
+ - **description**: Custom description (defaults to app.description)
256
+ - **describe_all_responses**: Whether to include all response schemas in tool descriptions
257
+ - **describe_full_response_schema**: Whether to include full JSON schema for responses
258
+ - **http_client**: Optional custom httpx.AsyncClient instance
259
+ - **include_operations**: List of operation IDs to include as MCP tools
260
+ - **exclude_operations**: List of operation IDs to exclude (can't use with include_operations)
261
+ - **include_tags**: List of tags to include as MCP tools
262
+ - **exclude_tags**: List of tags to exclude (can't use with include_tags)
263
+ - **auth_config**: Optional FastAPI MCP AuthConfig for custom authentication
264
+
265
+ ### Session Management
266
+
267
+ The SDK automatically handles session management through OAuth2 authentication:
268
+ - Session IDs are extracted from bearer tokens
269
+ - Context is maintained across API calls
270
+ - Sessions can be managed programmatically:
271
+
272
+ ```python
273
+ # Get current session ID
274
+ session_id = veris.session_id
275
+
276
+ # Set a new session ID
277
+ veris.set_session_id("new-session-123")
278
+
279
+ # Clear the session
280
+ veris.clear_session_id()
281
+ ```
282
+
283
+ ## Braintrust & Jaeger Tracing
284
+
285
+ The SDK includes a non-invasive instrumentation helper for sending traces to both Braintrust and a Jaeger-compatible OpenTelemetry (OTEL) collector simultaneously. This allows you to leverage Braintrust's powerful monitoring and evaluation tools while also storing and visualizing traces in your own Jaeger instance.
286
+
287
+ ### Usage
288
+
289
+ To enable parallel tracing, simply import the `braintrust_tracing` module and call the `instrument()` function at the beginning of your application's lifecycle.
290
+
291
+ ```python
292
+ from veris_ai import braintrust_tracing
293
+
294
+ # Enable Braintrust and Jaeger tracing
295
+ braintrust_tracing.instrument()
296
+ ```
297
+
298
+ ### Configuration
299
+
300
+ The `instrument()` function is configured through environment variables:
301
+
302
+ - **`VERIS_SERVICE_NAME`** (required): The name of your service as it will appear in Jaeger.
303
+ - **`VERIS_OTLP_ENDPOINT`** (required): The gRPC endpoint of your Jaeger OTLP collector (e.g., `http://host.docker.internal:4317`).
304
+
305
+ When initialized, the SDK automatically patches the `agents` library to send traces to both systems without any further code changes required.
306
+
307
+ ## Utility Functions
308
+
309
+ ### extract_json_schema
310
+
311
+ The SDK provides a utility function to extract JSON schemas from Python types and Pydantic models:
312
+
313
+ ```python
314
+ from veris_ai.utils import extract_json_schema
315
+ from pydantic import BaseModel
316
+ from typing import List, Optional
317
+
318
+ # Extract schema from built-in types
319
+ int_schema = extract_json_schema(int)
320
+ # {"type": "integer"}
321
+
322
+ list_schema = extract_json_schema(List[str])
323
+ # {"type": "array", "items": {"type": "string"}}
324
+
325
+ # Extract schema from Pydantic models
326
+ class User(BaseModel):
327
+ name: str
328
+ age: int
329
+ email: Optional[str] = None
330
+
331
+ user_schema = extract_json_schema(User)
332
+ # Returns full JSON schema with properties, required fields, etc.
333
+
334
+ # Extract schema from TypedDict
335
+ from typing import TypedDict
336
+
337
+ class Config(TypedDict):
338
+ host: str
339
+ port: int
340
+ debug: bool
341
+
342
+ config_schema = extract_json_schema(Config)
343
+ # {"type": "object", "properties": {...}, "required": ["host", "port", "debug"]}
344
+ ```
345
+
346
+ This function supports:
347
+ - Built-in types (str, int, float, bool, None)
348
+ - Generic types (List, Dict, Union, Optional, Literal)
349
+ - Pydantic models
350
+ - TypedDict classes
351
+ - Forward references and complex nested types
352
+
353
+ ## Project Structure
354
+
355
+ ```
356
+ src/veris_ai/
357
+ ├── __init__.py # Main entry point, exports the veris instance
358
+ ├── tool_mock.py # VerisSDK class with @veris.mock() decorator
359
+ └── utils.py # Type conversion and JSON schema utilities
360
+
361
+ tests/
362
+ ├── conftest.py # Pytest fixtures
363
+ ├── test_tool_mock.py # Tests for VerisSDK functionality
364
+ └── test_utils.py # Tests for type conversion and schema extraction
365
+ ```
366
+
367
+ ## Development
368
+
369
+ This project uses `pyproject.toml` for dependency management and `uv` for package installation.
370
+
371
+ ### Development Dependencies
372
+
373
+ To install the package with development dependencies:
374
+
375
+ ```bash
376
+ uv add "veris-ai[dev]"
377
+ ```
378
+
379
+ This will install the following development tools:
380
+ - **Ruff**: Fast Python linter
381
+ - **pytest**: Testing framework
382
+ - **pytest-asyncio**: Async support for pytest
383
+ - **pytest-cov**: Coverage reporting for pytest
384
+ - **black**: Code formatter
385
+ - **mypy**: Static type checker
386
+ - **pre-commit**: Git hooks for code quality
387
+
388
+ ### Code Quality
389
+
390
+ This project uses [Ruff](https://github.com/charliermarsh/ruff) for linting and code quality checks. Ruff is a fast Python linter written in Rust.
391
+
392
+ To run Ruff:
393
+
394
+ ```bash
395
+ # Lint code
396
+ ruff check .
397
+
398
+ # Auto-fix linting issues
399
+ ruff check --fix .
400
+
401
+ # Format code
402
+ ruff format .
403
+
404
+ # Check formatting only
405
+ ruff format --check .
406
+ ```
407
+
408
+ The Ruff configuration is defined in `pyproject.toml` under the `[tool.ruff]` section.
409
+
410
+ ### Running Tests
411
+
412
+ ```bash
413
+ # Run all tests with coverage
414
+ pytest tests/ --cov=veris_ai --cov-report=xml --cov-report=term-missing
415
+
416
+ # Run specific test file
417
+ pytest tests/test_tool_mock.py
418
+
419
+ # Run tests with verbose output
420
+ pytest -v tests/
421
+ ```
422
+
423
+ ### Type Checking
424
+
425
+ ```bash
426
+ # Run static type checking
427
+ mypy src/veris_ai tests
428
+ ```
429
+
430
+ ## License
431
+
432
+ This project is licensed under the MIT License - see the LICENSE file for details.
433
+
434
+ ## Jaeger Trace Interface
435
+
436
+ A lightweight, fully-typed wrapper around the Jaeger **Query Service** HTTP API lives under `veris_ai.jaeger_interface`.
437
+ It allows you to **search and retrieve traces** from both Jaeger’s default storage back-ends as well as **OpenSearch**, which powers the official Jaeger UI search page.
438
+
439
+ ```python
440
+ from veris_ai.jaeger_interface import JaegerClient, SearchQuery
441
+
442
+ client = JaegerClient("http://localhost:16686")
443
+
444
+ traces = client.search(SearchQuery(service="veris-agent", limit=2))
445
+ first_trace = client.get_trace(traces.data[0].traceID)
446
+ ```
447
+
448
+ See `src/veris_ai/jaeger_interface/README.md` for a complete walkthrough and API reference.