Skip to content

fix(ollama): tolerate dict-backed reasoning messages in OpenAI preprocessing#5638

Open
skamenan7 wants to merge 6 commits intoogx-ai:mainfrom
skamenan7:bug/5636-ollama-dict-bug
Open

fix(ollama): tolerate dict-backed reasoning messages in OpenAI preprocessing#5638
skamenan7 wants to merge 6 commits intoogx-ai:mainfrom
skamenan7:bug/5636-ollama-dict-bug

Conversation

@skamenan7
Copy link
Copy Markdown
Contributor

What does this PR do?

Prevent reasoning providers from failing when they pass provider-specific dict messages through shared image localization.

  • src/ogx/providers/utils/inference/openai_mixin.py: update _localize_image_url() to handle both Pydantic message models and dict-backed messages via duck-typed field access.
  • tests/unit/providers/utils/inference/test_openai_mixin_models.py: add a regression test for dict-shaped reasoning messages with provider-specific keys like reasoning.

Closes #5636

Test Plan

Unit tests:

uv run pytest tests/unit/providers/utils/inference/test_openai_mixin_models.py -x --tb=short
uv run pytest tests/unit/providers/utils/inference/test_openai_mixin_inference.py -x --tb=short

Static checks:

uv run ruff check src/ogx/providers/utils/inference/openai_mixin.py tests/unit/providers/utils/inference/test_openai_mixin_models.py
uv run mypy src/ogx/providers/utils/inference/openai_mixin.py tests/unit/providers/utils/inference/test_openai_mixin_models.py

Integration test (replay mode against recorded ollama/gpt-oss:20b reasoning setup):

uv run --no-sync ./scripts/integration-tests.sh --stack-config server:ci-tests --setup ollama-reasoning --file tests/integration/responses/test_reasoning.py --pattern test_reasoning_multi_turn_passthrough

…cessing

Prevent reasoning providers from failing when they pass provider-specific dict messages through shared image localization, and add a regression test for the dict-shaped message path.

Signed-off-by: skamenan7 <skamenan@redhat.com>
…cessing

Prevent reasoning providers from failing when they pass provider-specific dict messages through shared image localization, and add a regression test for the dict-shaped message path.

Signed-off-by: skamenan7 <skamenan@redhat.com>
@skamenan7 skamenan7 force-pushed the bug/5636-ollama-dict-bug branch from dddf764 to da58e44 Compare April 28, 2026 15:26
@skamenan7 skamenan7 marked this pull request as ready for review April 28, 2026 15:26
self._validate_model_allowed(provider_model_id)

messages = params.messages
messages: list[Any] = params.messages
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.

please find a way to fix this bug without undoing our type protections. that's to say, find a way to turn the dict back into the proper type before passing it along.

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.

bug: ollama reasoning path passes dict messages into OpenAIMixin code that expects .content

2 participants