Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(tasks): return short stable download URLs for run artifacts (#79176)

Adam Bowker3ebcb7ca931b
diff --git a/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.test.ts b/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.test.ts
index 02f2a8e86d89..8d54a95fdbf3 100644
--- a/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.test.ts
+++ b/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.test.ts
@@ -5,11 +5,13 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const prepareTaskArtifactUploads = vi.fn();
const finalizeTaskArtifactUploads = vi.fn();
+const uploadTaskArtifacts = vi.fn();
vi.mock("../../../signed-commit-artefacts", () => ({
createSandboxPosthogClient: () => ({
prepareTaskArtifactUploads,
finalizeTaskArtifactUploads,
+ uploadTaskArtifacts,
}),
}));
@@ -50,6 +52,17 @@ describe("uploadArtifactTool", () => {
url: "https://storage.example/download/report.csv",
},
]);
+ uploadTaskArtifacts.mockResolvedValue([
+ {
+ id: "artifact-1",
+ name: "report.csv",
+ type: "output",
+ size: 7,
+ storage_path: "tasks/artifacts/report.csv",
+ uploaded_at: "2026-01-01T00:00:00Z",
+ url: "https://app.example/download/artifact-1",
+ },
+ ]);
});
afterEach(async () => {
@@ -96,6 +109,48 @@ describe("uploadArtifactTool", () => {
);
});
+ it("falls back to the inline upload when object storage is unreachable", async () => {
+ await writeFile(path.join(cwd, "report.csv"), "a,b\n1,2");
+ vi.stubGlobal(
+ "fetch",
+ vi.fn().mockRejectedValue(new TypeError("fetch failed")),
+ );
+
+ const result = await uploadArtifactTool.handler(
+ { cwd, taskId: "task-1", taskRunId: "run-1" },
+ { path: "report.csv", contentType: "text/csv" },
+ );
+
+ expect(result.isError).toBeUndefined();
+ expect(uploadTaskArtifacts).toHaveBeenCalledWith("task-1", "run-1", [
+ expect.objectContaining({
+ name: "report.csv",
+ content: Buffer.from("a,b\n1,2").toString("base64"),
+ content_encoding: "base64",
+ }),
+ ]);
+ expect(result.content[0]?.text).toContain(
+ "https://app.example/download/artifact-1",
+ );
+ });
+
+ it("surfaces the failure instead of falling back above the inline size limit", async () => {
+ await writeFile(path.join(cwd, "big.bin"), Buffer.alloc(11 * 1024 * 1024));
+ vi.stubGlobal(
+ "fetch",
+ vi.fn().mockRejectedValue(new TypeError("fetch failed")),
+ );
+
+ const result = await uploadArtifactTool.handler(
+ { cwd, taskId: "task-1", taskRunId: "run-1" },
+ { path: "big.bin" },
+ );
+
+ expect(result.isError).toBe(true);
+ expect(result.content[0]?.text).toContain("fetch failed");
+ expect(uploadTaskArtifacts).not.toHaveBeenCalled();
+ });
+
it("rejects files outside the session workspace", async () => {
const outside = await mkdtemp(path.join(os.tmpdir(), "outside-artifact-"));
const outsideFile = path.join(outside, "secret.txt");
diff --git a/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.ts b/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.ts
index 4c1c776f991a..c00302ee57f2 100644
--- a/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.ts
+++ b/products/desktop/packages/agent/src/adapters/local-tools/tools/upload-artifact.ts
@@ -1,10 +1,15 @@
import { readFile, realpath, stat } from "node:fs/promises";
import path from "node:path";
import { z } from "zod";
+import type { PostHogAPIClient } from "../../../posthog-api";
import { createSandboxPosthogClient } from "../../../signed-commit-artefacts";
+import type { TaskRunArtifact } from "../../../types";
import { defineLocalTool, type LocalToolResult } from "../registry";
const MAX_ARTIFACT_UPLOAD_BYTES = 30 * 1024 * 1024;
+// The inline fallback base64-encodes the file into a JSON body, so it is held to a lower
+// ceiling than a direct-to-storage POST to stay under the API's request size limit.
+const MAX_INLINE_UPLOAD_BYTES = 10 * 1024 * 1024;
export const uploadArtifactTool = defineLocalTool({
name: "upload_artifact",
@@ -65,71 +70,37 @@ export const uploadArtifactTool = defineLocalTool({
);
}
- const name = args.name ?? path.basename(artifactPath);
- const contentType = args.contentType ?? "application/octet-stream";
- const prepared = await client.prepareTaskArtifactUploads(
- ctx.taskId,
- ctx.taskRunId,
- [
- {
- name,
- type: "output",
- source: "agent_output",
- size: fileStat.size,
- content_type: contentType,
- },
- ],
- );
- const upload = prepared[0];
- if (!upload) {
- return errorResult("PostHog did not prepare the artifact upload.");
- }
+ const upload = {
+ name: args.name ?? path.basename(artifactPath),
+ contentType: args.contentType ?? "application/octet-stream",
+ content: await readFile(artifactPath),
+ };
- const form = new FormData();
- for (const [key, value] of Object.entries(upload.presigned_post.fields)) {
- form.append(key, value);
- }
- form.append(
- "file",
- new Blob([await readFile(artifactPath)], { type: contentType }),
- name,
- );
- const response = await fetch(upload.presigned_post.url, {
- method: "POST",
- body: form,
- });
- if (!response.ok) {
- return errorResult(
- `Artifact storage upload failed (${response.status}).`,
+ let downloadUrl: string | undefined;
+ try {
+ downloadUrl = await uploadDirect(
+ client,
+ ctx.taskId,
+ ctx.taskRunId,
+ upload,
+ );
+ } catch (error) {
+ // A direct upload needs the agent to reach object storage itself, which fails in
+ // any environment where the sandbox can reach the PostHog API but not the storage
+ // host (a split network, or an egress allowlist that omits the bucket). The inline
+ // upload goes through the API instead, so retry there before surfacing a failure.
+ if (upload.content.byteLength > MAX_INLINE_UPLOAD_BYTES) {
+ throw error;
+ }
+ downloadUrl = await uploadInline(
+ client,
+ ctx.taskId,
+ ctx.taskRunId,
+ upload,
);
}
- const finalized = await client.finalizeTaskArtifactUploads(
- ctx.taskId,
- ctx.taskRunId,
- [
- {
- id: upload.id,
- name,
- type: "output",
- source: "agent_output",
- storage_path: upload.storage_path,
- content_type: contentType,
- },
- ],
- );
- const finalizedEntry = finalized.find(
- (artifact) => artifact.storage_path === upload.storage_path,
- );
- if (!finalizedEntry) {
- return errorResult("PostHog did not confirm the artifact upload.");
- }
-
- // The finalize endpoint returns a presigned download URL on each artifact.
- // Read it defensively: the field rides in on TaskRunArtifact once the
- // api-client is regenerated against the updated OpenAPI spec, and older
- // backends simply omit it.
- const downloadUrl = (finalizedEntry as { url?: string }).url;
+ const { name } = upload;
const linkText = downloadUrl ? ` Download URL: ${downloadUrl}` : "";
return {
@@ -148,6 +119,108 @@ export const uploadArtifactTool = defineLocalTool({
},
});
+interface ArtifactUpload {
+ name: string;
+ contentType: string;
+ content: Buffer;
+}
+
+/** Reserve a storage key, POST the bytes straight to object storage, then attach them. */
+async function uploadDirect(
+ client: PostHogAPIClient,
+ taskId: string,
+ taskRunId: string,
+ { name, contentType, content }: ArtifactUpload,
+): Promise<string | undefined> {
+ const [prepared] = await client.prepareTaskArtifactUploads(
+ taskId,
+ taskRunId,
+ [
+ {
+ name,
+ type: "output",
+ source: "agent_output",
+ size: content.byteLength,
+ content_type: contentType,
+ },
+ ],
+ );
+ if (!prepared) {
+ throw new Error("PostHog did not prepare the artifact upload.");
+ }
+
+ const form = new FormData();
+ for (const [key, value] of Object.entries(prepared.presigned_post.fields)) {
+ form.append(key, value);
+ }
+ form.append(
+ "file",
+ new Blob([new Uint8Array(content)], { type: contentType }),
+ name,
+ );
+ const response = await fetch(prepared.presigned_post.url, {
+ method: "POST",
+ body: form,
+ });
+ if (!response.ok) {
+ throw new Error(`Artifact storage upload failed (${response.status}).`);
+ }
+
+ const finalized = await client.finalizeTaskArtifactUploads(
+ taskId,
+ taskRunId,
+ [
+ {
+ id: prepared.id,
+ name,
+ type: "output",
+ source: "agent_output",
+ storage_path: prepared.storage_path,
+ content_type: contentType,
+ },
+ ],
+ );
+ const entry = finalized.find(
+ (artifact) => artifact.storage_path === prepared.storage_path,
+ );
+ if (!entry) {
+ throw new Error("PostHog did not confirm the artifact upload.");
+ }
+ return readDownloadUrl(entry);
+}
+
+/** Send the bytes through the PostHog API and let the backend write them to storage. */
+async function uploadInline(
+ client: PostHogAPIClient,
+ taskId: string,
+ taskRunId: string,
+ { name, contentType, content }: ArtifactUpload,
+): Promise<string | undefined> {
+ const manifest = await client.uploadTaskArtifacts(taskId, taskRunId, [
+ {
+ name,
+ type: "output",
+ source: "agent_output",
+ content: content.toString("base64"),
+ content_encoding: "base64",
+ content_type: contentType,
+ },
+ ]);
+ // The endpoint returns the run's whole manifest with the new entry appended last.
+ const entry = manifest.at(-1);
+ if (!entry) {
+ throw new Error("PostHog did not confirm the artifact upload.");
+ }
+ return readDownloadUrl(entry);
+}
+
+// Read the download URL defensively: the field rides in on TaskRunArtifact once the
+// api-client is regenerated against the updated OpenAPI spec, and older backends simply
+// omit it.
+function readDownloadUrl(artifact: TaskRunArtifact): string | undefined {
+ return (artifact as { url?: string }).url;
+}
+
function errorResult(message: string): LocalToolResult {
return { content: [{ type: "text", text: message }], isError: true };
}
diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.py
index 8af6bee56408..7ed49909e049 100644
--- a/products/tasks/backend/facade/api.py
+++ b/products/tasks/backend/facade/api.py
@@ -32,12 +32,14 @@ from django.db import IntegrityError, transaction
from django.db.models import CharField, Count, Exists, F, Func, Min, OuterRef, Q, QuerySet, Subquery
from django.db.models.fields.json import KeyTextTransform
from django.utils import timezone as django_timezone
+from django.utils.http import content_disposition_header
import posthoganalytics
from posthog.event_usage import groups
from posthog.models import Team, User
from posthog.models.integration import Integration
+from posthog.utils import absolute_uri
from products.tasks.backend.constants import (
AGENT_OTEL_TELEMETRY_STATE_KEY,
@@ -204,6 +206,7 @@ __all__ = [
"prepare_task_run_artifact_uploads",
"prepare_task_staged_artifacts",
"presign_task_run_artifact",
+ "presign_task_run_artifact_download",
"read_task_run_artifact",
"read_task_run_logs",
"record_comment_activity",
@@ -2599,6 +2602,10 @@ def _build_artifact_storage_path(run: TaskRun, artifact_id: str, name: str) -> t
return safe_name, f"{prefix}/{artifact_id[:8]}_{safe_name}"
+def _build_artifact_download_path(run: TaskRun, artifact_id: str) -> str:
+ return f"/api/projects/{run.team_id}/tasks/{run.task_id}/runs/{run.id}/artifacts/{artifact_id}/download/"
+
+
def _tag_artifact_object(run: TaskRun, storage_path: str) -> None:
from posthog.storage import object_storage # noqa: PLC0415 — keep storage deps off the api import path
@@ -2656,7 +2663,7 @@ def upload_task_run_artifacts(
"""Write artifact bytes to S3 and append them to the run manifest.
Returns ``(uploaded, manifest)`` — the entries created for ``artifacts`` and the full
- manifest including them — or ``None`` when the run isn't visible.
+ manifest including them, each carrying a ``url`` — or ``None`` when the run isn't visible.
An artifact may carry an explicit ``id``; entries with that id are upserted into the
manifest (same-id S3 writes overwrite the same key), so callers that derive ids
@@ -2715,7 +2722,17 @@ def upload_task_run_artifacts(
manifest.extend(uploaded)
_save_artifact_manifest(run, manifest)
- return uploaded, manifest
+ # Same download URL the finalize-upload path returns, so a caller that reaches storage
+ # through this endpoint instead of a presigned POST still gets a link to surface. Built
+ # after the save so it stays off the persisted manifest.
+ response_manifest = [
+ {**entry, "url": absolute_uri(_build_artifact_download_path(run, entry["id"]))}
+ if entry.get("id")
+ else dict(entry)
+ for entry in manifest
+ ]
+
+ return uploaded, response_manifest
def prepare_task_run_artifact_uploads(
@@ -2854,13 +2871,17 @@ def finalize_task_run_artifact_uploads(
for storage_path in new_storage_paths:
_tag_artifact_object(run, storage_path)
- # Mint a fresh presigned download URL per response entry so the caller (e.g. the
- # upload_artifact tool) can surface a link to the file. Presigned URLs expire, so
- # they are attached to the response only and never written back to the manifest.
+ # Attach a download URL per response entry so the caller (e.g. the upload_artifact
+ # tool) can surface a link to the file. The app URL redirects to a fresh presigned
+ # URL on each request, so unlike a raw presigned URL it stays short and works for
+ # the artifact's full retention window rather than one presign TTL; it is attached
+ # to the response only and never written back to the manifest.
response_entries: list[dict] = []
for entry in finalized_entries:
- presigned_url = object_storage.get_presigned_url(entry["storage_path"])
- response_entries.append({**entry, "url": presigned_url} if presigned_url else dict(entry))
+ entry_id = entry.get("id")
+ response_entries.append(
+ {**entry, "url": absolute_uri(_build_artifact_download_path(run, entry_id))} if entry_id else dict(entry)
+ )
return response_entries, None
@@ -3030,6 +3051,35 @@ def set_task_run_artifacts_dismissed(
return manifest, None
+def presign_task_run_artifact_download(
+ run_id: str | UUID, task_id: str | UUID, team_id: int, *, artifact_id: str
+) -> tuple[str | None, str | None]:
+ """Presign a download URL for an artifact addressed by its manifest id.
+
+ Returns ``(url, error)``: ``(None, None)`` if the run isn't found, ``(None, "not_found")`` if
+ the artifact isn't on the run, ``(None, "unavailable")`` if presigning fails, else ``(url, None)``.
+ """
+ from posthog.storage import object_storage # noqa: PLC0415 — keep storage deps off the api import path
+
+ run = _get_visible_run(run_id, task_id, team_id)
+ if run is None:
+ return None, None
+
+ entry = next((a for a in run.artifacts or [] if a.get("id") == artifact_id), None)
+ if entry is None:
+ return None, "not_found"
+
+ filename = str(entry.get("name") or "artifact")
+ url = object_storage.get_presigned_url(
+ entry["storage_path"],
+ content_type=str(entry.get("content_type") or "") or None,
+ content_disposition=content_disposition_header(as_attachment=True, filename=filename) or "attachment",
+ )
+ if not url:
+ return None, "unavailable"
+ return url, None
+
+
def read_task_run_artifact(
run_id: str | UUID, task_id: str | UUID, team_id: int, *, storage_path: str
) -> tuple[bytes | None, dict | None, str | None]:
diff --git a/products/tasks/backend/presentation/serializers.py b/products/tasks/backend/presentation/serializers.py
index db503569d1ce..ad1b09123cec 100644
--- a/products/tasks/backend/presentation/serializers.py
+++ b/products/tasks/backend/presentation/serializers.py
@@ -287,8 +287,9 @@ class TaskRunArtifactResponseSerializer(serializers.Serializer):
url = serializers.URLField(
required=False,
help_text=(
- "Presigned download URL for the artifact. Populated on the finalize-upload response so "
- "the caller can link to the file directly; it is time-limited and not persisted on the manifest."
+ "Stable download URL for the artifact. Populated on the finalize-upload response so "
+ "the caller can link to the file; it redirects to a fresh presigned URL on each request "
+ "and is not persisted on the manifest."
),
)
diff --git a/products/tasks/backend/presentation/views/api.py b/products/tasks/backend/presentation/views/api.py
index a87a85795853..6543085125a3 100644
--- a/products/tasks/backend/presentation/views/api.py
+++ b/products/tasks/backend/presentation/views/api.py
@@ -11,7 +11,7 @@ from urllib.parse import parse_qs, quote, urlparse
from uuid import UUID
from django.conf import settings
-from django.http import HttpResponse, JsonResponse
+from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
import pydantic
import requests as http_requests
@@ -1068,6 +1068,7 @@ class TaskRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
"stream_token",
"artifacts_presign",
"artifacts_download",
+ "artifacts_download_by_id",
)
def _ensure_task_accessible(self) -> str:
@@ -1769,6 +1770,46 @@ class TaskRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
)
return response
+ @extend_schema(
+ parameters=[
+ OpenApiParameter(
+ "artifact_id",
+ OpenApiTypes.STR,
+ OpenApiParameter.PATH,
+ description="Manifest id of the artifact to download",
+ )
+ ],
+ responses={
+ 302: OpenApiResponse(description="Redirect to a short-lived presigned download URL"),
+ 400: OpenApiResponse(
+ response=TaskRunErrorResponseSerializer, description="Unable to generate download URL"
+ ),
+ 404: OpenApiResponse(description="Artifact not found"),
+ },
+ summary="Download a task run artifact by id",
+ description=(
+ "Redirects to a short-lived presigned URL for the artifact, so callers can share a stable "
+ "link instead of a raw presigned URL."
+ ),
+ )
+ @action(
+ detail=True,
+ methods=["get"],
+ url_path=r"artifacts/(?P<artifact_id>[^/]+)/download",
+ required_scopes=["task:read"],
+ )
+ def artifacts_download_by_id(self, request, pk=None, artifact_id=None, **kwargs):
+ task_id = self._ensure_task_accessible()
+ url, error = tasks_facade.presign_task_run_artifact_download(pk, task_id, self.team_id, artifact_id=artifact_id)
+ if error == "unavailable":
+ return Response(
+ TaskRunErrorResponseSerializer({"error": "Unable to generate download URL"}).data,
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+ if url is None:
+ raise NotFound()
+ return HttpResponseRedirect(url)
+
@extend_schema(
extensions={"x-product": "logs"},
responses={
diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.py
index 8b83e3d73ae9..7b27dfac38f1 100644
--- a/products/tasks/backend/tests/test_api.py
+++ b/products/tasks/backend/tests/test_api.py
@@ -5911,9 +5911,18 @@ class TestTaskRunAPI(BaseTaskAPITest):
mock_write.assert_called_once()
mock_tag.assert_called_once()
+ returned = response.json()["artifacts"][0]
+ self.assertEqual(
+ returned["url"],
+ absolute_uri(
+ f"/api/projects/{self.team.id}/tasks/{task.id}/runs/{run.id}/artifacts/{returned['id']}/download/"
+ ),
+ )
+
run.refresh_from_db()
self.assertEqual(len(run.artifacts), 1)
artifact = run.artifacts[0]
+ self.assertNotIn("url", artifact)
self.assertIn("id", artifact)
self.assertEqual(artifact["name"], "plan.md")
self.assertEqual(artifact["type"], "plan")
@@ -6585,6 +6594,14 @@ class TestTaskRunAPI(BaseTaskAPITest):
mock_head_object.assert_called_once_with(storage_path)
mock_tag.assert_called_once()
+ returned = response.json()["artifacts"][0]
+ self.assertEqual(
+ returned["url"],
+ absolute_uri(
+ f"/api/projects/{self.team.id}/tasks/{task.id}/runs/{run.id}/artifacts/{artifact_id}/download/"
+ ),
+ )
+
run.refresh_from_db()
self.assertEqual(len(run.artifacts), 1)
artifact = run.artifacts[0]
@@ -6713,7 +6730,7 @@ class TestTaskRunAPI(BaseTaskAPITest):
self.assertEqual(response.status_code, status.HTTP_200_OK)
returned_artifacts = response.json()["artifacts"]
- # The finalize response augments each entry with a presigned download URL that is not
+ # The finalize response augments each entry with a download URL that is not
# persisted on the manifest, so compare the stored fields separately from the URL.
self.assertEqual([{k: v for k, v in a.items() if k != "url"} for a in returned_artifacts], run.artifacts)
self.assertTrue(all(a.get("url") for a in returned_artifacts))
@@ -6846,6 +6863,39 @@ class TestTaskRunAPI(BaseTaskAPITest):
self.assertEqual(response.json()["url"], "https://example.com/artifact?sig=123")
self.assertIn("expires_in", response.json())
+ @patch("posthog.storage.object_storage.get_presigned_url")
+ def test_download_artifact_by_id_redirects_to_presigned_url(self, mock_presign):
+ mock_presign.return_value = "https://example.com/artifact?sig=123"
+ task = self.create_task()
+ artifact_id = uuid.uuid4().hex
+ run = TaskRun.objects.create(
+ task=task,
+ team=self.team,
+ status=TaskRun.Status.IN_PROGRESS,
+ artifacts=[
+ {
+ "id": artifact_id,
+ "name": "report.pdf",
+ "type": "output",
+ "content_type": "application/pdf",
+ "storage_path": "tasks/artifacts/team_1/task_2/run_3/report.pdf",
+ }
+ ],
+ )
+
+ response = self.client.get(
+ f"/api/projects/@current/tasks/{task.id}/runs/{run.id}/artifacts/{artifact_id}/download/"
+ )
+
+ self.assertEqual(response.status_code, status.HTTP_302_FOUND)
+ self.assertEqual(response["Location"], "https://example.com/artifact?sig=123")
+ self.assertEqual(mock_presign.call_args.kwargs["content_disposition"], 'attachment; filename="report.pdf"')
+
+ missing = self.client.get(
+ f"/api/projects/@current/tasks/{task.id}/runs/{run.id}/artifacts/{uuid.uuid4().hex}/download/"
+ )
+ self.assertEqual(missing.status_code, status.HTTP_404_NOT_FOUND)
+
def test_presign_artifact_not_found(self):
task = self.create_task()
run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.IN_PROGRESS, artifacts=[])
diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.ts
index 1265a7909047..a7831e164c04 100644
--- a/products/tasks/frontend/generated/api.schemas.ts
+++ b/products/tasks/frontend/generated/api.schemas.ts
@@ -1436,7 +1436,7 @@ export interface TaskRunArtifactResponseApi {
uploaded_at: string
/** Timestamp when a user dismissed the artifact. Absent while the artifact is shown. */
dismissed_at?: string
- /** Presigned download URL for the artifact. Populated on the finalize-upload response so the caller can link to the file directly; it is time-limited and not persisted on the manifest. */
+ /** Stable download URL for the artifact. Populated on the finalize-upload response so the caller can link to the file; it redirects to a fresh presigned URL on each request and is not persisted on the manifest. */
url?: string
}
diff --git a/products/tasks/frontend/generated/api.ts b/products/tasks/frontend/generated/api.ts
index 1b49b31d221a..d20c5ff4cbf3 100644
--- a/products/tasks/frontend/generated/api.ts
+++ b/products/tasks/frontend/generated/api.ts
@@ -1689,6 +1689,32 @@ export const tasksRunsArtifactsCreate = async (
})
}
+export const getTasksRunsArtifactsDownloadRetrieveUrl = (
+ projectId: string,
+ taskId: string,
+ id: string,
+ artifactId: string
+) => {
+ return `/api/projects/${projectId}/tasks/${taskId}/runs/${id}/artifacts/${artifactId}/download/`
+}
+
+/**
+ * Redirects to a short-lived presigned URL for the artifact, so callers can share a stable link instead of a raw presigned URL.
+ * @summary Download a task run artifact by id
+ */
+export const tasksRunsArtifactsDownloadRetrieve = async (
+ projectId: string,
+ taskId: string,
+ id: string,
+ artifactId: string,
+ options?: RequestInit
+): Promise<unknown> => {
+ return apiMutator<unknown>(getTasksRunsArtifactsDownloadRetrieveUrl(projectId, taskId, id, artifactId), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getTasksRunsArtifactsDismissCreateUrl = (projectId: string, taskId: string, id: string) => {
return `/api/projects/${projectId}/tasks/${taskId}/runs/${id}/artifacts/dismiss/`
}
diff --git a/products/tasks/mcp/tools.yaml b/products/tasks/mcp/tools.yaml
index 9e2f3da1229a..b780edb46a93 100644
--- a/products/tasks/mcp/tools.yaml
+++ b/products/tasks/mcp/tools.yaml
@@ -450,6 +450,9 @@ tools:
tasks-runs-artifacts-download-create:
operation: tasks_runs_artifacts_download_create
enabled: false
+ tasks-runs-artifacts-download-retrieve:
+ operation: tasks_runs_artifacts_download_retrieve
+ enabled: false
tasks-runs-artifacts-finalize-upload-create:
operation: tasks_runs_artifacts_finalize_upload_create
enabled: false
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 736bc91b3a9b..3599fd4c26c5 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -49957,7 +49957,7 @@ export namespace Schemas {
uploaded_at: string;
/** Timestamp when a user dismissed the artifact. Absent while the artifact is shown. */
dismissed_at?: string;
- /** Presigned download URL for the artifact. Populated on the finalize-upload response so the caller can link to the file directly; it is time-limited and not persisted on the manifest. */
+ /** Stable download URL for the artifact. Populated on the finalize-upload response so the caller can link to the file; it redirects to a fresh presigned URL on each request and is not persisted on the manifest. */
url?: string;
}