Skip to content

feat(api): generate and migrate Prompt REST resources - #750

Merged
Abhijeet Prasad (AbhiPrasad) merged 3 commits into
mainfrom
abhi-openapi-prompts
Sep 9, 2026
Merged

feat(api): generate and migrate Prompt REST resources#750
Abhijeet Prasad (AbhiPrasad) merged 3 commits into
mainfrom
abhi-openapi-prompts

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

AI Summary

Implements the Prompt slice of #683 by publishing all six operations tagged Prompts and moving load_prompt() retrieval onto the public REST resources. Prompt request and response models are also exported through the public API.

Migration flow

Before
  load_prompt(id=...) ------> raw GET /v1/prompt/{id}
  load_prompt(slug=...) ----> raw GET /v1/prompt

After
  load_prompt(id=...) ------> generated GET /v1/prompt/{id}
  load_prompt(slug=...) ----> generated GET /v1/prompt
SDK workflow Previous wire call Public REST call
Load by ID Raw GET /v1/prompt/{id} Generated GET /v1/prompt/{id}
Behavior Result
Explicit credentials Use isolated, cached generated clients without mutating global login

Refs #683

### AI Summary

Implements the Prompt slice of #683 by publishing all six operations tagged
Prompts and moving `load_prompt()` retrieval onto the public REST resources.
Prompt request and response models are also exported through the public API.

### Migration flow

```text
Before
  load_prompt(id=...) ------> raw GET /v1/prompt/{id}
  load_prompt(slug=...) ----> raw GET /v1/prompt

After
  load_prompt(id=...) ------> generated GET /v1/prompt/{id}
  load_prompt(slug=...) ----> generated GET /v1/prompt
```

| SDK workflow | Previous wire call | Public REST call |
| --- | --- | --- |
| Load by ID | Raw `GET /v1/prompt/{id}` | Generated `GET /v1/prompt/{id}` |
| Load by project and slug | Raw `GET /v1/prompt` | Generated `GET /v1/prompt` |
| Prompt CRUD | No generated resource | `client.openapi.prompts` |

| Behavior | Result |
| --- | --- |
| Explicit credentials | Use isolated, cached generated clients without mutating global login |
| Active global login | Reuse the existing generated API client |
| Version and environment | Explicit version continues to take precedence over environment |
| Cache fallback | Preserve local prompt cache fallback for retryable server failures |
| Lazy and async loading | Continue deferring retrieval until the prompt is used |
| Prompt lookup by ID | Consume the direct response without a synthetic `objects` envelope |
| Retry behavior | GET operations are safe reads; version-producing writes are not retried |

VCR coverage exercises generated CRUD against the real backend and verifies that
high-level prompt loading uses the generated resources. Wire, model, packaging,
and type tests cover the public bindings.

Refs #683
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T23:35:35.156292Z 0cf0199 New commits
ℹ️ About Codex in GitHub

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

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 4cb34df177

ℹ️ 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

@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: 3022c67304

ℹ️ 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".

cache_namespace = login_options.cache_namespace
try:
with _state.loader_conn(login_options) as conn:
with _state.loader_api_client(login_options) as api_client:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the configured timeout for prompt loads

When BRAINTRUST_HTTP_TIMEOUT is set, this migration stops honoring it: the previous loader_conn() path created a long-lived HTTPConnection, whose make_long_lived() reads that setting, while the generated client's SAFE_READ policy always uses its hard-coded 20-second timeout. Users who lower the timeout to avoid stalled prompt retrievals can now wait up to the generated client's retry budget, and users who raise it for slow endpoints can fail prematurely; carry the configured timeout into this generated request path.

Useful? React with 👍 / 👎.

@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: 0cf0199b5f

ℹ️ 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".

cache_namespace = login_options.cache_namespace
try:
with _state.loader_conn(login_options) as conn:
with _state.loader_api_client(login_options) as api_client:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor timeouts configured by custom adapters

When callers install RetryRequestExceptionsAdapter(default_timeout_secs=...) (or an equivalent adapter that supplies a timeout when none is provided), switching prompt loading to the generated client ignores that setting: Transport.request() always passes a non-None policy timeout—20 seconds when BRAINTRUST_HTTP_TIMEOUT is unset—while this repository's adapter applies default_timeout_secs only when the supplied timeout is None. The legacy loader_conn() path allowed the adapter to provide its timeout. Fresh evidence after the earlier adapter finding is that _set_adapter() now mounts the adapter, but does not change the explicit timeout passed by the generated transport.

Useful? React with 👍 / 👎.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 744eccd into main Sep 9, 2026
83 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi-openapi-prompts branch September 9, 2026 01:56
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.

2 participants