Skip to content

Commit 9104635

Browse files
fix(evals): select query endpoint from edgeUrl vs url (#275)
## Summary - select eval baseline query endpoint deterministically based on config - when `eval.edgeUrl` is set, use `/v1/query/_apl` on edge - when `eval.edgeUrl` is not set, use `/v1/datasets/_apl` on API URL - remove runtime fallback chaining between endpoints ## Verification - `pnpm build` (packages/ai) - `npm run eval -- support-agent-e2e-tool-use` (examples/kitchen-sink) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes how eval case data is queried by switching base URL and API path depending on whether `config.eval.edgeUrl` is explicitly set, which could affect eval retrieval if deployments rely on the previous endpoint behavior. > > **Overview** > `findEvaluationCases` now selects the Axiom query endpoint deterministically: if `config.eval.edgeUrl` is explicitly set it uses the edge query route (`/v1/query/_apl`), otherwise it queries via the standard API URL (`/v1/datasets/_apl`). > > The error handling for failed queries is also hardened to tolerate missing `payload.message`/`resp.statusText` and emit a fallback message. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 70a594b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c2c4efe commit 9104635

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/ai/src/evals/eval.service.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const findEvaluationCases = async (
9393
evalId: string,
9494
config: ResolvedAxiomConfig,
9595
): Promise<Evaluation | null> => {
96-
const { dataset, edgeUrl, token, orgId } = resolveAxiomConnection(config);
96+
const { dataset, edgeUrl, url, token, orgId } = resolveAxiomConnection(config);
9797

9898
const apl = `['${dataset}'] | where trace_id == "${evalId}" | order by _time`;
9999

@@ -103,16 +103,25 @@ export const findEvaluationCases = async (
103103
...(orgId ? { 'X-AXIOM-ORG-ID': orgId } : {}),
104104
});
105105

106-
// Use edgeUrl for query operations
107-
const resp = await fetch(`${edgeUrl}/v1/datasets/_apl?format=legacy`, {
106+
// If edgeUrl is explicitly configured, use the edge query endpoint.
107+
// Otherwise use the regular API query endpoint.
108+
const hasExplicitEdgeUrl = !!config.eval.edgeUrl;
109+
const queryBaseUrl = hasExplicitEdgeUrl ? edgeUrl : url;
110+
const queryPath = hasExplicitEdgeUrl
111+
? '/v1/query/_apl?format=legacy'
112+
: '/v1/datasets/_apl?format=legacy';
113+
114+
const resp = await fetch(`${queryBaseUrl}${queryPath}`, {
108115
headers: headers,
109116
method: 'POST',
110117
body: JSON.stringify({ apl }),
111118
});
112119
const payload = await resp.json();
113120

114121
if (!resp.ok) {
115-
throw new Error(`Failed to query evaluation cases: ${payload.message || resp.statusText}`);
122+
throw new Error(
123+
`Failed to query evaluation cases: ${payload?.message || resp?.statusText || 'Unknown error'}`,
124+
);
116125
}
117126

118127
return payload.matches.length ? buildSpanTree(payload.matches) : null;

0 commit comments

Comments
 (0)