phoenix-client-development

Guides development of the phoenix-client TypeScript SDK covering experiments, prompts, tracing, and vitest testing.

11.3k|1.1k|Updated Nov 9, 2022
One-click install
npx skills add https://github.com/Arize-ai/phoenix --skill phoenix-client-development
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: phoenix-client-development
Source: https://github.com/Arize-ai/phoenix/tree/main/js/packages/phoenix-client/.agents/skills/phoenix-client-development
Command: npx skills add https://github.com/Arize-ai/phoenix --skill phoenix-client-development

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Contributing to the @arizeai/phoenix-client TypeScript SDK requires following non-obvious conventions: two-phase experiment lifecycle with separate tracer providers, prompt selector object patterns, OpenTelemetry global state management through phoenix-otel, and three distinct test layers. This Skill encodes those rules so changes stay consistent and avoid subtle bugs like leaked tracer providers or silently widened prompt selectors.

Core Features & Use Cases

  • Experiment Lifecycle Rules: Enforces the two-phase task/evaluation architecture with correct provider ownership and cleanup across runExperiment, resumeExperiment, and resumeEvaluation.
  • Prompt API Conventions: Guides use of PromptSelector and PromptIdentifier unions, runtime guards against version selectors, and server version gating via RouteRequirement.
  • Tracing and Testing Standards: Routes all global tracer state through phoenix-otel attach/detach functions and defines unit, provider lifecycle, and integration test conventions.
  • Use Case: When adding a new prompt helper to the SDK, the Skill directs you to accept a selector object, resolve it with resolvePromptIdentifier, add a RouteRequirement for version gating, and write vitest tests with correctly mocked phoenix-otel functions.

Quick Start

Use the phoenix-client development skill to add a new experiment feature to the phoenix-client package and write the corresponding vitest tests.

Frequently Asked Questions about phoenix-client-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run experiments with the phoenix-client TypeScript SDK?

Experiments run in two phases: a task phase using the experiment's projectName, then an evaluation phase using projectName "evaluators". Each phase creates its own tracer provider with global: false, and the task provider must be fully cleaned up before the eval provider is created.

How do I write tests for the phoenix-client package?

Run tests with pnpm --filter phoenix-client test using vitest, with test files named *.test.ts in the test/ directory. When mocking @arizeai/phoenix-otel, register() must return getTracer, forceFlush, and shutdown, and attachGlobalTracerProvider must return a detach function.

Why should I avoid calling provider.register() directly in OpenTelemetry setup?

In pnpm workspaces, packages may resolve @opentelemetry/api to different module instances, so direct register() calls create inconsistent global state. All global tracer provider mutations must go through phoenix-otel's attachGlobalTracerProvider and detachGlobalTracerProvider functions.

How do I select a prompt by name or version in the Phoenix client?

Pass a selector object under a prompt key, such as { prompt: { name: "x" } }, using PromptSelector for version-level operations or PromptIdentifier for prompt-level operations. resolvePromptIdentifier rejects versionId and tag selectors at runtime to prevent accidental destructive operations.

What are the conventions for integration tests against a live Phoenix server?

Integration tests are standalone scripts run via npx tsx, not part of the vitest suite. File names must start with integration-, use a plain assert helper instead of vitest imports, avoid console.log, and clean up OTel global state with trace.disable, context.disable, and propagation.disable.