feat: execute() stamps its traces as eval traffic automatically - #34
Merged
Conversation
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>
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.
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.