mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
refactor(transports/codex): trim duplicated cache-key comments
The xAI prompt_cache_key block carried two long comment paragraphs that either restated setdefault semantics, narrated the SDK type-validation mechanism, or recapped the historical motivation for the extra_body indirection — all already covered by the test docstring at test_xai_responses_sends_cache_key_via_extra_body (which links to the xAI docs). Also restored the truncated link in the body-injection comment. No behavior change.
This commit is contained in:
parent
e13c1b8060
commit
7fdc16dd4a
2 changed files with 6 additions and 19 deletions
|
|
@ -102,11 +102,8 @@ class ResponsesApiTransport(ProviderTransport):
|
|||
kwargs["parallel_tool_calls"] = True
|
||||
|
||||
session_id = params.get("session_id")
|
||||
# xAI's Responses API uses `prompt_cache_key` (body-level) as the
|
||||
# cache-routing key, not a top-level kwarg — the body-field
|
||||
# injection below survives openai SDK builds whose
|
||||
# Responses.stream() signature drops the kwarg. Everything else
|
||||
# that ISN'T github/xAI keeps using the typed kwarg.
|
||||
# xAI Responses takes prompt_cache_key in extra_body (set further
|
||||
# down); GitHub Models opts out of cache-key routing entirely.
|
||||
if not is_github_responses and not is_xai_responses and session_id:
|
||||
kwargs["prompt_cache_key"] = session_id
|
||||
|
||||
|
|
@ -172,15 +169,10 @@ class ResponsesApiTransport(ProviderTransport):
|
|||
merged_extra_headers["x-grok-conv-id"] = session_id
|
||||
kwargs["extra_headers"] = merged_extra_headers
|
||||
|
||||
# xAI Responses cache-routing field. Lives in the request body
|
||||
# (per https://docs.x.ai/.../prompt-caching/maximizing-cache-hits),
|
||||
# so we ship it via extra_body — the openai SDK serializes
|
||||
# extra_body fields into the JSON body without per-field type
|
||||
# validation, sidestepping the TypeError that fires on
|
||||
# Responses.stream() builds whose `prompt_cache_key` kwarg has
|
||||
# been dropped. Setdefault preserves a caller-supplied value
|
||||
# (e.g. request_overrides.extra_body.prompt_cache_key) over
|
||||
# the auto-derived session_id.
|
||||
# xAI Responses cache-routing — body-level field per
|
||||
# https://docs.x.ai/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits.
|
||||
# Sent via extra_body (not the typed kwarg) so it survives openai
|
||||
# SDK builds whose Responses.stream() signature has dropped the field.
|
||||
existing_extra_body = kwargs.get("extra_body")
|
||||
merged_extra_body: Dict[str, Any] = {}
|
||||
if isinstance(existing_extra_body, dict):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue