fix(agent): recover or flag pending attachments that fail to reach the cloud agent#3039
Merged
fercgomes merged 2 commits intoJul 2, 2026
Merged
Conversation
…e cloud agent Pasted text in a cloud task is uploaded as a run artifact and read by the sandbox agent from .posthog/attachments. When the run's artifact manifest does not yet list the just-uploaded pending_user_artifact_ids, getPendingUserPrompt returned null and sendInitialTaskMessage fell back to task.description — the bare "Attached files: pasted-text.txt" summary — handing the agent a prompt that names a file it was never given. Harden getPendingUserPrompt: - Refetch the run manifest once when a declared attachment isn't listed yet, so a transient lag doesn't drop the attachment. - If an attachment still can't be hydrated, append an explicit "didn't come through, ask the user to re-send" notice instead of the misleading description. Skill bundles (installed silently) are excluded from the check. - Log a warning with resolved/expected counts so a consistent failure is visible. Closes GROW-99 Generated-By: PostHog Code Task-Id: 62e30413-5b19-4752-9520-b0e772c462ce
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(agent): recover or flag pending atta..." | Re-trigger Greptile |
…etch resolve Review feedback (Greptile): getArtifactsById logs a per-id warning for each unresolved id, and the new refetch path calls it twice, so a genuinely missing artifact produced two identical low-level warnings on top of the high-level summary. Add a warnOnMissing option (default true) and pass false on the speculative pre-refetch resolve, where a miss is expected and is exactly what triggers the refetch. Generated-By: PostHog Code Task-Id: 62e30413-5b19-4752-9520-b0e772c462ce
Contributor
|
Reviews (2): Last reviewed commit: "fix(agent): avoid duplicate "missing art..." | Re-trigger Greptile |
tatoalo
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes GROW-99
Pasting a prompt into PostHog Code auto-converts it to a
pasted-text.txtattachment. On cloud tasks the file is uploaded as a run artifact and the sandbox agent reads it from.posthog/attachments/…. Intermittently the agent instead received the bare task descriptionAttached files: pasted-text.txtas plain text — no file, no inline content — and replied that it "can't find the file… no text was included inline", unable to do the task. (The task title also stayed Untitled.)Root cause
In
agent-server.ts → sendInitialTaskMessage, whengetPendingUserPrompt()returnsnull(no pending message and no resolvable artifacts) it falls back totask.description. For a pasted-text-only task that description is just theAttached files: …summary, so the agent is handed a prompt naming a file it was never given. The artifact fails to resolve when the run'sartifactsmanifest doesn't yet contain the just-uploadedpending_user_artifact_ids— most likely a transient manifest lag at run start.Fix
Hardened
getPendingUserPrompt:warn("Pending user attachments could not be loaded", …)log with resolved/expected counts, so a consistent failure (artifact genuinely missing server-side) is obvious in run logs.The misleading
task.descriptionfallback insendInitialTaskMessageis now bypassed for this case, and the resume paths benefit too since they sharegetPendingUserPrompt.Tests
New
AgentServer pending user attachmentssuite inagent-server.test.ts:nullresource_linkblock, no noticenull, and no refetchTypecheck and Biome are clean.
Notes
taskRun.artifactsserver-side.Closes GROW-99