|
| 1 | +# Agents |
| 2 | + |
| 3 | +## Fern SDK Regeneration |
| 4 | + |
| 5 | +### Overview |
| 6 | + |
| 7 | +This SDK is generated by [Fern](https://buildwithfern.com/). Most files under `src/deepgram/` are auto-generated and should not be edited directly. Some files have manual patches (custom auth, type fixes, WebSocket defaults, etc.) and are listed in `.fernignore` to prevent the generator from overwriting them. |
| 8 | + |
| 9 | +When a new Fern generator release is available, we prepare the repo so the generator can overwrite previously-frozen files, then re-apply manual patches after reviewing the diff. |
| 10 | + |
| 11 | +### Files that may be frozen in `.fernignore` |
| 12 | + |
| 13 | +These are the files that typically carry manual patches and get frozen between regenerations: |
| 14 | + |
| 15 | +**Client & Socket Clients:** |
| 16 | +- `src/deepgram/client.py` — Bearer token auth + session ID injection |
| 17 | +- `src/deepgram/speak/v1/socket_client.py` — optional message param defaults, broad exception catch |
| 18 | +- `src/deepgram/listen/v1/socket_client.py` — same as above + `construct_type` for unknown WS messages |
| 19 | +- `src/deepgram/listen/v2/socket_client.py` — same as above |
| 20 | +- `src/deepgram/agent/v1/socket_client.py` — same as above + `_sanitize_numeric_types` |
| 21 | + |
| 22 | +**Type Fixes (Fern generates float where API returns int):** |
| 23 | +- `src/deepgram/types/listen_v1response_results_utterances_item.py` |
| 24 | +- `src/deepgram/types/listen_v1response_results_utterances_item_words_item.py` |
| 25 | +- `src/deepgram/types/listen_v1response_results_channels_item_alternatives_item_paragraphs_paragraphs_item.py` |
| 26 | + |
| 27 | +**Redact type (Union[str, Sequence[str]] support):** |
| 28 | +- `src/deepgram/types/listen_v1redact.py` |
| 29 | + |
| 30 | +**Listen Clients (array param support):** |
| 31 | +- `src/deepgram/listen/v1/client.py` |
| 32 | +- `src/deepgram/listen/v2/client.py` |
| 33 | + |
| 34 | +**Tests & WireMock:** |
| 35 | +- `tests/wire/test_listen_v1_media.py` — manual fix for `transcribe_file()` bytes param |
| 36 | +- `wiremock/wiremock-mappings.json` — removed duplicate stub causing non-deterministic matching |
| 37 | + |
| 38 | +**Always frozen (never unfreeze for regen):** |
| 39 | +- `tests/custom/test_text_builder.py`, `tests/custom/test_transport.py` — hand-written tests |
| 40 | +- `tests/manual/` — manual standalone tests |
| 41 | +- `README.md`, `CHANGELOG.md`, `CONTRIBUTING.md`, `reference.md` — docs |
| 42 | +- `src/deepgram/helpers/` — TextBuilder helpers |
| 43 | +- `src/deepgram/transport_interface.py`, `src/deepgram/transport.py`, `src/deepgram/transports/` — custom transport support |
| 44 | +- `.github/`, `docs/`, `examples/` — folders |
| 45 | + |
| 46 | +### Prepare repo for regeneration |
| 47 | + |
| 48 | +1. **Create a new branch** off `main` named `lo/sdk-gen-<YYYY-MM-DD>`. |
| 49 | +2. **Push the branch** and create a PR titled `chore: SDK regeneration <YYYY-MM-DD>` with an empty commit if needed. |
| 50 | +3. **Identify frozen generated files** in `.fernignore` (the files listed above under Client, Type Fixes, Redact, Listen Clients, Tests & WireMock — NOT the "always frozen" files). |
| 51 | +4. **Back up each file** as `<filename>.bak` alongside the original. |
| 52 | +5. **Remove their entries** (and associated comments) from `.fernignore`. |
| 53 | +6. **Commit** as `chore: unfreeze files pending regen` and push. |
| 54 | +7. The branch is now ready for the Fern generator to push changes. |
| 55 | + |
| 56 | +### After regeneration |
| 57 | + |
| 58 | +The `.bak` files are our manually-patched versions. The newly generated files replace them. By comparing the two, we can see what the generator now produces vs what we had patched. |
| 59 | + |
| 60 | +1. **Diff each `.bak` file against the new generated version** (e.g., `diff src/deepgram/client.py.bak src/deepgram/client.py`) to understand what changed and whether our patches are still needed. |
| 61 | +2. **Re-apply any patches** that are still necessary to the newly generated files. |
| 62 | +3. **Re-add entries to `.fernignore`** for any files that still need manual patches. |
| 63 | +4. **Delete `.bak` files** once review is complete. |
| 64 | +5. **Run tests** (`pytest`) and linting (`ruff check`, `mypy`) to verify. |
| 65 | +6. **Commit** as `chore: re-apply manual patches after regen` and push. |
0 commit comments