Skip to content

fix(evaluator): Update routes url#928

Merged
nina-kollman merged 5 commits intomainfrom
nk/eval_routes
Apr 12, 2026
Merged

fix(evaluator): Update routes url#928
nina-kollman merged 5 commits intomainfrom
nk/eval_routes

Conversation

@nina-kollman
Copy link
Copy Markdown
Contributor

@nina-kollman nina-kollman commented Apr 12, 2026

Summary by CodeRabbit

  • Chores

    • Updated evaluator execution endpoint to use the new execute route.
    • Changed experiment task creation to the pluralized tasks route.
    • Trigger requests now include evaluator_slug and forward experimentSlug.
  • Breaking Changes

    • SDK run/trigger options now require experimentSlug; update any calls to supply this field.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b74b1d69-20ed-4c86-83f5-312c37bbd681

📥 Commits

Reviewing files that changed from the base of the PR and between 729547f and 2b37bc7.

📒 Files selected for processing (1)
  • packages/traceloop-sdk/test/standalone-evaluators.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/traceloop-sdk/test/standalone-evaluators.test.ts

📝 Walkthrough

Walkthrough

Evaluator execution endpoints and experiment task endpoints/payloads were updated: evaluator run now posts to a standalone /v2/evaluators/{identifier}/execute; experiment-trigger requests require experimentSlug, include evaluator_slug, and use the experiment run task resource; task creation route pluralized to /tasks.

Changes

