Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions deeptutor/services/llm/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def _sanitize_call_kwargs(

if not supports_response_format(binding, model):
extra_kwargs.pop("response_format", None)
if binding == "azure_openai" and "max_completion_tokens" in extra_kwargs:
extra_kwargs["max_tokens"] = extra_kwargs.pop("max_completion_tokens")
return extra_kwargs


Expand Down
22 changes: 22 additions & 0 deletions tests/services/llm/test_factory_provider_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,28 @@ async def test_complete_strips_unsupported_response_format(monkeypatch) -> None:
assert "response_format" not in provider.complete_kwargs


@pytest.mark.asyncio
async def test_complete_normalizes_azure_max_completion_tokens(monkeypatch) -> None:
cfg = _make_cfg(
model="gpt-5.4",
binding="azure_openai",
provider_name="azure_openai",
)
provider = _FakeProvider()

monkeypatch.setattr("deeptutor.services.llm.factory.get_llm_config", lambda: cfg)
monkeypatch.setattr(
"deeptutor.services.llm.factory.get_runtime_provider",
lambda _config: provider,
)

result = await complete("hello", max_completion_tokens=200)

assert result == "ok"
assert provider.complete_kwargs["max_tokens"] == 200
assert "max_completion_tokens" not in provider.complete_kwargs


@pytest.mark.asyncio
async def test_complete_passes_retry_delays(monkeypatch) -> None:
cfg = _make_cfg()
Expand Down