@arizeai/phoenix-client 6.11.0 → 6.11.2

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.
Files changed (31) hide show
  1. package/dist/esm/__generated__/api/v1.d.ts +69 -0
  2. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  3. package/dist/esm/testing/phoenix-test-tracking.d.ts +16 -2
  4. package/dist/esm/testing/phoenix-test-tracking.d.ts.map +1 -1
  5. package/dist/esm/testing/phoenix-test-tracking.js +52 -7
  6. package/dist/esm/testing/phoenix-test-tracking.js.map +1 -1
  7. package/dist/esm/testing/runner.js +1 -1
  8. package/dist/esm/testing/runner.js.map +1 -1
  9. package/dist/esm/testing/types.d.ts +1 -1
  10. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  11. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  12. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  13. package/dist/src/__generated__/api/v1.d.ts +69 -0
  14. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  15. package/dist/src/testing/phoenix-test-tracking.d.ts +16 -2
  16. package/dist/src/testing/phoenix-test-tracking.d.ts.map +1 -1
  17. package/dist/src/testing/phoenix-test-tracking.js +53 -6
  18. package/dist/src/testing/phoenix-test-tracking.js.map +1 -1
  19. package/dist/src/testing/runner.js +1 -1
  20. package/dist/src/testing/runner.js.map +1 -1
  21. package/dist/src/testing/types.d.ts +1 -1
  22. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  23. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/docs/ci-evals-vitest.mdx +1 -1
  26. package/docs/ci-evals.mdx +2 -2
  27. package/package.json +6 -6
  28. package/src/__generated__/api/v1.ts +69 -0
  29. package/src/testing/phoenix-test-tracking.ts +58 -7
  30. package/src/testing/runner.ts +1 -1
  31. package/src/testing/types.ts +1 -1
