feat(api): generate and migrate Prompt REST resources - #750
Conversation
### 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
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
💡 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: |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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: |
There was a problem hiding this comment.
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 👍 / 👎.
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
GET /v1/prompt/{id}GET /v1/prompt/{id}Refs #683