fix(agent): poll for pending attachments before the first cloud turn#3409
Closed
posthog[bot] wants to merge 3 commits into
Closed
fix(agent): poll for pending attachments before the first cloud turn#3409posthog[bot] wants to merge 3 commits into
posthog[bot] wants to merge 3 commits into
Conversation
A pasted-text attachment could be missing on the first message of a new cloud session and only become readable after a second message. The first turn resolves pending attachments through the run's artifact manifest, which can momentarily lag the just-uploaded artifacts. The previous mitigation refetched the run once, which often still misses them when propagation takes longer than a single round trip. Poll the manifest a few times with a short backoff until every requested artifact is listed before building the initial prompt. Also add a bounded retry to artifact downloads so an object that isn't readable yet right after upload doesn't fail the turn. The second-message path is unaffected: it receives fully resolved artifact metadata directly and never consults the manifest. Generated-By: PostHog Code Task-Id: 76c08662-af28-426f-838b-fc11c313e48b
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Generated-By: PostHog Code Task-Id: 855ffa3f-1804-44a4-8ec4-63cd2bc8b018
Remove the speculative artifact download retry from the existing fix. The reported first-turn failure follows the stale run manifest path; retrying every download failure would also delay or mask authentication and client errors without addressing the confirmed race. Generated-By: PostHog Code Task-Id: 855ffa3f-1804-44a4-8ec4-63cd2bc8b018
Contributor
|
superseded by #3425 |
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
When a user pastes a long prompt into a new cloud session, the text is converted into a generated
pasted-text.txtattachment. On the first message, the agent can receive only the attachment summary and cannot read the file; the same file is available on a later turn.Why: the first turn resolves pending attachments from the run artifact manifest, which can briefly lag the upload finalization write. The existing single immediate refetch can still observe the stale manifest, especially for fast-starting sessions.
Changes
How did you test this?
pnpm --dir packages/agent exec vitest run src/server/agent-server.test.ts -t "AgentServer pending user attachments" --reporter=defaultpnpm --dir packages/agent exec vitest run src/posthog-api.test.ts --reporter=defaultpnpm --filter @posthog/agent typecheckgit diff --checkpass.AgentServer HTTP Modesuite cannot run in this environment because its fixture performs an unsignedgit commit, which is blocked; those tests are unrelated to this change.Automatic notifications
Created with PostHog Code