Skip to content

bug(routing): knn backend drops generation settings (temperature / max_tokens / reasoning_effort) on per-model endpoints #183

Description

@0xKT

Summary

The knn routing backend routes calls to per-model endpoints through PerModelProvider, but the per-model sub-providers it builds never receive .generation. As a result, the configured agents.defaults.temperature / max_tokens / reasoning_effort are silently ignored for any call that routes to a knn endpoint; those calls fall back to the hardcoded GenerationSettings() defaults (temperature=0.7, max_tokens=4096).

Introduced by #163 (opt-in knn backend). Off by default, so impact is limited to users who set routing.enabled=true and routing.backend=knn.

Mechanism

  • Generation defaults reach a call via chat_with_retry, which reads self.generation.{temperature,max_tokens,reasoning_effort} and injects them into chat() (raven/providers/base.py:516-521). The low-level chat() itself does not read self.generation.
  • On the normal path, make_provider sets provider.generation from config (raven/cli/_helpers.py:134), so the values reach calls.
  • On the knn path, PerModelProvider.__init__ builds one CustomProvider per model with only api_key / api_base / default_model and never assigns .generation (raven/providers/per_model_provider.py:23-30). PerModelProvider.chat_with_retry delegates to the sub-provider (per_model_provider.py:49), whose .generation is the default, so the configured values are lost.
  • gateway_commands.py:50 also never sets .generation on the PerModelProvider itself.

Impact

  • knn-routed calls ignore user-configured temperature / max_tokens / reasoning_effort.
  • Low severity: knn is opt-in and off by default (routing.enabled=false, routing.backend=ecoclaw).

Fix

PerModelProvider should inherit the fallback provider's .generation and propagate it to the per-model sub-providers (the fallback is already configured by make_provider before knn wrapping at gateway_commands.py:196):

# in PerModelProvider.__init__, after building self._by_model
self.generation = fallback.generation
for sub in self._by_model.values():
    sub.generation = self.generation

Note

This same wiring gap also blocks the configurable llm_call_timeout proposed in #150 from reaching knn endpoints. The #150 fix will apply the 3-line propagation above as a side effect, which incidentally corrects the temperature / max_tokens loss described here. Filing this separately to record the root cause; the cross-reference on #163 keeps attribution clear.

Related: #150, #163.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions