veris-ai 1.10.0__tar.gz → 1.10.1__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 (40) hide show
  1. {veris_ai-1.10.0 → veris_ai-1.10.1}/PKG-INFO +54 -2
  2. {veris_ai-1.10.0 → veris_ai-1.10.1}/README.md +53 -1
  3. {veris_ai-1.10.0 → veris_ai-1.10.1}/pyproject.toml +1 -1
  4. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/README.md +4 -4
  5. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/api_client.py +31 -9
  6. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/observability.py +1 -2
  7. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/test_agents_wrapper_simple.py +1 -1
  8. {veris_ai-1.10.0 → veris_ai-1.10.1}/uv.lock +2 -2
  9. {veris_ai-1.10.0 → veris_ai-1.10.1}/.cursor/rules/documentation-management.mdc +0 -0
  10. {veris_ai-1.10.0 → veris_ai-1.10.1}/.github/workflows/release.yml +0 -0
  11. {veris_ai-1.10.0 → veris_ai-1.10.1}/.github/workflows/test.yml +0 -0
  12. {veris_ai-1.10.0 → veris_ai-1.10.1}/.gitignore +0 -0
  13. {veris_ai-1.10.0 → veris_ai-1.10.1}/.pre-commit-config.yaml +0 -0
  14. {veris_ai-1.10.0 → veris_ai-1.10.1}/CHANGELOG.md +0 -0
  15. {veris_ai-1.10.0 → veris_ai-1.10.1}/CLAUDE.md +0 -0
  16. {veris_ai-1.10.0 → veris_ai-1.10.1}/LICENSE +0 -0
  17. {veris_ai-1.10.0 → veris_ai-1.10.1}/examples/README.md +0 -0
  18. {veris_ai-1.10.0 → veris_ai-1.10.1}/examples/__init__.py +0 -0
  19. {veris_ai-1.10.0 → veris_ai-1.10.1}/examples/import_options.py +0 -0
  20. {veris_ai-1.10.0 → veris_ai-1.10.1}/examples/openai_agents_example.py +0 -0
  21. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/__init__.py +0 -0
  22. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/agents_wrapper.py +0 -0
  23. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/jaeger_interface/README.md +0 -0
  24. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/jaeger_interface/__init__.py +0 -0
  25. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/jaeger_interface/client.py +0 -0
  26. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/jaeger_interface/models.py +0 -0
  27. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/models.py +0 -0
  28. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/tool_mock.py +0 -0
  29. {veris_ai-1.10.0 → veris_ai-1.10.1}/src/veris_ai/utils.py +0 -0
  30. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/README.md +0 -0
  31. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/__init__.py +0 -0
  32. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/conftest.py +0 -0
  33. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/fixtures/__init__.py +0 -0
  34. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/fixtures/http_server.py +0 -0
  35. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/fixtures/simple_app.py +0 -0
  36. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/test_agents_wrapper_extract.py +0 -0
  37. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/test_mcp_protocol_server_mocked.py +0 -0
  38. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/test_tool_mock.py +0 -0
  39. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/test_utils.py +0 -0
  40. {veris_ai-1.10.0 → veris_ai-1.10.1}/tests/test_veris_runner_tool_options.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: veris-ai
3
- Version: 1.10.0
3
+ Version: 1.10.1
4
4
  Summary: A Python package for Veris AI tools
5
5
  Project-URL: Homepage, https://github.com/veris-ai/veris-python-sdk
6
6
  Project-URL: Bug Tracker, https://github.com/veris-ai/veris-python-sdk/issues
@@ -151,7 +151,7 @@ What this enables:
151
151
 
152
152
  End-to-end propagation with the simulator:
153
153
  - The simulator injects W3C headers when connecting to your FastAPI MCP endpoints
154
- - The SDK injects W3C headers on `/api/v2/tool_mock` and logging requests back to the simulator
154
+ - The SDK injects W3C headers on `/v2/tool_mock` and logging requests back to the simulator
155
155
  - Result: customer agent spans and tool mocks appear under the same distributed trace
156
156
 
157
157
  ## Function Mocking
@@ -212,6 +212,58 @@ async def get_data() -> dict:
212
212
 
213
213
  **Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
214
214
 
