Skip to content
Merged
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
23 changes: 19 additions & 4 deletions tests/integration/test_openrouter_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

Cost: free with `:free` model variants; otherwise pennies.
Skipped when OPENROUTER_API_KEY is unset.

Why we disable retries
----------------------
The :free OpenRouter pool is shared and frequently hits upstream
rate limits. Our patch's retry-with-backoff would dutifully wait
~7 minutes before bubbling the 429 — fine in production, terrible
in CI. We disable retries via env so transient 429s fail the test
fast (in seconds) and CI can re-run on the next cron tick.
"""

from __future__ import annotations
Expand All @@ -26,18 +34,25 @@

import pytest

import wikitrace as wt
# Disable wikitrace's retry-with-backoff for these tests BEFORE the
# patch reads the env var. _retry pulls _DEFAULT_MAX_RETRIES from env
# at import time, so we have to set it here, before the wrapper
# captures the default.
os.environ.setdefault("WIKITRACE_MAX_RETRIES", "0")

import wikitrace as wt # noqa: E402 must follow env override


pytestmark = pytest.mark.integration


# OpenRouter free-tier model. The :free suffix routes to a no-cost
# instance; if the upstream model is renamed, override via
# WIKITRACE_OPENROUTER_TEST_MODEL.
# instance; if the upstream model is renamed or rate-limited, override
# via WIKITRACE_OPENROUTER_TEST_MODEL. Verified working: the Liquid
# LFM 2.5 1.2B model is small enough to be reliably available.
DEFAULT_FREE_MODEL = os.environ.get(
"WIKITRACE_OPENROUTER_TEST_MODEL",
"mistralai/mistral-small-3.2-24b-instruct:free",
"liquid/lfm-2.5-1.2b-instruct:free",
)


Expand Down
Loading