Cohort / File(s) Summary
Evaluator client
packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts
Switched evaluator run route from POST /v2/evaluators/{identifier}/executionsPOST /v2/evaluators/{identifier}/execute. triggerExperimentEvaluator now accepts/destructures experimentSlug, requires experimentSlug when taskResult is present, adds evaluator_slug: evaluatorName to the payload, and posts to POST /v2/experiments/{experimentSlug}/runs/{experimentRunId}/tasks/{taskId}. Request/response shapes otherwise preserved.
Experiment client
packages/traceloop-sdk/src/lib/client/experiment/experiment.ts
runLocally(...) now forwards experimentSlug to evaluator runner. createTask(...) endpoint changed from POST /v2/experiments/${experimentSlug}/runs/${experimentRunId}/taskPOST /v2/experiments/${experimentSlug}/runs/${experimentRunId}/tasks; body and response mapping unchanged.
Type definitions
packages/traceloop-sdk/src/lib/interfaces/evaluator.interface.ts
Added required experimentSlug: string to EvaluatorRunOptions and TriggerEvaluatorRequest, aligning type definitions with updated client calls and validation.
Tests
packages/traceloop-sdk/test/standalone-evaluators.test.ts
Updated test expectations for evaluator run endpoint URL from /v2/evaluators/:id/executions/v2/evaluators/:id/execute (covers id and slug cases).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through code and nudged a path anew,
A little slug I carried, and payloads too.
Execute now sings where executions used to be,
Tasks pluralized — a tidy hop for me.
Nose twitch, small tweak, endpoints dancing free.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: multiple evaluator and experiment API routes were updated/modified across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nk/eval_routes

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts`:
- Around line 227-229: The run() method endpoint was changed to
"/v2/evaluators/:id/execute" but tests still assert the old
"/v2/evaluators/:id/executions" URL; update the assertions in the standalone
evaluators tests that check the request URL to expect
"https://api.traceloop.com/v2/evaluators/:id/execute" instead of the old path so
they match the post call made in Evaluator.run (the client.post call using
`/v2/evaluators/${encodeURIComponent(identifier)}/execute`).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbad6579-412f-4ff6-a753-e88548c5167d

📥 Commits

Reviewing files that changed from the base of the PR and between a869545 and 5271da1.

📒 Files selected for processing (2)
  • packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts
  • packages/traceloop-sdk/src/lib/client/experiment/experiment.ts

Comment thread packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts (1)

366-404: ⚠️ Potential issue | 🟠 Major

Validate experimentRunId and taskId before building the new task URL.

Line 402 now requires both values in the path, but this method still only guards experimentId and taskResult. If either ID is missing, the client will POST to /runs/undefined/tasks/undefined instead of failing fast with a clear local error.

Suggested fix
-    if (!experimentId || !taskResult) {
-      throw new Error("experimentId, evaluator, and taskResult are required");
+    if (!experimentId || !experimentRunId || !taskId || !evaluator || !taskResult) {
+      throw new Error(
+        "experimentId, experimentRunId, taskId, evaluator, and taskResult are required",
+      );
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts` around lines
366 - 404, The method currently validates only experimentId and taskResult but
then builds a URL using experimentRunId and taskId; add explicit validation for
experimentRunId and taskId (e.g., check they are truthy) alongside the existing
guard for experimentId/taskResult and throw a clear Error if missing, before
calling createInputSchemaMapping or this.client.post so the client doesn't POST
to /runs/undefined/tasks/undefined; update the error message to mention
experimentRunId and taskId (referencing the variables experimentRunId, taskId
and the client.post call) so failures fail fast locally.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts`:
- Around line 366-404: The method currently validates only experimentId and
taskResult but then builds a URL using experimentRunId and taskId; add explicit
validation for experimentRunId and taskId (e.g., check they are truthy)
alongside the existing guard for experimentId/taskResult and throw a clear Error
if missing, before calling createInputSchemaMapping or this.client.post so the
client doesn't POST to /runs/undefined/tasks/undefined; update the error message
to mention experimentRunId and taskId (referencing the variables
experimentRunId, taskId and the client.post call) so failures fail fast locally.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cb443df9-d29f-4fdf-af8f-4920c753ad7b

📥 Commits

Reviewing files that changed from the base of the PR and between 5271da1 and 67fb86e.

📒 Files selected for processing (1)
  • packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/traceloop-sdk/src/lib/interfaces/evaluator.interface.ts (1)

11-19: ⚠️ Potential issue | 🟠 Major

Require all route params in the public request types.

runExperimentEvaluator() / triggerExperimentEvaluator() now target /v2/experiments/${experimentSlug}/runs/${experimentRunId}/tasks/${taskId}. Leaving experimentRunId optional on EvaluatorRunOptions, and experimentRunId/taskId optional on TriggerEvaluatorRequest, lets SDK consumers build requests that type-check but still produce /runs/undefined/tasks/undefined at runtime.

Suggested contract fix
 export interface EvaluatorRunOptions {
   experimentId: string;
   experimentSlug: string;
-  experimentRunId?: string;
+  experimentRunId: string;
   taskId: string;
   taskResult: Record<string, any>;
   evaluator: EvaluatorDetails;
   waitForResults?: boolean;
   timeout?: number;
 }

 export interface TriggerEvaluatorRequest {
   experimentId: string;
   experimentSlug: string;
-  experimentRunId?: string;
-  taskId?: string;
+  experimentRunId: string;
+  taskId: string;
   evaluator: EvaluatorDetails;
   taskResult: Record<string, any>;
   metadata?: Record<string, any>;
 }

Also applies to: 31-37

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/traceloop-sdk/src/lib/interfaces/evaluator.interface.ts` around
lines 11 - 19, The public request types allow building requests with undefined
route params; make experimentRunId and taskId required so callers cannot produce
/runs/undefined/tasks/undefined: update the EvaluatorRunOptions interface to
mark experimentRunId as non-optional and update TriggerEvaluatorRequest (and any
related request type around lines 31-37) to make experimentRunId and taskId
required, and verify runExperimentEvaluator/triggerExperimentEvaluator
signatures use these non-optional properties so the router string interpolation
always receives defined values.
packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts (1)

365-405: ⚠️ Potential issue | 🟠 Major

Reject missing experimentRunId and taskId before building the task URL.

This method now posts to /v2/experiments/${experimentSlug}/runs/${experimentRunId}/tasks/${taskId}, but it only validates experimentSlug and taskResult. A JS caller—or any caller passing undefined through—will silently hit /runs/undefined/tasks/undefined instead of getting a local error. Please validate the run/task identifiers here as well, and make the error message match the actual checks.