215
+ ### Core Instrument
216
+
217
+ Instrument OpenAI agents without changing tool code by using the SDK's Runner (extends OpenAI's Runner) and an optional VerisConfig for fine control.
218
+
219
+ Requirements:
220
+ - Install extras: `uv add "veris-ai[agents]"`
221
+ - Set `ENV=simulation` to enable mock behavior (otherwise passes through)
222
+
223
+ Minimal usage:
224
+
225
+ ```python
226
+ from veris_ai import Runner
227
+
228
+ result = await Runner.run(agent, "What's 10 + 5?")
229
+ ```
230
+
231
+ Select tools to intercept (include/exclude):
232
+
233
+ ```python
234
+ from veris_ai import Runner, VerisConfig
235
+
236
+ config = VerisConfig(include_tools=["calculator", "search_web"]) # or exclude_tools=[...]
237
+ result = await Runner.run(agent, "Process this", veris_config=config)
238
+ ```
239
+
240
+ Per‑tool behavior via ToolCallOptions:
241
+
242
+ ```python
243
+ from veris_ai import Runner, VerisConfig, ToolCallOptions, ResponseExpectation
244
+
245
+ config = VerisConfig(
246
+ tool_options={
247
+ "calculator": ToolCallOptions(
248
+ response_expectation=ResponseExpectation.REQUIRED,
249
+ cache_response=True,
250
+ mode="tool",
251
+ ),
252
+ "search_web": ToolCallOptions(
253
+ response_expectation=ResponseExpectation.NONE,
254
+ cache_response=False,
255
+ mode="spy",
256
+ ),
257
+ }
258
+ )
259
+
260
+ result = await Runner.run(agent, "Calculate and search", veris_config=config)
261
+ ```
262
+
263
+ Notes:
264
+ - Runner is a drop‑in enhancement over OpenAI's Runner (full details in [OpenAI Agents Integration](#openai-agents-integration))
265
+ - See complete examples in [`examples/openai_agents_example.py`](examples/openai_agents_example.py)
266
+
215
267
  ## OpenAI Agents Integration
216
268
 
217
269
  **Semantic Tag**: `openai-agents`
@@ -108,7 +108,7 @@ What this enables:
108
108
 
109
109
  End-to-end propagation with the simulator:
110
110
  - The simulator injects W3C headers when connecting to your FastAPI MCP endpoints
111
- - The SDK injects W3C headers on `/api/v2/tool_mock` and logging requests back to the simulator
111
+ - The SDK injects W3C headers on `/v2/tool_mock` and logging requests back to the simulator
112
112
  - Result: customer agent spans and tool mocks appear under the same distributed trace
113
113
 
114
114
  ## Function Mocking
@@ -169,6 +169,58 @@ async def get_data() -> dict:
169
169
 
170
170
  **Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
171
171
 
172
+ ### Core Instrument
173
+
174
+ Instrument OpenAI agents without changing tool code by using the SDK's Runner (extends OpenAI's Runner) and an optional VerisConfig for fine control.
175
+
176
+ Requirements:
177
+ - Install extras: `uv add "veris-ai[agents]"`
178
+ - Set `ENV=simulation` to enable mock behavior (otherwise passes through)
179
+
180
+ Minimal usage:
181
+
182
+ ```python
183
+ from veris_ai import Runner
184
+
185
+ result = await Runner.run(agent, "What's 10 + 5?")
186
+ ```
187
+
188
+ Select tools to intercept (include/exclude):
189
+
190
+ ```python
191
+ from veris_ai import Runner, VerisConfig
192
+
193
+ config = VerisConfig(include_tools=["calculator", "search_web"]) # or exclude_tools=[...]
194
+ result = await Runner.run(agent, "Process this", veris_config=config)
195
+ ```
196
+
197
+ Per‑tool behavior via ToolCallOptions:
198
+
199
+ ```python
200
+ from veris_ai import Runner, VerisConfig, ToolCallOptions, ResponseExpectation
201
+
202
+ config = VerisConfig(
203
+ tool_options={
204
+ "calculator": ToolCallOptions(
205
+ response_expectation=ResponseExpectation.REQUIRED,
206
+ cache_response=True,
207
+ mode="tool",
208
+ ),
209
+ "search_web": ToolCallOptions(
210
+ response_expectation=ResponseExpectation.NONE,
211
+ cache_response=False,
212
+ mode="spy",
213
+ ),
214
+ }
215
+ )
216
+
217
+ result = await Runner.run(agent, "Calculate and search", veris_config=config)
218
+ ```
219
+
220
+ Notes:
221
+ - Runner is a drop‑in enhancement over OpenAI's Runner (full details in [OpenAI Agents Integration](#openai-agents-integration))
222
+ - See complete examples in [`examples/openai_agents_example.py`](examples/openai_agents_example.py)
223
+
172
224
  ## OpenAI Agents Integration
