Repository navigation
refactor(observability): consolidate model-call capture into base_responses_api_model - #1993
Merged
bxyu-nvidia merged 1 commit intoJul 10, 2026
Conversation
…es_api_mode.py. Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Contributor
|
🌿 Preview your docs: https://nvidia-preview-ffrujeri-model-server-observability.docs.buildwithfern.com/nemo/gym Here are the markdown pages you've updated: |
bxyu-nvidia
merged commit Jul 10, 2026
b0607fa
into
feat/model-server-observability
19 checks passed
Glorf
pushed a commit
that referenced
this pull request
Jul 14, 2026
…ponses_api_model (#1993) ## Summary Merges `nemo_gym/model_call_capture.py` and `nemo_gym/observability.py` into `nemo_gym/base_responses_api_model.py` and deletes both modules. Pure consolidation — the code moved verbatim, no behavior changes. The model server is where capture lives: `SimpleResponsesAPIModel` installs the middleware, the middleware writes the store, and the record/aggregation helpers read what the middleware wrote. Splitting that across three modules added indirection without a real seam, so everything now has a single home. ## Changes **`nemo_gym/base_responses_api_model.py`** now contains, in reading order: 1. Model server base classes (`SimpleResponsesAPIModel` etc.) — unchanged. 2. Capture configuration + rollout-keyed storage (`ModelCallCaptureConfig`, `CaptureStore`). 3. Observability records (`ModelCallRecord`, token/cache normalization, read/aggregate helpers). 4. Capture middleware (SSE terminal-event handling, streamed-response reconstruction, `_CaptureMiddleware`, `install_model_call_capture`). 5. Run-level helpers used by rollout collection (`model_call_capture_dirs_from_config`, `clear_model_call_captures_for_rollouts`, `merge_model_call_capture_into_record`). **Deleted:** `nemo_gym/model_call_capture.py`, `nemo_gym/observability.py`. **Import sites updated:** - `nemo_gym/rollout_collection.py` — imports the run-level helpers from the new home. - `nemo_gym/server_utils.py` — comment pointing at `observability.py` updated. - `tests/unit_tests/test_observability.py` → renamed to `tests/unit_tests/test_base_responses_api_model_capture.py` (it tests the capture feature of the merged module; `test_base_responses_api_model.py` already covers the server classes), all imports and `monkeypatch` targets rewritten. - `responses_api_models/openai_model/tests/test_app.py` and `fern/versions/latest/pages/model-server/model-call-capture.mdx` — import paths updated. One incidental cleanup: dropped `from __future__ import annotations` (present in the old modules). The repo is Python 3.12+ so it's unnecessary, and PEP 563 string annotations can interact badly with FastAPI's runtime annotation evaluation on the endpoint signatures that now share the module. ## Notes for review - No circular imports: `base_responses_api_model`'s dependencies (`anthropic_converter`, `openai_utils`, `server_utils`) never import `rollout_collection`, so rollout collection importing the model-server module is safe. - The run-level helpers (section 5) are consumed by rollout collection rather than the model server itself, but they read the store and record shapes defined right above them — keeping them co-located beats scattering them into `rollout_collection.py`. ## Testing - Capture, model-base, and rollout-collection suites pass (97 tests). - Full core unit suite passes (1175 passed; the 2 `test_opensandbox_provider.py` failures are pre-existing on the base branch). - `ruff check` and `ruff format` clean. Signed-off-by: Felipe Vieira Frujeri <[email protected]>
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
Merges
nemo_gym/model_call_capture.pyandnemo_gym/observability.pyintonemo_gym/base_responses_api_model.pyand deletes both modules. Pure consolidation — the code moved verbatim, no behavior changes.The model server is where capture lives:
SimpleResponsesAPIModelinstalls the middleware, the middleware writes the store, and the record/aggregation helpers read what the middleware wrote. Splitting that across three modules added indirection without a real seam, so everything now has a single home.Changes
nemo_gym/base_responses_api_model.pynow contains, in reading order:SimpleResponsesAPIModeletc.) — unchanged.ModelCallCaptureConfig,CaptureStore).ModelCallRecord, token/cache normalization, read/aggregate helpers)._CaptureMiddleware,install_model_call_capture).model_call_capture_dirs_from_config,clear_model_call_captures_for_rollouts,merge_model_call_capture_into_record).Deleted:
nemo_gym/model_call_capture.py,nemo_gym/observability.py.Import sites updated:
nemo_gym/rollout_collection.py— imports the run-level helpers from the new home.nemo_gym/server_utils.py— comment pointing atobservability.pyupdated.tests/unit_tests/test_observability.py→ renamed totests/unit_tests/test_base_responses_api_model_capture.py(it tests the capture feature of the merged module;test_base_responses_api_model.pyalready covers the server classes), all imports andmonkeypatchtargets rewritten.responses_api_models/openai_model/tests/test_app.pyandfern/versions/latest/pages/model-server/model-call-capture.mdx— import paths updated.One incidental cleanup: dropped
from __future__ import annotations(present in the old modules). The repo is Python 3.12+ so it's unnecessary, and PEP 563 string annotations can interact badly with FastAPI's runtime annotation evaluation on the endpoint signatures that now share the module.Notes for review
base_responses_api_model's dependencies (anthropic_converter,openai_utils,server_utils) never importrollout_collection, so rollout collection importing the model-server module is safe.rollout_collection.py.Testing
test_opensandbox_provider.pyfailures are pre-existing on the base branch).ruff checkandruff formatclean.