Skip to content

Commit 924159f

Browse files
llm: clarify transient-set count and legacy finish_reason mapping
Two doc-only cleanups from PR #17 review: - errors.py: TRANSIENT_CATEGORIES has three entries, not four — comment was off by one. - providers/openai.py: tighten the comment on the `finish_reason: "function_call"` → `"tool_calls"` rename so it's clear this is a value rename (per spec §8.2 / conformance fixture 005), not a message-field transformation. We do not translate the deprecated single `message.function_call` shape — none of the backends we currently target emit it.
1 parent 3f825b2 commit 924159f

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/openarmature/llm/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
PROVIDER_INVALID_REQUEST = "provider_invalid_request"
3232

3333

34-
# Per spec §7 "Retry classification": these four categories are
35-
# *transient* — a retry MAY succeed. The other three
34+
# Per spec §7 "Retry classification": these three categories are
35+
# *transient* — a retry MAY succeed. The other four
3636
# (`provider_authentication`, `provider_invalid_model`,
3737
# `provider_invalid_request`, `provider_invalid_response`) are
3838
# non-transient and MUST NOT be retried by the default classifier.

src/openarmature/llm/providers/openai.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,16 @@ def _parse_response(self, payload: dict[str, Any]) -> Response:
253253
raise ProviderInvalidResponse(f"response missing required fields: {exc}") from exc
254254
finish_reason: str = finish_reason_raw if isinstance(finish_reason_raw, str) else "error"
255255

256-
# Map OpenAI's legacy `function_call` to `tool_calls`; map any
257-
# unknown finish_reason to `error` per §8.2.
256+
# Per §8.2 (and conformance fixture 005's
257+
# `function_call_legacy_finish_reason_mapping` case): the
258+
# legacy `finish_reason: "function_call"` value MUST be
259+
# normalized to the spec's `"tool_calls"`. This is a
260+
# finish_reason *value* rename only — the assistant message's
261+
# `tool_calls` list is already populated by
262+
# ``_wire_to_assistant_message`` from the `tool_calls` field
263+
# on the wire. We do NOT translate the deprecated single
264+
# `message.function_call` shape (no backend we target emits
265+
# it). Any other unknown finish_reason maps to `error`.
258266
if finish_reason == "function_call":
259267
finish_reason = "tool_calls"
260268
if finish_reason not in {"stop", "length", "tool_calls", "content_filter", "error"}:

0 commit comments

Comments
 (0)