Repository navigation
feat(website): record a website env's traffic as PCAP, served through traffic/v1 (FD-4683) - #469
Open
williamloo-scale wants to merge 5 commits into
Open
williamloo-scale wants to merge 5 commits into
williamloo-scale wants to merge 5 commits into
Conversation
williamloo-scale
force-pushed
the
wloo/website-computer-routing
branch
from
November 3, 2026 22:52
a767a25 to
d160d31
Compare
williamloo-scale
force-pushed
the
wloo/website-traffic-capture
branch
from
November 3, 2026 22:52
194572e to
3b757da
Compare
williamloo-scale
force-pushed
the
wloo/website-computer-routing
branch
from
November 3, 2026 23:53
d160d31 to
5953d5a
Compare
williamloo-scale
force-pushed
the
wloo/website-traffic-capture
branch
from
November 4, 2026 00:00
3b757da to
73241f9
Compare
williamloo-scale
force-pushed
the
wloo/website-computer-routing
branch
from
November 4, 2026 00:32
5953d5a to
9f2a5ca
Compare
williamloo-scale
force-pushed
the
wloo/website-traffic-capture
branch
from
November 4, 2026 00:33
73241f9 to
0192f08
Compare
williamloo-scale
force-pushed
the
wloo/website-traffic-capture
branch
from
November 4, 2026 01:06
0192f08 to
77c1ede
Compare
williamloo-scale
force-pushed
the
wloo/website-computer-routing
branch
from
November 4, 2026 01:06
9f2a5ca to
4283738
Compare
… traffic/v1 (FD-4683) This PR's change, rebased as one commit onto #448. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…refix of its own, and capture loopback too (FD-4683) - The gateway's traffic/v1 get copies a capture before sending any of it, copying again when tcpdump truncates the file to reuse it, and answers 503 when every copy was rewritten. - collect_traffic_capture writes each collection under its own attempt prefix, and the upload owns its temp file (finish_on_thread), so a cancelled collection never removes a file an upload still reads. - tcpdump captures every interface of the container, its loopback among them. - The read size and error limits are named. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… the env closes (FD-4683) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…collects a retry's rolled-back deployments too (FD-4683) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…time runs out partway (FD-4683) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
williamloo-scale
force-pushed
the
wloo/website-computer-routing
branch
from
November 4, 2026 01:30
4283738 to
0cca3db
Compare
williamloo-scale
force-pushed
the
wloo/website-traffic-capture
branch
from
November 4, 2026 01:30
77c1ede to
965deb7
Compare
Comment on lines
+166
to
+169
| artifact = None | ||
| if files: | ||
| universe = FileArtifactUniverse.put(id=universe_id, file_artifacts=files) | ||
| artifact = {"id": universe.id, "version": universe.version} |
There was a problem hiding this comment.
Partial captures lose their links
_store saves the universe and its run reference only after every capture finishes. If teardown times out during a later download or upload, files already uploaded remain without a universe or run reference. The finally in collect_uncollected_captures saves only completed environment entries, so it cannot preserve these files. Teardown then removes the VM, preventing another attempt.
Save each completed file's reference as collection progresses, and preserve partial results when collection stops.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/task_step/task_steps/traffic_capture.py
Line: 166-169
Comment:
**Partial captures lose their links**
`_store` saves the universe and its run reference only after every capture finishes. If teardown times out during a later download or upload, files already uploaded remain without a universe or run reference. The `finally` in `collect_uncollected_captures` saves only completed environment entries, so it cannot preserve these files. Teardown then removes the VM, preventing another attempt.
Save each completed file's reference as collection progresses, and preserve partial results when collection stops.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.This branch has not been deployed
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.
Stacked on #448.
A website env can record every packet its websites' server and frontend containers send and receive, as PCAP, and serve the files through its card. This is opt-in.
Turning it on:
deploy_envtakescapture_traffic, andagent-env env deploytakes--capture-traffic. It works for a website env, or a multi env with a website, on a VM. Any other env, and container mode, refuse it.Capture: each website container gets a tcpdump service beside it.
network_mode: "service:<container>").NET_RAW/NET_ADMIN.Protocol: the new
agentenv_protocol.trafficdefinesurn:agentenv:traffic/v1with two ops:listreturns aTrafficCaptureListing, oldest file first;getstreams one file asapplication/vnd.tcpdump.pcap.Client helpers:
list_traffic_captures,fetch_traffic_capture,serves_traffic. The gateway'sconstants.pymirrors the names, with a test keeping them equal.Access: both ops require the per-deploy control token (
DeployedEnv.control_token). The gateway removesAuthorizationfrom a proxied request only when it carries that token (compared withhmac.compare_digest), so no site can read the token, and a site's own bearer auth still reaches it.Collection: the new
collect_traffic_capturestep stores each capture as a pcapFileArtifactin oneFileArtifactUniverse, recorded undercontext.metadata["traffic_captures"][env_id]. It's best effort unlessfail_task_on_erroris set. Teardown also collects any capturing env the run didn't collect, before the env closes, so a capture isn't lost with its VM.Before merging
Test
Unit suite on this branch: 13,358 passed, lint clean. One GitHub-clone test from main is deselected because it hangs on the local machine on main too.
🤖 Generated with Claude Code
Preserve partial capture results before merging so teardown cannot discard links to files it already uploaded.
Fix with agent prompt
Summary
Adds opt-in website traffic capture through tcpdump services and the
traffic/v1protocol.The previous-review ancestry check failed, and the two revisions have different merge bases with the target. This review therefore used the full PR diff. All supplied previous threads were unnumbered and were not reposted.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR W[Website container] --> T[tcpdump in shared network namespace] T --> V[Rotating PCAP volume] V --> G[Gateway read-only mount] G -->|traffic/v1 with control token| C[Capture collection] C --> F[File artifacts] F --> U[File artifact universe] U --> R[Stored run metadata]Reviews (6) · Last reviewed commit: "fix(website): teardown saves the capture..." · Reviewed by Greptile