Skip to content

feat: execute() stamps its traces as eval traffic automatically - #34

Merged
RobinXL merged 1 commit into
mainfrom
feat/eval-traffic-separation
Aug 26, 2026
Merged

feat: execute() stamps its traces as eval traffic automatically#34
RobinXL merged 1 commit into
mainfrom
feat/eval-traffic-separation

Conversation

@RobinXL

@RobinXL RobinXL commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

The burden used to sit on every caller: remember monitor=False on every tracer.trace() inside an evaluation, or the engine double-judged each case, raised signals on synthetic questions, and counted the run's latencies into production KPIs. Nobody remembered - including our own samples, including the sample written by the person who wrote the rule.

execute() now enters an eval-run scope (tracing/eval_scope.py, a contextvar so it nests and cannot leak across concurrent runs). While it is active every trace the tracer sends - roots and child spans - is stamped source="eval-run", monitor=False, and metadata.evalRunId, so a trace can always be walked back to the run that produced it. An explicit monitor=True is respected: deliberately pointing checks at eval traffic is a choice, not a mistake.

Known limit, documented in the module: a bare Thread() the agent function spawns itself does not inherit the contextvar - same posture as the tracer's existing user-managed-thread caveats.

Six tests pin the contract: no-op outside the scope, full stamp inside, explicit monitor=True wins, child spans stamped, no leak after exit, caller metadata survives the merge.

The burden used to sit on every caller: remember monitor=False on every
tracer.trace() inside an evaluation, or the engine double-judged each
case, raised signals on synthetic questions, and counted the run's
latencies into production KPIs. Nobody remembered - including our own
samples, including the sample written by the person who wrote the rule.

execute() now enters an eval-run scope (tracing/eval_scope.py, a
contextvar so it nests and cannot leak across concurrent runs). While
it is active every trace the tracer sends - roots and child spans - is
stamped source="eval-run", monitor=False, and metadata.evalRunId, so a
trace can always be walked back to the run that produced it. An
explicit monitor=True is respected: deliberately pointing checks at
eval traffic is a choice, not a mistake.

Known limit, documented in the module: a bare Thread() the agent
function spawns itself does not inherit the contextvar - same posture
as the tracer's existing user-managed-thread caveats.

Six tests pin the contract: no-op outside the scope, full stamp inside,
explicit monitor=True wins, child spans stamped, no leak after exit,
caller metadata survives the merge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@RobinXL
RobinXL merged commit 7de63ac into main Aug 26, 2026
3 checks passed
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