Skip to content

feat(api): generate Experiments REST bindings - #701

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi-openapi-experiments
Aug 18, 2026
Merged

feat(api): generate Experiments REST bindings#701
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi-openapi-experiments

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Aug 18, 2026

Copy link
Copy Markdown
Member

Implements step 3 of #683 and fixes #639.

AI Summary

This adds the second public generated REST resource:

  • BraintrustOpenApiClient.experiments: all 10 operations selected by the Experiments OpenAPI tag, including get_experiment_id_summarize
  • braintrust.api.types: public experiment request and response types

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9c2512bcc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/logger.py
Comment thread py/src/braintrust/logger.py
Implements step 3 of #683 and fixes #639.

This adds the second public generated REST resource:

- `BraintrustOpenApiClient.experiments`: all 10 operations selected by the
  Experiments OpenAPI tag, including `get_experiment_id_summarize`
- `braintrust.api.types`: public experiment request and response types

Codegen now partitions models across multiple resources. Models reached by
one resource remain in its resource-specific module, while shared definitions
are emitted once in `models/common.py` and imported explicitly. Against the
pinned specification, Projects plus Experiments generates 15 operations and
45 reachable component schemas. Logical POST reads use a reviewed
`safe_reads` allowlist, while generated GETs retain mechanical `SAFE_READ`
classification and writes remain non-retrying unless explicitly classified.

`Experiment.summarize()` now uses the generated summarize binding. Successful
and intentionally skipped summaries are represented by `SummarySuccess` and
`SummarySkipped`, with `comparison` as the primary result. The deprecated
read-only `scores` and `metrics` bridges remain serialized for compatibility.
Summary retrieval errors are no longer swallowed: transient failures retry
through the policy-aware transport and final failures raise typed API errors.
Structured summaries support tagged deep deserialization and legacy payloads
containing only top-level score and metric maps.

Coverage includes deterministic multi-resource codegen, retry-policy
validation, exact wire behavior for all generated Experiments methods,
additive responses, retry exhaustion, framework propagation, static and
runtime typing, structured-summary round trips, and real-backend VCR flows for
implicit and explicit comparison selection.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd49da87f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/logger.py
Comment thread openapi/config.json
Comment on lines +33 to +34
"Projects",
"Experiments"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I understand correctly, I wonder if we will ever leak unwanted endpoints into the generated client

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or accidentally remove endpoints because someone removed the tag and break them

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the allowlist this way so that we very explicitly add only the endpoints we want to the generated client.

Removing tags should also break tests so I'm not too worried about that.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 5eb6251 into main Aug 18, 2026
83 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi-openapi-experiments branch August 18, 2026 15:31
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.

Experiment.summarize() silently discards scores/metrics on any fetch failure instead of surfacing or retrying

2 participants