Files
hermes-agent/plugins/model-providers/fireworks/__init__.py
T
teknium1andHukla 7f03867523 fix(aux): parameter rungs hand a 429 on, and Fireworks gets top-level reasoning_effort
The pre-ladder max_tokens rung accepted payment|connection|rate_limit errors on
its retry, so a 429 after a stripped retry reached the credential and
provider-fallback rungs. The ladder's shared `_param_rung_accepts` dropped
rate_limit: a 429 on the retry raised out of the primary call and skipped the
whole fallback chain. Accept it there too, with a rung-level test that the
stripped kwargs and the 429 are handed on rather than raised.

The body claimed `Fixes #109774` while the aux client still sent the generic
`extra_body.reasoning` to Fireworks on every call and only recovered
reactively (an extra 400 round-trip per request). Port @huklaa's profile
override from #109807: Fireworks documents top-level `reasoning_effort`
(`none` disables thinking), and overriding `build_api_kwargs_extras` marks the
profile reasoning-aware so the transport omits the generic fallback on this
route. Extends the salvage with the effort mapping so enabled-with-effort takes
the same wire, with a control that a profile-less route keeps the fallback.

Salvages #109807 (@huklaa).

Co-authored-by: Hukla <129692708+huklaa@users.noreply.github.com>
2026-09-17 08:45:46 -07:00

50 lines
2.2 KiB
Python

"""Fireworks AI provider profile. Models are addressed by full catalog ID
(``accounts/fireworks/models/<slug>``), tracking fw-ai/fireconnect ``setup-cli``."""
from typing import Any
from hermes_cli import __version__ as _HERMES_VERSION
from providers import register_provider
from providers.base import ProviderProfile
class FireworksProfile(ProviderProfile):
"""Map Hermes reasoning controls onto Fireworks' OpenAI-compatible wire."""
def build_api_kwargs_extras(
self, *, reasoning_config: dict | None = None, **context: Any
) -> tuple[dict[str, Any], dict[str, Any]]:
# Fireworks rejects the nested ``extra_body.reasoning`` fallback some OpenAI-compatible
# gateways accept (#109774); its documented control is top-level ``reasoning_effort``
# (``none`` disables thinking). Overriding here marks the profile reasoning-aware, so the
# transport never sends the generic fallback on this route.
if not isinstance(reasoning_config, dict):
return {}, {}
if reasoning_config.get("enabled") is False:
return {}, {"reasoning_effort": "none"}
effort = reasoning_config.get("effort")
return {}, ({"reasoning_effort": effort} if effort else {})
fireworks = FireworksProfile(
name="fireworks", aliases=("fireworks-ai", "fw"), display_name="Fireworks AI",
description="Fireworks AI — OpenAI-compatible direct model API",
signup_url="https://app.fireworks.ai/settings/users/api-keys", env_vars=("FIREWORKS_API_KEY",),
base_url="https://api.fireworks.ai/inference/v1", auth_type="api_key",
# Attribution headers (canonical Hermes set); via default_headers so they
# survive switch_model and credential rotation.
default_headers={
"HTTP-Referer": "https://hermes-agent.nousresearch.com",
"X-Title": "Hermes Agent",
"User-Agent": f"HermesAgent/{_HERMES_VERSION}",
},
default_aux_model="accounts/fireworks/models/glm-5p2",
# Picker safety net when the live catalog fetch fails.
fallback_models=(
"accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/glm-5p2",
"accounts/fireworks/models/kimi-k2p7-code",
),
)
register_provider(fireworks)