: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): hide internal artifacts from task timeline (#83102)
Shy Alterdd328aae2077
diff --git a/products/desktop/packages/core/src/canvas/activityEvents.ts b/products/desktop/packages/core/src/canvas/activityEvents.tsindex 94a9d579451f..80c552e1a7b3 100644--- a/products/desktop/packages/core/src/canvas/activityEvents.ts+++ b/products/desktop/packages/core/src/canvas/activityEvents.ts@@ -26,6 +26,18 @@ export type ActivityEventKind = (typeof ACTIVITY_EVENTS)[number];const ACTIVITY_EVENT_SET: ReadonlySet<string> = new Set(ACTIVITY_EVENTS);+const RUN_ARTIFACT_TYPES_WITHOUT_TIMELINE_EVENTS: ReadonlySet<string> = new Set(+ [+ "plan",+ "context",+ "reference",+ "artifact",+ "tree_snapshot",+ "user_attachment",+ "skill_bundle",+ ],+);+export interface RunStartedPayload {runId: string;environment: string;@@ -202,8 +214,12 @@ export function parseActivityEvent(message: {case "awaiting_input":return { kind: event, payload: { runId: str(payload.run_id) } };case "artifact_created":- case "artifact_revised":- return { kind: event, payload: artifactPayload(payload) };+ case "artifact_revised": {+ const parsed = artifactPayload(payload);+ return RUN_ARTIFACT_TYPES_WITHOUT_TIMELINE_EVENTS.has(parsed.artifactType)+ ? null+ : { kind: event, payload: parsed };+ }case "canvas_created":return {kind: event,diff --git a/products/desktop/packages/core/src/canvas/activityTimeline.test.ts b/products/desktop/packages/core/src/canvas/activityTimeline.test.tsindex a0a8925f6b40..269fc1b6663a 100644--- a/products/desktop/packages/core/src/canvas/activityTimeline.test.ts+++ b/products/desktop/packages/core/src/canvas/activityTimeline.test.ts@@ -322,6 +322,30 @@ describe("activity events", () => {});});+ it.each([+ "plan",+ "context",+ "reference",+ "artifact",+ "tree_snapshot",+ "user_attachment",+ "skill_bundle",+ ])(+ "drops non-output %s artifacts from historical timelines",+ (artifactType) => {+ expect(+ parseActivityEvent({+ event: "artifact_created",+ payload: {+ artifact_id: "internal-1",+ name: "checkpoint.index",+ artifact_type: artifactType,+ },+ }),+ ).toBeNull();+ },+ );+it("drops a pull request event with no url, since it can't be opened", () => {expect(parseActivityEvent({ event: "pr_merged", payload: {} })).toBeNull();});diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.pyindex 3daa5f1bd346..30f39c5bd0b0 100644--- a/products/tasks/backend/facade/api.py+++ b/products/tasks/backend/facade/api.py@@ -7222,15 +7222,22 @@ def post_comment_thread_update(*, team_id: int, comment_id: UUID) -> None:def _announce_agent_artifact_uploads(run: TaskRun, new_entries: list[dict], manifest: list[dict]) -> None:- """Manifest entries carry no version, so an announcement counts same-named entries:- re-uploading a file reads as a revision of it, the way the artifacts list groups- versions. The artifact_id dedup absorbs a retried upload."""- new_ids = {entry.get("id") for entry in new_entries}+ """Announce files the agent delivered as task outputs.++ The manifest also holds internal state such as git handoff checkpoints and skill+ bundles. Those files support the run but are not deliverables for the timeline.+ Manifest entries carry no version, so same-named output entries determine whether+ an upload created or revised a file. The artifact id deduplicates retried uploads.+ """+ output_entries = [entry for entry in new_entries if entry.get("type") == "output"]+ new_output_ids = {entry.get("id") for entry in output_entries}announced_in_batch: dict[str, int] = {}- for entry in new_entries:+ for entry in output_entries:name = entry.get("name")prior_versions = sum(- 1 for other in manifest if other.get("name") == name and other.get("id") not in new_ids+ 1+ for other in manifest+ if other.get("type") == "output" and other.get("name") == name and other.get("id") not in new_output_ids) + announced_in_batch.get(name or "", 0)announced_in_batch[name or ""] = announced_in_batch.get(name or "", 0) + 1post_artifact_thread_update(diff --git a/products/tasks/backend/tests/test_thread_updates.py b/products/tasks/backend/tests/test_thread_updates.pyindex 0ab84aa0350d..bbd9ae9a7fb0 100644--- a/products/tasks/backend/tests/test_thread_updates.py+++ b/products/tasks/backend/tests/test_thread_updates.py@@ -224,19 +224,29 @@ class TestAgentThreadUpdates(TestCase):@patch("posthog.storage.object_storage.tag")@patch("posthog.storage.object_storage.write")@patch(_FLAG_TARGET, return_value=True)- def test_inline_agent_upload_announces_created_then_revised(self, _flag, _write, _tag) -> None:+ def test_inline_agent_upload_only_announces_output_versions(self, _flag, _write, _tag) -> None:from products.tasks.backend.facade.api import upload_task_run_artifacts- artifact = {"name": "summary.md", "type": "output", "content_bytes": b"v1", "content_type": "text/markdown"}+ output = {"name": "summary.md", "type": "output", "content_bytes": b"v1", "content_type": "text/markdown"}+ checkpoint = {+ "name": "checkpoint.index",+ "type": "artifact",+ "content_bytes": b"internal state",+ "content_type": "application/octet-stream",+ }with team_scope(self.team.id):upload_task_run_artifacts(- self.task_run.id, self.task.id, self.team.id, artifacts=[artifact], uploaded_by="agent"+ self.task_run.id,+ self.task.id,+ self.team.id,+ artifacts=[output, checkpoint],+ uploaded_by="agent",)upload_task_run_artifacts(self.task_run.id,self.task.id,self.team.id,- artifacts=[{**artifact, "content_bytes": b"v2"}],+ artifacts=[{**output, "content_bytes": b"v2"}],uploaded_by="agent",)