Suggested guard update
-    if (!experimentSlug || !taskResult) {
-      throw new Error("experimentSlug, evaluator, and taskResult are required");
+    if (!experimentSlug || !experimentRunId || !taskId || !taskResult) {
+      throw new Error(
+        "experimentSlug, experimentRunId, taskId, and taskResult are required",
+      );
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts` around lines
365 - 405, The code currently only checks experimentSlug and taskResult but
later uses experimentRunId and taskId to build the URL; update the same method
to validate that experimentRunId and taskId are present (not
null/undefined/empty) before constructing the payload/URL and throw a clear
Error mentioning which identifier is missing; ensure the thrown message aligns
with the actual checks (e.g., "experimentSlug, experimentRunId, taskId,
evaluator, and taskResult are required" or separate errors for run vs task), and
keep references to the existing variables experimentRunId, taskId,
experimentSlug, taskResult and evaluatorName so the validation runs prior to
calling this.client.post.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts`:
- Around line 365-405: The code currently only checks experimentSlug and
taskResult but later uses experimentRunId and taskId to build the URL; update
the same method to validate that experimentRunId and taskId are present (not
null/undefined/empty) before constructing the payload/URL and throw a clear
Error mentioning which identifier is missing; ensure the thrown message aligns
with the actual checks (e.g., "experimentSlug, experimentRunId, taskId,
evaluator, and taskResult are required" or separate errors for run vs task), and
keep references to the existing variables experimentRunId, taskId,
experimentSlug, taskResult and evaluatorName so the validation runs prior to
calling this.client.post.

In `@packages/traceloop-sdk/src/lib/interfaces/evaluator.interface.ts`:
- Around line 11-19: The public request types allow building requests with
undefined route params; make experimentRunId and taskId required so callers
cannot produce /runs/undefined/tasks/undefined: update the EvaluatorRunOptions
interface to mark experimentRunId as non-optional and update
TriggerEvaluatorRequest (and any related request type around lines 31-37) to
make experimentRunId and taskId required, and verify
runExperimentEvaluator/triggerExperimentEvaluator signatures use these
non-optional properties so the router string interpolation always receives
defined values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c591851b-bfbc-4ae1-854d-0ce8f0dcf0e5

📥 Commits

Reviewing files that changed from the base of the PR and between 67fb86e and 2dcfef8.

📒 Files selected for processing (3)
  • packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts
  • packages/traceloop-sdk/src/lib/client/experiment/experiment.ts
  • packages/traceloop-sdk/src/lib/interfaces/evaluator.interface.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/traceloop-sdk/src/lib/client/experiment/experiment.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts (1)

365-390: ⚠️ Potential issue | 🟠 Major

Validate evaluator before dereferencing it.

Line 380 can throw (evaluator.name) when request.evaluator is missing, because Lines 374-376 currently don’t validate evaluator despite the error message saying it is required.

💡 Suggested fix
-    if (!experimentSlug || !taskResult) {
-      throw new Error("experimentSlug, evaluator, and taskResult are required");
-    }
+    if (!experimentSlug || !taskResult || !evaluator) {
+      throw new Error("experimentSlug, evaluator, and taskResult are required");
+    }

     // Handle string, EvaluatorWithVersion, and EvaluatorWithConfig types
     const evaluatorName =
       typeof evaluator === "string" ? evaluator : evaluator.name;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts` around lines
365 - 390, The code dereferences request.evaluator without validating it; update
the initial validation to require evaluator (e.g., check request.evaluator !==
undefined/null) before extracting properties, or add a guard before computing
evaluatorName/evaluatorVersion/evaluatorConfig so you never access
evaluator.name on undefined; adjust the thrown Error message to match (include
"evaluator" alongside experimentSlug and taskResult), and use the existing local
symbols evaluatorName, evaluatorVersion, evaluatorConfig to compute values only
after the null/undefined check passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts`:
- Line 410: The interpolated route string in evaluator.ts uses experimentSlug,
experimentRunId, and taskId directly; wrap each dynamic segment with URL-safe
encoding (e.g., apply encodeURIComponent to experimentSlug, experimentRunId, and
taskId before building the template string used for
`/v2/experiments/.../runs/.../tasks/...`) so reserved URL characters won’t break
or redirect the request; update the code that constructs that path (the template
string using `/v2/experiments/${...}/runs/${...}/tasks/${...}`) to use the
encoded values.

---

Outside diff comments:
In `@packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts`:
- Around line 365-390: The code dereferences request.evaluator without
validating it; update the initial validation to require evaluator (e.g., check
request.evaluator !== undefined/null) before extracting properties, or add a
guard before computing evaluatorName/evaluatorVersion/evaluatorConfig so you
never access evaluator.name on undefined; adjust the thrown Error message to
match (include "evaluator" alongside experimentSlug and taskResult), and use the
existing local symbols evaluatorName, evaluatorVersion, evaluatorConfig to
compute values only after the null/undefined check passes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01a855fd-6054-4138-ba49-deee5e977fbc

📥 Commits

Reviewing files that changed from the base of the PR and between 2dcfef8 and 729547f.

📒 Files selected for processing (1)
  • packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts

Comment thread packages/traceloop-sdk/src/lib/client/evaluator/evaluator.ts
@nina-kollman nina-kollman merged commit 116e033 into main Apr 12, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants