Skip to content

feat(agent): tell cloud agents to upload deliverables as artifacts - #3944

Merged
trunk-io[bot] merged 4 commits into
mainfrom
posthog-code/artifact-upload-system-prompt
Jul 31, 2026
Merged

feat(agent): tell cloud agents to upload deliverables as artifacts#3944
trunk-io[bot] merged 4 commits into
mainfrom
posthog-code/artifact-upload-system-prompt

Conversation

@puemos

@puemos puemos commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Cloud agents can create downloadable files but leave them only in the workspace, making those deliverables inaccessible to users. Even after uploading a file, an agent may reference its local path instead of the working download URL.

Changes

  • Tell cloud agents to upload non-code file deliverables before their final response.
  • Require the final response to link the download URL returned by upload_artifact, never the local workspace path.
  • Keep source code and repository changes in commits and pull requests.

Why: Users should receive a working download link whenever an agent produces a file, without needing to remind the agent how to deliver it.

How did you test this?

  • git diff --check
  • Biome and the agent typecheck could not run in this fresh clone because dependencies are not installed.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

@trunk-io

trunk-io Bot commented Jul 29, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@posthog

posthog Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Done. Opened #3944 (draft) in posthog/code.

What the tool is: upload_artifact (mcp__posthog-code-tools__upload_artifact) is a cloud-only local tool that uploads a file from the session workspace to PostHog storage so it shows up in the user's artifact panel as a download. It's already gated to cloud sessions with a live task run, and its own description says to call it for non-code deliverables — but nothing in the system prompt reinforced that, so the agent only did it when told.

The change: added a "Delivering non-code files (artifacts)" section to the cloud task system prompt (agent-server.ts) telling the agent to call upload_artifact for reports, images, rendered canvases, data files, etc. before its final reply — and not for source/repo changes. It's skipped for Slack-origin sessions, since those get a runtime "no artifact delivery" constraint instead (this very session is one). Also exported UPLOAD_ARTIFACT_QUALIFIED_TOOL_NAME so the prompt references the tool id from one source, matching the signed-commit pattern.

I put it in the cloud prompt rather than the base desktop instructions on purpose — the tool doesn't exist in local desktop sessions, so a global instruction would reference a missing tool.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit ecc0aba.

@posthog

posthog Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Visual changes approved by @puemos — baseline updated in f8ef7a6.

View this run in PostHog

8 new.

Comment thread packages/agent/src/adapters/local-tools/tools/upload-artifact.ts Outdated
Comment thread packages/agent/src/server/agent-server.ts Outdated
Comment thread packages/agent/src/server/agent-server.ts Outdated
@puemos
puemos requested a review from k11kirky July 29, 2026 15:05
@k11kirky
k11kirky marked this pull request as ready for review July 30, 2026 16:07
puemos added 3 commits July 31, 2026 10:46
Add guidance to the cloud task system prompt instructing the agent to call
the `upload_artifact` tool for non-code deliverables (reports, images,
rendered canvases, data files) so they appear in the user's artifact panel as
downloads, rather than being left in the workspace where the user can't see
them.

The instruction is appended to every cloud system-prompt branch and skipped
for Slack-origin sessions, which get a runtime "no artifact delivery"
constraint. Exposes UPLOAD_ARTIFACT_QUALIFIED_TOOL_NAME from the tool module,
mirroring the signed-commit tool-name constants, so the prompt references the
qualified tool id from a single source.

Generated-By: PostHog Code
Task-Id: 887b21b0-78b0-4741-be7c-1f0e456f926a
Address review feedback from @k11kirky: drop the exported UPLOAD_ARTIFACT
tool-name constants (revert upload-artifact.ts to referencing the literal
name), remove the verbose explanatory code comment, and tighten the
artifact-delivery prompt prose. The instruction now references the
`upload_artifact` tool by its short name.

Generated-By: PostHog Code
Task-Id: 887b21b0-78b0-4741-be7c-1f0e456f926a
Address review feedback from @puemos: drop the Slack gating so the
artifact-delivery instruction appears in every cloud session. Sessions that
genuinely can't deliver artifacts already get a runtime constraint that
overrides the prompt.

Generated-By: PostHog Code
Task-Id: 887b21b0-78b0-4741-be7c-1f0e456f926a
@puemos
puemos force-pushed the posthog-code/artifact-upload-system-prompt branch from f8ef7a6 to 71fd26f Compare July 31, 2026 08:46
Comment thread packages/agent/src/server/agent-server.ts Outdated
Generated-By: PostHog Code
Task-Id: 842d598b-48cc-4059-8fed-18a9965a71c4
@trunk-io
trunk-io Bot merged commit 1fac094 into main Jul 31, 2026
34 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/artifact-upload-system-prompt branch July 31, 2026 12:56
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.

3 participants