Repository navigation
Conversation
|
🌿 Preview your docs: https://nvidia-preview-feat-adapter-observability.docs.buildwithfern.com/nemo/gym Here are the markdown pages you've updated: |
349a6d7 to
ca5ecd7
Compare
45c8b8c to
73051c7
Compare
ca5ecd7 to
1c267b4
Compare
PR 2 of 4 — observability family. Built on feat/adapter-base.
Adds 5 interceptors for inspecting traffic without changing semantics:
- log_tokens response log usage token counts + latency
- response_stats response accumulate counts / tokens / latency
- progress_tracking response optional webhook ping every N responses
- reasoning response normalize <think>...</think> OR reasoning
field into reasoning_content
- raise_client_errors response non-retriable 4xx -> RuntimeError;
429/408 pass through (retriable)
All five are registered as builtins in InterceptorRegistry._BUILTIN.
Tests
test_adapter_interceptors.py per-interceptor behaviour
test_adapter_parity_replay.py captured-fixture parity (5 scenarios)
adapter_fixtures/ logging, log_tokens, response_stats,
progress_tracking, raise_client_errors,
reasoning JSON fixtures
60 tests pass (42 from feat/adapter-base + 18 added).
Docs
fern/.../model-server/adapters.mdx appends Observability section with
per-interceptor YAML config snippets
Signed-off-by: Michal Bien <[email protected]>
1c267b4 to
9da7222
Compare
ffrujeri
left a comment
There was a problem hiding this comment.
Thanks for this PR — the 5 new interceptors are well-structured. Async patterns are correct, progress_tracking correctly routes webhooks through the global aiohttp client, asyncio.Lock usage is sound in both stateful interceptors, all 18 tests pass, and ruff is clean.
Two items worth a look before merging:
Generated by Claude Code (4 agents + devil's advocate)
| pt, | ||
| ct, | ||
| tt, | ||
| resp.latency_ms, |
There was a problem hiding this comment.
nemo_gym/adapters/interceptors/log_tokens.py:46
The docs page advertises that log_tokens logs "token counts and latency", but in the install_middleware path latency_ms is always 0.0 — the middleware closure doesn't timestamp the upstream call (only proxy.py does). Would it make sense to either add timing to the middleware path, or note the limitation in the docs?
The same applies to response_stats, which logs total_latency_ms in its periodic summary.
| assert result.status_code == 429 | ||
|
|
||
|
|
||
| async def test_reasoning_normalize(): |
There was a problem hiding this comment.
tests/unit_tests/test_adapter_interceptors_observability.py:70
reasoning has three normalization paths but only path c (<think>…</think> extraction) is tested here. Could you add coverage for the other two?
- Path b —
"reasoning"field renamed to"reasoning_content"— is the primary DeepSeek/QwQ use case and currently has zero coverage. - Path a — idempotency when
reasoning_contentis already present — is also untested.
async def test_reasoning_normalizes_reasoning_field():
ic = InterceptorRegistry.create("reasoning")
resp = _resp({"choices": [{"message": {"reasoning": "chain-of-thought", "content": "answer"}}]})
result = await ic.intercept_response(resp)
msg = result.body["choices"][0]["message"]
assert "reasoning" not in msg
assert msg["reasoning_content"] == "chain-of-thought"
assert msg["content"] == "answer"
async def test_reasoning_idempotent_when_already_has_reasoning_content():
ic = InterceptorRegistry.create("reasoning")
resp = _resp({"choices": [{"message": {"reasoning_content": "existing", "content": "answer"}}]})
result = await ic.intercept_response(resp)
msg = result.body["choices"][0]["message"]
assert msg["reasoning_content"] == "existing" # not mutated
assert "reasoning" not in msgECS Fargate `SandboxProvider` on top of the sandbox API (#1377, now merged to `main`). Auto-mirrors public images to ECR on demand; SSH reverse-tunnel for exec / file-transfer / model egress. Rebased onto `main` now that the sandbox base (#1377) has landed — this PR stands on its own and is ready for review. **Sandbox-bound agents line of work:** **ECS Fargate (this PR)** → adapter middleware base (#1646) → sandbox-bound CLI agents + capture (#1647). Interceptor follow-ups on the adapter base: #1649 (caching), #1650 (observability), #1651 (rewrites). 3 commits, +5974: ECS provider + engine, on-demand ECR mirroring + conda activation fix, and 233 unit tests (engine.py to 99%). `uv.lock` reconciled with main's security upgrades (#1657). --------- Signed-off-by: Michal Bien <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Adapter interceptor follow-up on
feat/adapter-base. Adds 5 passive / mildly-normalizing interceptors:log_tokens— log usage token counts + latencyresponse_stats— accumulate counts / tokens / latencyprogress_tracking— optional webhook ping every N responsesreasoning— normalize<think>…</think>/ reasoning field intoreasoning_contentraise_client_errors— non-retriable 4xx →RuntimeError; 429/408 pass throughAll registered as builtins in the interceptor registry. Tests: per-interceptor behavior + parity replay (5 scenarios) — 18 added.
Supersedes Glorf#3 (fork discontinued; rebased clean onto upstream
feat/adapter-base).