Commit 4619b30
fix(obs): stand down when litellm's routing table cannot be read
Greptile P2 on #523, and it is right: the previous commit warned and then kept
recording with a five-provider fallback, which marks groq, deepseek, xai and
~50 others as native. litellm still sends those over the OpenAI client, so both
that client and inference_call record them. A warning does not prevent the bad
metric data — it just annotates it.
Both halves of the suggestion are taken.
**A stable source.** The list is read from `litellm.constants`, where it is
defined (constants.py:789), instead of the `litellm` top level, which is an
incidental re-export. litellm declares no `__all__` at all, so the top-level
name carries no stability promise even informally, which is what pyright was
objecting to in the first place. Verified the two are the same object.
**Stand down when it is unknown.** `_over_openai_client` now returns None for
"cannot tell", and `_split_model`'s second element is `bool | None`. None is
deliberately not collapsed into False, because treating an unknown provider as
native is exactly what double-counts it. `inference_call` returns the null
recorder on None, so no record is started at all.
That choice is deliberate in one direction: standing down also drops the native
providers (anthropic, bedrock, vertex_ai) that nothing else records, so the
fallback loses real data. It is still the right trade. A doubled token or cost
figure is silent and gets believed; a gap is visible, and this one is warned
about by name. The path is also effectively unreachable — litellm is a hard
dependency and the constant has been there for many releases — so the
conservative branch costs nothing in practice.
Verified end to end: with `litellm.constants` blocked and a working sgp-obs
stub present, every model resolves to None and zero records are started.
Tests: 35 in this file, covering both the None contract and the property that
actually protects the data — no sgp-obs record is created when routing is
unknown. `./scripts/lint` (ruff, pyright 0 errors, import) and
`./scripts/check-slim-deps` clean; 1714 repo-wide.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 9927124 commit 4619b30
2 files changed
Lines changed: 105 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 67 | + | |
74 | 68 | | |
75 | | - | |
76 | 69 | | |
77 | | - | |
| 70 | + | |
78 | 71 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 72 | + | |
83 | 73 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
90 | 79 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
101 | 96 | | |
102 | 97 | | |
103 | 98 | | |
| |||
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
129 | | - | |
| 124 | + | |
130 | 125 | | |
131 | 126 | | |
132 | 127 | | |
| |||
153 | 148 | | |
154 | 149 | | |
155 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
156 | 155 | | |
157 | 156 | | |
158 | 157 | | |
| |||
246 | 245 | | |
247 | 246 | | |
248 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
| |||
Lines changed: 63 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
136 | 140 | | |
137 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
138 | 149 | | |
139 | 150 | | |
140 | 151 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
147 | 196 | | |
148 | 197 | | |
149 | 198 | | |
| |||
0 commit comments