MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _get_context_window

Function _get_context_window

src/query/query.py:249–264  ·  view source on GitHub ↗

Ch5/B.4 — return the model's context-window size in tokens. Defaults to 200_000 (the Claude family default) when the provider doesn't expose a real integer ``context_window`` attribute. The ``isinstance(_, int)`` guard handles MagicMock test fixtures: a MagicMock returns another mo

(provider: BaseProvider)

Source from the content-addressed store, hash-verified

247
248
249def _get_context_window(provider: BaseProvider) -> int:
250 """Ch5/B.4 — return the model's context-window size in tokens.
251
252 Defaults to 200_000 (the Claude family default) when the provider
253 doesn't expose a real integer ``context_window`` attribute.
254
255 The ``isinstance(_, int)`` guard handles MagicMock test fixtures:
256 a MagicMock returns another mock for unset attributes, so a naive
257 ``getattr(..., None) or default`` would short-circuit past the
258 default. Be explicit about the type so the loop is robust to test
259 doubles.
260 """
261 cw = getattr(provider, "context_window", None)
262 if isinstance(cw, int) and cw > 0:
263 return cw
264 return 200_000
265
266
267def _is_withheld_max_output_tokens(msg: Message | None) -> bool:

Callers 1

queryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected