Repository navigation
feat(export): sample trace sessions as rows are read - #43
fergusfinn wants to merge 3 commits into
Conversation
`--sample-sessions FRACTION` (with `--dynamo-traces`) keeps that fraction of sessions and drops the other rows as they are read, before their block hashes are parsed. Memory then follows the sample, not the traffic. `--sample` thins trajectories only after every row is loaded, and a busy model's long prompts carry hundreds of hashes each. A row goes with its agent session id, else its x-request-id (retried attempts together), else its request id. Each key's draw comes from `--seed`, so for one seed a smaller fraction keeps a subset of a larger one, and manifests at several loads stay comparable. Dropped rows count as `sampled_out`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VDPqeFzGgF3vkuiyimwMxX
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/batchbench/dynamo_traces.py">
<violation number="1" location="src/batchbench/dynamo_traces.py:338">
P2: Rows with no sampling key are dropped at every fraction, including 1.0, so `--sample-sessions 1` does not reproduce the unsampled manifest. Keep keyless rows rather than sampling them out.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| continue | ||
| if sample_sessions is not None: | ||
| key = session_sample_key(row) | ||
| if key is None or not keeps_session(key, sample_sessions, seed): |
There was a problem hiding this comment.
P2: Rows with no sampling key are dropped at every fraction, including 1.0, so --sample-sessions 1 does not reproduce the unsampled manifest. Keep keyless rows rather than sampling them out.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/batchbench/dynamo_traces.py, line 338:
<comment>Rows with no sampling key are dropped at every fraction, including 1.0, so `--sample-sessions 1` does not reproduce the unsampled manifest. Keep keyless rows rather than sampling them out.</comment>
<file context>
@@ -293,6 +333,11 @@ def load_trace_records(
continue
+ if sample_sessions is not None:
+ key = session_sample_key(row)
+ if key is None or not keeps_session(key, sample_sessions, seed):
+ stats.sampled_out += 1
+ continue
</file context>
| if key is None or not keeps_session(key, sample_sessions, seed): | |
| if key is not None and not keeps_session(key, sample_sessions, seed): |
There was a problem hiding this comment.
Fixed in 5cd6c03: a row with no session, x_request_id or request_id is now drawn on its own line instead of being dropped, so --sample-sessions 1 keeps every row. Tested.
|
Virtual Fergus: reviewed, looks right. The key falls back from session to |
A session id is one wherever record_from_trace keeps it (anything but missing or empty), so a session of id 0 stays whole. A row with no session, x_request_id or request_id is drawn on its own line instead of being dropped at every fraction, so --sample-sessions 1 keeps every row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VDPqeFzGgF3vkuiyimwMxX
There was a problem hiding this comment.
1 existing issue remains and no new issues found across 3 files (changes from recent commits).
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
Virtual Fergus: re-reviewed at 5cd6c03. |
Stacked on #42 (itself stacked on #40).
--sample-sessions FRACTION(with--dynamo-traces) keeps that fraction of sessions and drops other rows as they are read, before their block hashes are parsed. The exporter holds every loaded row until it writes the manifest, and for a busy model with long prompts that is more than a machine has: one hour of one production model is about 95k rows, each with a few hundred hashes, and the default link window loads a day of them.--samplecannot help there, because it thins trajectories after everything is loaded.x_request_id, so a request's retried attempts go together, else with itsrequest_id. Such a row can lose the request it extends and then replays as a new trajectory, asdocs/export-plans.mdnow says.--seeda smaller fraction keeps a subset of a larger one. Manifests at several loads of the same window are then comparable.sampled_out.Tests: sessions are kept whole, fractions nest and differ across seeds, attempts without a session go together, and the CLI checks the fraction. 42 Python tests pass (2 need the compiled agent and skip here).
🤖 Generated with Claude Code
https://claude.ai/code/session_01VDPqeFzGgF3vkuiyimwMxX