173
225
 
174
226
  **Semantic Tag**: `openai-agents`
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "veris-ai"
7
- version = "1.10.0"
7
+ version = "1.10.1"
8
8
  description = "A Python package for Veris AI tools"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -27,16 +27,16 @@ This module contains the core implementation of the Veris AI Python SDK. Each co
27
27
 
28
28
  ### Mock Flow
29
29
  1. **Decoration**: `@veris.mock()` captures function metadata
30
- 2. **Session Check**: Presence of session ID determines behavior
31
- 3. **API Call**: POST to VERIS API endpoint `/v2/tool_mock` (auto-configured)
30
+ 2. **Environment Check**: `ENV=simulation` determines behavior
31
+ 3. **API Call**: POST to `{VERIS_ENDPOINT_URL}/v2/tool_mock`
32
32
  4. **Type Conversion**: Response converted using `extract_json_schema()`
33
33
 
34
34
  **Implementation**: [`tool_mock.py:200-250`](tool_mock.py)
35
35
 
36
36
  ### Spy Flow
37
- 1. **Pre-execution Logging**: Call details sent to `/v2/simulations/{session_id}/log_tool_call`
37
+ 1. **Pre-execution Logging**: Call details sent to `/v2/log_tool_call`
38
38
  2. **Function Execution**: Original function runs normally
39
- 3. **Post-execution Logging**: Response sent to `/v2/simulations/{session_id}/log_tool_response`
39
+ 3. **Post-execution Logging**: Response sent to `/v2/log_tool_response`
40
40
 
41
41
  **Implementation**: [`tool_mock.py:250-300`](tool_mock.py)
42
42
 
@@ -11,28 +11,50 @@ logger = logging.getLogger(__name__)
11
11
 
12
12
 
13
13
  class SimulatorAPIClient:
14
- """Centralized client for making requests to VERIS simulation endpoints."""
14
+ """Centralized client for making requests to VERIS simulation endpoints.
15
+
16
+ Note:
17
+ This client intentionally reads configuration (base URL and API key)
18
+ from environment variables at call-time instead of at construction
19
+ time. This allows tests to patch environment variables and have those
20
+ changes reflected without recreating the singleton.
21
+ """
15
22
 
16
23
  def __init__(self) -> None:
17
- """Initialize the API client with configuration from environment variables."""
18
- self.base_url = os.getenv("VERIS_API_URL", "https://simulation.api.veris.ai/")
19
- self.api_key = os.getenv("VERIS_API_KEY")
24
+ """Initialize the API client with static timeout configuration."""
20
25
  self.timeout = float(os.getenv("VERIS_MOCK_TIMEOUT", "90.0"))
21
26
 
27
+ def _get_base_url(self) -> str:
28
+ """Resolve the base URL from environment.
29
+
30
+ Behavior:
31
+ - If VERIS_API_URL is unset, default to the dev simulator URL.
32
+ - If VERIS_API_URL is set to an empty string, treat it as empty
33
+ (do not fall back). This supports tests expecting connection
34
+ failures when an invalid endpoint is provided.
35
+ """
36
+ return os.getenv("VERIS_API_URL") or "https://simulator.api.veris.ai"
37
+
22
38
  def _build_headers(self) -> dict[str, str] | None:
23
39
  """Build headers including OpenTelemetry tracing and API key."""
24
40
  headers: dict[str, str] | None = None
25
41
  # Add API key header if available
26
- if self.api_key:
42
+ api_key = os.getenv("VERIS_API_KEY")
43
+ if api_key:
27
44
  if headers is None:
