Skip to content

refactor(context): remove unused provider formatters - #385

Merged
furgalep merged 1 commit into
mainfrom
refactor/remove-dead-provider-formatters
Sep 23, 2026
Merged

furgalep merged 1 commit into
mainfrom
refactor/remove-dead-provider-formatters

Conversation

@furgalep

@furgalep furgalep commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

AnthropicProviderFormatter and ResponsesProviderFormatter were not on the live path, so this removes them along with the runtime's isinstance(llm_client, ResponsesClient) dispatch that existed only to select the Responses one.

  • RenderConfig.provider_formatter defaults to OpenAIProviderFormatter for every client. Anthropic models already go through it; LiteLLM does the wire translation. The Anthropic formatter's only callers were tests.
  • ResponsesProviderFormatter was an empty subclass of the OpenAI formatter. actor.py picked it by client type, then ResponsesClient._transform_messages projected the same public message list it would have received anyway. Deleting it changes nothing on the wire.
  • actor.py now passes render_config.provider_formatter straight through. Connect's setup probe no longer branches on api_style to choose a formatter.

OpenAIProviderFormatter stays: it converts the neutral RenderedMessage list into the OpenAI-shaped list[dict] that UnifiedLLM accepts, which is a step LiteLLM cannot do for us. Collapsing it to a plain to_messages() and dropping provider_formatter= from RenderConfig/render_context is the remaining cleanup described in #337's migration notes; it overlaps #353's renderer rewrite, so it is left for after #353 lands.

Why now

This is the one place the runtime cared about the concrete UnifiedLLM subclass. With it gone, a wrapper around a client (for example an admission-control decorator, see the discussion on #349) only needs acall, model, and context_window to be a drop-in llm= for an agent.

Changes

  • src/nooa/context_blocks/formatter.py: delete both classes and the Anthropic-only _arguments_object helper; module docstring updated.
  • src/nooa/context_blocks/__init__.py: drop the two exports (public API removal).
  • src/nooa/runtime/actor.py: delete _resolve_provider_formatter.
  • src/nooa/unifiedllm/connect/_session.py: single formatter.
  • Tests: Anthropic-only tests removed (they exercised dead code); Responses-formatter call sites switched to OpenAIProviderFormatter with unchanged assertions; helpers that took a responses= flag to pick between identical formatters lose the flag. One parametrize("responses", ...) in test_response_history.py is dropped for the same reason.
  • CHANGELOG.md entry under Unreleased.

Test plan

  • uv run pytest --ignore=tests/integration tests: 8297 passed, 4 skipped, 83 deselected
  • tests/integration/test_truncation_e2e.py, test_l4_eviction_e2e.py, test_cache_resume_live.py collected and passed/skipped as before (live cases skip without credentials)
  • ruff check / ruff format --check clean on all touched files
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Breaking Changes
    • Removed the Anthropic- and Responses-specific context formatter options. Applications using these formatters must use the configured OpenAI-compatible formatter instead.
  • Behavior Changes
    • Context messages now use the configured formatter across client types. Responses clients continue to project messages into their API format.

AnthropicProviderFormatter and ResponsesProviderFormatter were not on the
live path. RenderConfig defaults to OpenAIProviderFormatter for every client
(Anthropic included; LiteLLM does the wire translation), and
ResponsesProviderFormatter was an empty subclass whose only purpose was to be
picked by an isinstance(llm_client, ResponsesClient) check in the runtime.
ResponsesClient already projects the public message list itself.

Delete both classes, the runtime's client-type dispatch, and Connect's
api_style branch that selected between them. The runtime now uses
RenderConfig.provider_formatter as configured for every client, so a wrapper
around a UnifiedLLM client (for example an admission-control decorator) no
longer has to be an instance of the wrapped class.

Tests that only exercised the Anthropic export are removed; the rest move to
OpenAIProviderFormatter with unchanged assertions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA-NeMo/labs-OO-Agents/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e1b07817-b67f-4b56-955a-544430233b85

📥 Commits

Reviewing files that changed from the base of the PR and between c11aa5d and 3ed17c4.

📒 Files selected for processing (20)
  • CHANGELOG.md
  • src/nooa/context_blocks/__init__.py
  • src/nooa/context_blocks/formatter.py
  • src/nooa/context_blocks/renderers/cached.py
  • src/nooa/runtime/actor.py
  • src/nooa/unifiedllm/connect/_session.py
  • tests/context_blocks/test_cached_renderer.py
  • tests/context_blocks/test_formatters.py
  • tests/context_blocks/test_renderer.py
  • tests/integration/test_cache_resume_live.py
  • tests/test_provider_image_rendering.py
  • tests/unifiedllm/test_cache_defaults.py
  • tests/unifiedllm/test_cross_provider_reasoning.py
  • tests/unifiedllm/test_explicit_cache_boundary.py
  • tests/unifiedllm/test_plain_reasoning_replay.py
  • tests/unifiedllm/test_reasoning_state_replay.py
  • tests/unifiedllm/test_response_history.py
  • tests/unifiedllm/test_responses_formatter.py
  • tests/unifiedllm/test_review_contracts.py
  • tests/unifiedllm/test_turn_projection.py
💤 Files with no reviewable changes (3)
  • tests/context_blocks/test_renderer.py
  • tests/unifiedllm/test_review_contracts.py
  • src/nooa/context_blocks/init.py

Included review availability: Your plan provides up to 12 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change removes the Anthropic and Responses provider formatters. Runtime rendering now uses the configured formatter, and Connect setup uses OpenAIProviderFormatter for every API style. Tests use OpenAI-compatible formatting and retain ResponsesClient message projection coverage.

Changes

Provider formatter consolidation

Layer / File(s) Summary
Formatter surface and Anthropic coverage
src/nooa/context_blocks/*, tests/context_blocks/*, tests/test_provider_image_rendering.py, tests/unifiedllm/test_review_contracts.py
The package removes AnthropicProviderFormatter and its public export. Formatter documentation, cached-renderer guidance, and related tests reflect the remaining OpenAI-compatible formatting path.
Runtime formatter selection
src/nooa/runtime/actor.py, src/nooa/unifiedllm/connect/_session.py, tests/integration/test_cache_resume_live.py, CHANGELOG.md
ActorRuntime passes the configured formatter directly to context rendering. Connect setup uses OpenAIProviderFormatter for all API styles.
Projection and replay tests
tests/context_blocks/test_formatters.py, tests/unifiedllm/*
Tests use OpenAIProviderFormatter for Responses rendering and replay. ResponsesClient projection tests continue to exercise the client transformation.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 3ed17

The formatter consolidation is mergeable after normal checks; no concrete behavior regression remains identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.02% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 16 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing unused provider formatters as part of a context refactor.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 17.02% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 16 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@furgalep
furgalep force-pushed the refactor/remove-dead-provider-formatters branch from 16baec6 to 3ed17c4 Compare September 23, 2026 09:08

@alessiodevoto alessiodevoto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! LGTM!

@furgalep
furgalep merged commit 3374cea into main Sep 23, 2026
9 checks passed
@furgalep
furgalep deleted the refactor/remove-dead-provider-formatters branch September 23, 2026 12:55
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