Skip to content

feat: pass response_format through iaas with fallback - #179

Draft
RohanAwhad wants to merge 2 commits into
Red-Hat-AI-Innovation-Team:v0from
RohanAwhad:feat/iaas-response-format-fallback
Draft

feat: pass response_format through iaas with fallback#179
RohanAwhad wants to merge 2 commits into
Red-Hat-AI-Innovation-Team:v0from
RohanAwhad:feat/iaas-response-format-fallback

Conversation

@RohanAwhad

Copy link
Copy Markdown

Summary

  • Add OpenAI-compatible response_format support to IaaS chat requests and forward it through scaling algorithms.
  • Add non-breaking fallback in LM adapters: if upstream rejects response_format, retry once without it and continue.
  • Keep compatibility for particle-filtering by ignoring response_format with a warning instead of failing.
  • Add tests for request passthrough, LM fallback behavior, algorithm forwarding, and particle-filter warning behavior.

Test plan

  • Baseline before changes: uv run --extra dev pytest tests/test_lms.py tests/test_iaas.py tests/test_algorithms.py
  • Red tests for new behavior: uv run --extra dev pytest tests/test_lms.py tests/test_iaas.py tests/test_algorithms.py -k "response_format"
  • Updated suites after implementation: uv run --extra dev pytest tests/test_lms.py tests/test_iaas.py tests/test_algorithms.py
  • Full suite: uv run --extra dev pytest
  • Behavioral smoke with adapter path via IaaS: adapter_critic run using local its_hub + reward_hub branch

Unit tests

uv run --extra dev pytest tests/test_lms.py tests/test_iaas.py tests/test_algorithms.py
uv run --extra dev pytest

its_hub/integration/iaas.py; its_hub/lms.py; its_hub/algorithms/self_consistency.py; its_hub/algorithms/bon.py; its_hub/algorithms/particle_gibbs.py; tests/test_iaas.py; tests/test_lms.py; tests/test_algorithms.py

- Add optional ChatCompletionRequest.response_format and forward it to scaling algorithms

- Thread response_format through self-consistency and best-of-n generation calls

- Ignore response_format for particle-filtering with warning instead of failing

- Add OpenAI/LiteLLM fallback that retries once without response_format when unsupported

- Add red-green tests for request passthrough, LM fallback, algorithm forwarding, and particle-filter warning

Remaining: Update adapter_critic dependency pins; Create and link draft PR
its_hub/lms.py
- Add OrderedDict-based response_format support cache (bounded size)
- Centralize fallback helper logic and reuse for OpenAI-compatible and LiteLLM paths
- Skip repeated fail-then-retry requests once a provider/model is known unsupported

its_hub/base.py
- Add response_format argument to ainfer/infer interface and forward it in sync wrapper

its_hub/algorithms/beam_search.py
its_hub/algorithms/planning_wrapper.py
its_hub/algorithms/particle_gibbs.py
its_hub/algorithms/__init__.py
- Thread response_format through algorithm interfaces; warn/ignore for step-wise beam search

tests/test_lms.py
tests/test_algorithms.py
- Add cache behavior coverage and sync infer response_format forwarding checks

Remaining: tighten unsupported-error detection for invalid schema vs unsupported capability
Signed-off-by: Rohan Awhad <rawhad@redhat.com>
@RohanAwhad

RohanAwhad commented Feb 23, 2026

Copy link
Copy Markdown
Author

Implemented the requested follow-ups (2/3/4) and pushed commit 64c6714.

  • Added bounded OrderedDict cache for response_format capability in LM adapters to avoid repeated fail-then-retry attempts.
  • Added sync/async API parity by threading response_format through AbstractScalingAlgorithm.infer/ainfer.
  • Refactored duplicate fallback paths into shared helper functions used by OpenAI-compatible and LiteLLM sync/async flows.
  • Updated algorithm plumbing where needed (beam search now explicitly warns/ignores response_format for step-wise generation).
  • Added focused tests for cache behavior and sync forwarding.

Validation run:

  • PYTHONPATH=. uvx --with pytest --with pydantic --with aiohttp --with backoff --with certifi --with litellm --with numpy --with openai --with fastapi --with uvicorn --with click --with requests pytest tests/test_lms.py -k "response_format_fallback_when_unsupported"
  • PYTHONPATH=. uvx --with pytest --with pydantic --with aiohttp --with backoff --with certifi --with litellm --with numpy --with openai --with fastapi --with uvicorn --with click --with requests pytest tests/test_algorithms.py -k "test_infer_forwards_response_format or test_infer_logs_warning_and_ignores_response_format"

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.

1 participant