@@ -90,7 +90,7 @@ px.describe("my suite", () => { ... }, {
90
90
  | `client` | `PhoenixClient` | Pre-configured `@arizeai/phoenix-client` instance. |
91
91
  | `repetitions` | `number` | Run each test in the suite this many times (default `1`; `PHOENIX_TEST_REPETITIONS` overrides the default). Per-test `repetitions` wins. |
92
92
  | `acceptanceCriteria` | `AcceptanceCriterion[]` | Aggregate annotation thresholds that fail the suite after all tests run. |
93
- | `dryRun` | `boolean` | Run the whole suite locally — no dataset, experiment, runs, or annotations are created in Phoenix. Same effect as `PHOENIX_TEST_TRACING=false`, scoped to this suite. |
93
+ | `dryRun` | `boolean` | Run the whole suite locally — no dataset, experiment, runs, or annotations are created in Phoenix. Same effect as `PHOENIX_TEST_TRACKING=false`, scoped to this suite. |
94
94
 
95
95
  ### `test(name, params, fn, timeout?)`
96
96
 
package/docs/ci-evals.mdx CHANGED
@@ -97,7 +97,7 @@ standard Phoenix env vars.
97
97
  | `PHOENIX_HOST` | Phoenix base URL |
98
98
  | `PHOENIX_API_KEY` | Bearer token for Phoenix |
99
99
  | `PHOENIX_CLIENT_HEADERS` | Optional JSON headers forwarded to the Phoenix client and tracer |
100
- | `PHOENIX_TEST_TRACING=false` | Disable sync to Phoenix for the current run (tracing is on by default) |
100
+ | `PHOENIX_TEST_TRACKING=false` | Disable sync to Phoenix for the current run (tracing is on by default) |
101
101
  | `PHOENIX_TEST_REPETITIONS` | Default number of times to run each test |
102
102
  | `PHOENIX_TEST_REPORTER=verbose` | Show every test row plus per-test `output:` detail (default is the compact view) |
103
103
  | `PHOENIX_TEST_REPORTER_MAX_ROWS` | Max test rows shown per suite in compact mode (default `10`; failures are never hidden) |
@@ -123,7 +123,7 @@ Dry-run executes test bodies (and tracing, when a tracer is attached) but
123
123
  creates no dataset, experiment, run, or annotations in Phoenix. The
124
124
  reporter still prints a local summary.
125
125
 
126
- - **Whole process** — `PHOENIX_TEST_TRACING=false`.
126
+ - **Whole process** — `PHOENIX_TEST_TRACKING=false`.
127
127
  - **One suite** — `describe(name, fn, { dryRun: true })`.
128
128
  - **One test** — `test(name, { input, dryRun: true }, fn)`; that case runs
129
129
  as an ordinary local test, with no dataset example and nothing uploaded,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-client",
3
- "version": "6.11.0",
3
+ "version": "6.11.2",
4
4
  "description": "A client for the Phoenix API",
5
5
  "keywords": [
6
6
  "arize",
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@arizeai/openinference-semantic-conventions": "^2.5.0",
99
- "@arizeai/openinference-vercel": "^2.7.8",
99
+ "@arizeai/openinference-vercel": "^2.8.1",
100
100
  "async": "^3.2.6",
101
101
  "openapi-fetch": "^0.17.0",
102
102
  "tiny-invariant": "^1.3.3",
@@ -105,16 +105,16 @@
105
105
  "@arizeai/phoenix-otel": "1.0.2"
106
106
  },
107
107
  "devDependencies": {
108
- "@ai-sdk/openai": "^3.0.73",
108
+ "@ai-sdk/openai": "^3.0.75",
109
109
  "@anthropic-ai/sdk": "^0.102.0",
110
110
  "@opentelemetry/api": "^1.9.1",
111
111
  "@opentelemetry/sdk-trace-node": "^2.8.0",
112
112
  "@types/async": "^3.2.25",
113
113
  "@types/node": "^25.9.4",
114
- "ai": "^6.0.208",
115
- "dotenv": "^16.4.7",
114
+ "ai": "^6.0.211",
115
+ "dotenv": "^16.6.1",
116
116
  "jest": "^29.7.0",
117
- "openai": "^6.44.0",
117
+ "openai": "^6.45.0",
118
118
  "openapi-typescript": "^7.13.0",
119
119
  "tsx": "^4.22.4",
120
120
  "vitest": "^4.1.9",
@@ -1298,6 +1298,40 @@ export interface paths {
1298
1298
  patch?: never;
1299
1299
  trace?: never;
1300
1300
  };
1301
+ "/agents/server/sessions/{session_id}/chat": {
1302
+ parameters: {
1303
+ query?: never;
1304
+ header?: never;
1305
+ path?: never;
1306
+ cookie?: never;
1307
+ };
1308
+ get?: never;
1309
+ put?: never;
1310
+ /**
1311
+ * Run Server Agent
1312
+ * @description Stream a chat turn from the GraphQL server agent.
1313
+ *
1314
+ * This is the endpoint the PXI CLI talks to directly (no pre-configured
1315
+ * agent record): it builds a fresh server agent per request from the
1316
+ * caller-supplied model and contexts, then streams the reply back as
1317
+ * Vercel-AI chunks.
1318
+ *
1319
+ * The request contexts gate capabilities — GraphQL mutations, web access,
1320
+ * and subagents — and mutations are refused for viewer users. When trace
1321
+ * recording is enabled (and permitted by system settings), the run is
1322
+ * traced; locally ingested traces are persisted to the agent's project
1323
+ * once the stream completes.
1324
+ *
1325
+ * Returns ``403`` if agents or the server agent are disabled, or if a
1326
+ * viewer requests mutations.
1327
+ */
1328
+ post: operations["run_server_agent_agents_server_sessions__session_id__chat_post"];
1329
+ delete?: never;
1330
+ options?: never;
1331
+ head?: never;
1332
+ patch?: never;
1333
+ trace?: never;
1334
+ };
1301
1335
  "/agents/{agent_id}/sessions/{session_id}/chat": {
1302
1336
  parameters: {
1303
1337
  query?: never;
@@ -9288,6 +9322,41 @@ export interface operations {
9288
9322
  };
9289
9323
  };
9290
9324
  };
9325
+ run_server_agent_agents_server_sessions__session_id__chat_post: {
9326
+ parameters: {
9327
+ query?: never;
9328
+ header?: never;
9329
+ path: {
9330
+ session_id: string;
9331
+ };
9332
+ cookie?: never;
9333
+ };
9334
+ requestBody: {
9335
+ content: {
9336
+ "application/json": components["schemas"]["ChatRequest"];
9337
+ };
9338
+ };
9339
+ responses: {
9340
+ /** @description Successful Response */
9341
+ 200: {
9342
+ headers: {
9343
+ [name: string]: unknown;
9344
+ };
9345
+ content: {
9346
+ "application/json": unknown;
9347
+ };
9348
+ };
9349
+ /** @description Validation Error */
9350
+ 422: {
9351
+ headers: {
9352
+ [name: string]: unknown;
9353
+ };
9354
+ content: {
9355
+ "application/json": components["schemas"]["HTTPValidationError"];
9356
+ };
9357
+ };
9358
+ };
9359
+ };
9291
9360
  chat_agents__agent_id__sessions__session_id__chat_post: {
9292
9361
  parameters: {
9293
9362
  query?: never;
@@ -28,23 +28,67 @@ import {
28
28
  import { currentRun, type RunState, type SuiteState } from "./state";
29
29
  import type { Annotation, KVMap } from "./types";
30
30
 
31
- function isFalsyFlag(value: string | undefined): boolean {
32
- const v = (value ?? "").toLowerCase();
31
+ export function isFalsyFlag(value: string | undefined): boolean {
32
+ // Tolerate surrounding whitespace and matching quotes that survive some
33
+ // shells and `.env` loaders (e.g. `PHOENIX_TEST_TRACKING="false"` or a value
34
+ // with a trailing newline). Without this, such a value reads as truthy and
35
+ // silently re-enables recording even though the user asked to disable it.
36
+ const v = (value ?? "")
37
+ .trim()
38
+ .replace(/^(['"])(.*)\1$/, "$2")
39
+ .trim()
40
+ .toLowerCase();
33
41
  return v === "false" || v === "0" || v === "off" || v === "no";
34
42
  }
35
43
 
44
+ /**
45
+ * Snapshot of `PHOENIX_TEST_TRACKING` as it was when this module first loaded.
46
+ *
47
+ * When the flag is exported on the command line (the documented `eval:offline`
48
+ * workflow), this captures the user's intent at process start and is immune to
49
+ * any later in-process mutation of `process.env` by a sibling suite or setup
50
+ * file. That mutation is what made tracking leak across suites in #13930: one
51
+ * suite flipped the env var and re-enabled recording for the others.
52
+ */
53
+ const trackingDisabledAtLoad = isFalsyFlag(process.env.PHOENIX_TEST_TRACKING);
54
+
55
+ /**
56
+ * Latches to `true` the first time tracking is observed disabled in this
57
+ * process. Recording is opt-out and shared process-wide, so a single falsy
58
+ * reading turns the whole run off and keeps it off — later suites cannot
59
+ * re-enable recording regardless of declaration or execution order.
60
+ */
61
+ let trackingLatchedOff = trackingDisabledAtLoad;
62
+
63
+ /**
64
+ * Reset the process-level tracking latch. Test-only seam so unit tests can
65
+ * exercise the enable/disable transitions in isolation; not part of the
66
+ * public API.
67
+ *
68
+ * @internal
69
+ */
70
+ export function __resetTrackingLatchForTests(): void {
71
+ trackingLatchedOff = isFalsyFlag(process.env.PHOENIX_TEST_TRACKING);
72
+ }
73
+
36
74
  /**
37
75
  * Decide whether tests should sync to Phoenix.
38
76
  *
39
77
  * Tracing is enabled by default. It can be disabled globally by setting
40
- * `PHOENIX_TEST_TRACING=false`, or per suite via `SuiteConfig.dryRun`.
78
+ * `PHOENIX_TEST_TRACKING=false`, or per suite via `SuiteConfig.dryRun`.
79
+ *
80
+ * The global disable is sticky for the lifetime of the process: once the flag
81
+ * is seen falsy — at load time or on any later call — tracking stays off for
82
+ * every suite. This keeps offline mode deterministic regardless of which
83
+ * suites are included in a run, or the order they execute in.
41
84
  */
42
85
  export function isTrackingEnabled(suite?: SuiteState): {
43
86
  enabled: boolean;
44
87
  reason?: string;
45
88
  } {
46
- if (isFalsyFlag(process.env.PHOENIX_TEST_TRACING)) {
47
- return { enabled: false, reason: "PHOENIX_TEST_TRACING is disabled" };
89
+ if (trackingLatchedOff || isFalsyFlag(process.env.PHOENIX_TEST_TRACKING)) {
90
+ trackingLatchedOff = true;
91
+ return { enabled: false, reason: "PHOENIX_TEST_TRACKING is disabled" };
48
92
  }
49
93
  if (suite?.config.dryRun) {
50
94
  return { enabled: false, reason: "suite configured dryRun" };
@@ -177,7 +221,7 @@ function buildLinks(
177
221
  * Initialize the suite: upload the dataset, create the experiment, and
178
222
  * register the OpenInference tracer.
179
223
  *
180
- * If tracing is disabled (no Phoenix env vars, or PHOENIX_TEST_TRACING=false),
224
+ * If tracing is disabled (no Phoenix env vars, or PHOENIX_TEST_TRACKING=false),
181
225
  * this populates a no-op tracer and exits without making any network calls.
182
226
  */
183
227
  export async function initializeSuite(suite: SuiteState): Promise<void> {
@@ -478,6 +522,7 @@ export async function postExperimentRun(
478
522
  if (
479
523
  run.dryRun ||
480
524
  suite.trackingDisabled ||
525
+ !isTrackingEnabled(suite).enabled ||
481
526
  !suite.client ||
482
527
  !suite.experimentId
483
528
  ) {
@@ -524,7 +569,13 @@ export async function postAnnotation(
524
569
  runId: string | undefined,
525
570
  annotation: Annotation
526
571
  ): Promise<void> {
527
- if (suite.trackingDisabled || !suite.client || !runId) return;
572
+ if (
573
+ suite.trackingDisabled ||
574
+ !isTrackingEnabled(suite).enabled ||
575
+ !suite.client ||
576
+ !runId
577
+ )
578
+ return;
528
579
  const start = new Date();
529
580
  const end = new Date();
530
581
  try {
@@ -148,7 +148,7 @@ export function declareTest<Input extends KVMap, Expected extends KVMap>(
148
148
 
149
149
  // A per-test `dryRun` opts the case out of Phoenix entirely: no dataset
150
150
  // example, no experiment run, no annotations — it runs as an ordinary
151
- // local test. Suite-level dryRun (or PHOENIX_TEST_TRACING=false) is
151
+ // local test. Suite-level dryRun (or PHOENIX_TEST_TRACKING=false) is
152
152
  // handled in `initializeSuite`, which never uploads anything anyway.
153
153
  const isDryRun = !!params.dryRun;
154
154
 
@@ -241,7 +241,7 @@ export interface SuiteConfig {
241
241
  /**
242
242
  * When `true`, the whole suite runs as ordinary local tests — no dataset
243
243
  * is uploaded and no experiment, runs, or annotations are created in
244
- * Phoenix. Equivalent to `PHOENIX_TEST_TRACING=false` scoped to this
244
+ * Phoenix. Equivalent to `PHOENIX_TEST_TRACKING=false` scoped to this
245
245
  * suite. The reporter still prints a local summary.
246
246
  */
247
247
  dryRun?: boolean;