feat(ci): add RunnerContext and RegressionError for experiment GH action#1635
Draft
feat(ci): add RunnerContext and RegressionError for experiment GH action#1635
Conversation
Adds the SDK-side primitives consumed by the upcoming `langfuse/experiment-action` GitHub Action (LFE-9241): - `RunnerContext` wraps `Langfuse.run_experiment` with action-injected defaults (data, dataset_version, name, run_name, metadata). Users can override any default on the call site; metadata is merged with user-supplied keys winning on collision. - `RegressionError` lets users signal a CI gate failure and optionally pass structured `metric`/`value`/`threshold` fields so the action can render a callout in the PR comment. Both live in a dedicated `langfuse/ci.py` module so the CI surface stays isolated from the general experiment API. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Adds the SDK-side primitives consumed by the upcoming
langfuse/experiment-actionGitHub Action (LFE-9241).RunnerContextwrapsLangfuse.run_experimentwith action-injected defaults (data,dataset_version,name,run_name,metadata). Users can override any default on the call site;metadatais merged with user-supplied keys winning on collision. Supports bothLocalExperimentItemandDatasetItem.RegressionErrorlets a user'sexperimentfunction signal a CI gate failure. Exposes optional structuredmetric/value/thresholdfields so the action can render a targeted callout in the PR comment; falls back to a free-formmessageor a default string.Both live in a dedicated
langfuse/ci.pymodule so the CI surface stays isolated from the general experiment API.Usage (from the proposal)
Test plan
tests/unit/test_ci.pycovering:Langfuse.run_experimentLocalExperimentItempass-through (both default and override paths)ValueErrorwhenname/dataare missing on both sidesRegressionErrorattributes, default message, structured message, user-message precedenceinspect.signaturethat fails loudly ifLangfuse.run_experimentgrows a param not threaded throughRunnerContext.run_experimentpython -c "from langfuse import RunnerContext, RegressionError"resolvesOut of scope
langfuse/experiment-actionGitHub Action itselfregressions: List[Regression]later)🤖 Generated with Claude Code