28
45
  headers = {}
29
- headers["x-api-key"] = self.api_key
46
+ headers["x-api-key"] = api_key
30
47
 
31
48
  return headers
32
49
 
33
50
  def post(self, endpoint: str, payload: dict[str, Any]) -> Any: # noqa: ANN401
34
51
  """Make a synchronous POST request to the specified endpoint."""
35
52
  headers = self._build_headers()
53
+ # Validate endpoint URL; raise ConnectError for non-absolute URLs to
54
+ # mirror connection failures in tests when base URL is intentionally invalid.
55
+ if not endpoint.startswith(("http://", "https://")):
56
+ raise httpx.ConnectError("Invalid endpoint URL (not absolute): {endpoint}")
57
+
36
58
  with httpx.Client(timeout=self.timeout) as client:
37
59
  response = client.post(endpoint, json=payload, headers=headers)
38
60
  response.raise_for_status()
@@ -41,15 +63,15 @@ class SimulatorAPIClient:
41
63
  @property
42
64
  def tool_mock_endpoint(self) -> str:
43
65
  """Get the tool mock endpoint URL."""
44
- return urljoin(self.base_url, "v2/tool_mock")
66
+ return urljoin(self._get_base_url(), "v2/tool_mock")
45
67
 
46
68
  def get_log_tool_call_endpoint(self, session_id: str) -> str:
47
69
  """Get the log tool call endpoint URL."""
48
- return urljoin(self.base_url, f"v2/simulations/{session_id}/log_tool_call")
70
+ return urljoin(self._get_base_url(), f"v2/simulations/{session_id}/log_tool_call")
49
71
 
50
72
  def get_log_tool_response_endpoint(self, session_id: str) -> str:
51
73
  """Get the log tool response endpoint URL."""
52
- return urljoin(self.base_url, f"v2/simulations/{session_id}/log_tool_response")
74
+ return urljoin(self._get_base_url(), f"v2/simulations/{session_id}/log_tool_response")
53
75
 
54
76
 
55
77
  # Global singleton instance
@@ -16,7 +16,7 @@ logger = getLogger(__name__)
16
16
  def init_observability() -> None: # noqa: PLR0912
17
17
  """Initialize tracing/export and set W3C propagation.
18
18
 
19
- - Initializes Traceloop if available (acts as OTel bootstrap/exporter)
19
+ - Initializes logfire if available (acts as OTel bootstrap/exporter)
20
20
  - Sets global propagator to TraceContext + Baggage (W3C)
21
21
  - Instruments MCP, requests, httpx if instrumentation packages are present
22
22
  - Adds a request hook to capture outbound traceparent for debugging
@@ -35,7 +35,6 @@ def init_observability() -> None: # noqa: PLR0912
35
35
  logfire.instrument_mcp()
36
36
 
37
37
  except Exception as e:
38
- # Tracing is optional; continue without Traceloop
39
38
  msg = "Logfire not found: " + str(e)
40
39
  raise RuntimeError(msg) from e
41
40
 
@@ -244,7 +244,7 @@ async def test_runner_with_session_calls_endpoint(
244
244
 
245
245
  # Verify the call had correct structure
246
246
  first_call = mock_veris_endpoint["calls"][0]
247
- assert first_call["endpoint"] == "http://localhost:8000/api/v2/tool_mock"
247
+ assert first_call["endpoint"] == "http://localhost:8000/v2/tool_mock"
248
248
  assert first_call["payload"]["session_id"] == "test-session-123"
249
249
  assert "add_numbers" in str(first_call["payload"]) or "veris_tool_function" in str(
250
250
  first_call["payload"]
@@ -1,5 +1,5 @@
1
1
  version = 1
2
- revision = 3
2
+ revision = 2
3
3
  requires-python = ">=3.11"
4
4
  resolution-markers = [
5
5
  "python_full_version >= '3.13'",
@@ -1565,7 +1565,7 @@ wheels = [
1565
1565
 
1566
1566
  [[package]]
1567
1567
  name = "veris-ai"
1568
- version = "1.9.0"
1568
+ version = "1.10.0"
1569
1569
  source = { editable = "." }
1570
1570
  dependencies = [
1571
1571
  { name = "httpx" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes