Skip to content

[build-tools] Upload the last agent-device artifacts before the daemon stops - #4750

Draft
gwdp wants to merge 1 commit into
mainfrom
gwdp/agent-device-final-artifact-drain
Draft

gwdp wants to merge 1 commit into
mainfrom
gwdp/agent-device-final-artifact-drain

Conversation

@gwdp

@gwdp gwdp commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Why

The agent-device remote session checks the daemon for new artifacts every 5 seconds. When the session stops, the daemon stops right away, so an artifact created after the last check is never uploaded.

How

  • At a normal stop, the session ends polling and waits for one last inventory and upload pass before it stops the daemon.
  • The last pass has a 30-second limit. A job cancel stops it at once. The daemon stops even if the last pass fails.
  • The session keeps the poller promise, so a failed last pass is reported in teardown.

This PR shares agentDeviceArtifacts.ts and its test file with #4724. The files are byte-identical, so the diff of #4724 on these files becomes empty after this PR merges.

Test Plan

Claude Code ran these checks on bbbdee1: typecheck, lint and format check pass, and build-tools has 2526 tests passed, 8 skipped and 0 failed.

  • New tests fail on the old code and pass on this change.
  • Manual test on a remote session: planned.
New tests
  • uploads an artifact created after the last periodic inventory before the daemon stops
  • stops the daemon when the final artifact drain fails

Two suites that automock the poller now give it a resolved value: deviceSessionHost-orchestration.test.ts and remoteSessionLocalEgress.test.ts.

Authorship and LLM use

  • LLM involvement: primarily LLM-generated. Claude Code wrote the code, tests and this description.
  • Process: Gabe asked for the last artifact upload before the daemon stops, as a separate PR against main.
  • History: an AI review approved the change. The new tests failed on the old code before the fix.
  • Human involvement: Gabe set the direction.
  • Review status: human review pending; Gabe can answer questions.

Rollback

Revert this PR; the session then stops the daemon without the last upload pass.

Generated with T3 Code, using Claude Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gwdp

gwdp commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

@github-actions

Copy link
Copy Markdown

✅ Thank you for adding a changeset!

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment on lines +127 to 139
const error = err instanceof Error ? err : new Error(String(err));
listArtifactsErrorCount += 1;
// The final inventory has no later retry, so always report its failure.
if (finalInventory || listArtifactsErrorCount % 5 === 0) {
Sentry.capture('Could not list agent-device remote session artifacts', error);
logger.warn(
{ err: error, failedArtifactListCount: listArtifactsErrorCount },
'Could not list agent-device remote session artifacts.'
);
}
}
} catch (err) {
if (err instanceof AgentDeviceArtifactsUnsupportedError) {
logger.warn(
'agent-device daemon does not expose artifact inventory; remote session artifact uploads are disabled.'
);
if (finalInventory) {
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Final-pass failures use poller diagnostics

A failed final inventory is logged and sent to Sentry, but its caught error never reaches teardown. The claimed teardown reporting applies only to unexpected poller rejections.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.57%. Comparing base (d02de4d) to head (bbbdee1).

Files with missing lines Patch % Lines
...uild-tools/src/steps/utils/agentDeviceArtifacts.ts 96.73% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4750      +/-   ##
==========================================
+ Coverage   75.55%   75.57%   +0.02%     
==========================================
  Files        1053     1053              
  Lines       52399    52442      +43     
  Branches    11442    11459      +17     
==========================================
+ Hits        39587    39629      +42     
- Misses      11831    11832       +1     
  Partials      981      981              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant