refactor(agentex): remove the legacy Postgres spans API, table and UI reader - #430
refactor(agentex): remove the legacy Postgres spans API, table and UI reader#430mohammadatallah-scale wants to merge 4 commits into
Conversation
… reader Agent spans live in Scale GenAI Platform through the SDK's SGP tracing processor, so the Postgres-backed /spans routes, ORM model, repository, use case, schemas and tests go, and a migration drops the spans table. The UI traces sidebar was the last reader. It now fetches the task's trace from the platform through a scoped same-origin BFF route, the same way feedback already reaches the platform. The regenerated OpenAPI spec drops the spans surface, so the next SDK generation removes the client resource. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
✱ Stainless preview buildsThis PR will update the openapi python typescript Edit this comment to update them. They will appear in their respective SDK's changelogs.
|
| ❗ Reference/NotFound: Missing reference: `#/components/schemas/Span` |
| ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `post /spans` |
| ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `get /spans` |
| ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `patch /spans/{span_id}` |
| ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `get /spans/{span_id}` |
⚠️ agentex-sdk-typescript studio · code · diff
Your SDK build had at least one "error" diagnostic, which is a regression from the base state.
generate ❗(prev:generate ⚠️) →build ⏭️→lint ⏭️→test ⏭️(prev:test ✅)New diagnostics (5 error)
❗ Reference/NotFound: Missing reference: `#/components/schemas/Span` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `post /spans` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `get /spans` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `patch /spans/{span_id}` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `get /spans/{span_id}`
⚠️ agentex-sdk-python studio · conflict
Your SDK build had at least one new error diagnostic, which is a regression from the base state.
New diagnostics (5 error)
❗ Reference/NotFound: Missing reference: `#/components/schemas/Span` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `post /spans` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `get /spans` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `patch /spans/{span_id}` ❗ Endpoint/NotFound: Skipped endpoint because it's not in your OpenAPI spec: `get /spans/{span_id}`
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-09-11 14:07:02 UTC
…latform search with the browser The traces query keyed on the task id alone, so a deep link that switched the account while keeping the task could show the other account's cached spans. The BFF route also let a cancelled browser request keep the platform search running, unlike the Agentex proxy next to it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
P3 PR body - "SDKs older than 0.13" is wrong, the default processor left the SDK in 0.11.1. Left as is: the two applied migrations whose docstrings still name the deleted runbook, since applied migrations are not edited. |
…pt short pages The platform defaults an omitted search window to the last 90 days and refuses a page that exceeds its byte budget unless the caller opts into short pages, so an old or a heavy task read as empty or as an error. The sidebar now passes the task's creation time, which the proxy turns into a 90-day window, and opts into short pages. The header no longer loads spans to learn the trace id, which is the task id by construction. The truncation notice names the Investigate link only when it renders, and CI now runs the UI unit tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The raw fetch behind the traces sidebar returned a 401 to the user when the access token had expired, where the SDK client refreshes the session and retries. The hook now does the same, only when login is enabled. The migration docstring also stops claiming that nothing writes the table and that the drop always fits the statement timeout. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
andrewvo-scale
left a comment
There was a problem hiding this comment.
Blocking: the new creation-anchored 90-day query in agentex-ui/app/api/traces/[traceId]/spans/route.ts silently excludes spans emitted after roughly day 90. Agentex explicitly supports Temporal workflows that run for days, weeks, months, or indefinitely, and later turns keep the same task/trace ID. Because has_more is computed only inside this bounded request, the sidebar can present an apparently complete but stale trace with no warning. Please cover successive windows of at most 90 days, or deliberately choose and surface a truncated window so omitted history is explicit.
Important
Pending Mohammad's self-review. This note is removed by a human, not automation.
The problem. Agentex still keeps its own Postgres spans store, which only the UI sidebar reads since the SDK's SGP processor became the default.
The fix.
The span search window comes from the task's own creation time, which no account switch can change.
Blocked on scaleapi/scale-agentex-python#517 first. The drop is irreversible. Agents on SDKs older than 0.11.1 write here by default, so a deployment hosting them loses their traces. Move them to SGP and export the table if its history matters.
Test plan
The PR is not yet safe to merge because the new task-timestamp lookup can reuse account-stale cache data and hide valid platform spans.
Fix with agent prompt
Summary
Diagram
sequenceDiagram participant U as Browser participant T as AgentEx task API participant B as Traces BFF participant S as SGP span search U->>T: Load selected task T-->>U: Task created_at U->>B: "GET /api/traces/{taskId}/spans?from={created_at}" B->>B: Attach session and account credentials B->>S: POST /v5/spans/search for task trace S-->>B: First ordered page of spans B-->>U: Stream platform responseReviews (2) · Last reviewed commit: "fix(agentex-ui): retry a span read once ..."