Skip to content

Fix stack 10: typed model/reasoning_effort fields + FinishReason enum#34

Merged
ebarti merged 3 commits into
review-fixes/09-open-kind-lifecyclefrom
review-fixes/10-typed-fields
Jul 2, 2026
Merged

Fix stack 10: typed model/reasoning_effort fields + FinishReason enum#34
ebarti merged 3 commits into
review-fixes/09-open-kind-lifecyclefrom
review-fixes/10-typed-fields

Conversation

@ebarti

@ebarti ebarti commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Stacked review-fix PR 10/N (base: review-fixes/09-open-kind-lifecycle).

REVIEW.md §5.3, §5.4 — typed public surface:

  • model / reasoning_effort are now first-class AgentTask fields, not stringly-typed metadata magic keys. Adapters prefer the fields and fall back to the metadata aliases, so existing callers keep working.
  • FinishReason(str, Enum) gives callers a canonical vocabulary (done/failed/max_turns/max_tokens/interrupted) to match against instead of bare literals. finish_reason stays typed str for forward-compat; since FinishReason subclasses str, both == FinishReason.X and == "x" hold, so nothing breaks.

Tests: typed model/effort preference + metadata-alias override, FinishReason string equivalence. Full suite 176 passed / 12 skipped; ruff + mypy strict clean.


Re-review amendment. FinishReason adopts the StrEnum __str__/__format__ assignments: on Python 3.11+ a plain (str, Enum) renders f"{FinishReason.FAILED}" as "FinishReason.FAILED", leaking the enum name into event summaries for callers who pass members. Rendering now matches the wire value on every supported Python, with tests.


Round 2 (re-review follow-up)

  • reasoning_effort is now wired end-to-end instead of half-wired: Claude maps it to effort= (claude-agent-sdk >= 0.2.87; older SDKs record the drop in dropped_options — a quality preference, not a security kwarg), and Antigravity rejects it with a typed error since google-antigravity 0.1.x has no reasoning-effort control (the legacy metadata alias stays ignored there, as before).
  • AgentTask.model / AgentTask.reasoning_effort are now kw_only, so inserting them mid-dataclass no longer shifts the positional layout that predates them (the fourth positional argument is still working_directory).
  • Tests for all three adapters plus a positional-layout pin.

@ebarti ebarti force-pushed the review-fixes/10-typed-fields branch from 2c1512b to 76ee95f Compare July 2, 2026 10:00
@ebarti ebarti force-pushed the review-fixes/09-open-kind-lifecycle branch 2 times, most recently from 61c32c4 to b3da251 Compare July 2, 2026 10:26
@ebarti ebarti force-pushed the review-fixes/10-typed-fields branch 2 times, most recently from 660535d to 3cd343d Compare July 2, 2026 10:41
@ebarti ebarti force-pushed the review-fixes/09-open-kind-lifecycle branch from b3da251 to 23c6d0c Compare July 2, 2026 10:41
ebarti added 3 commits July 2, 2026 16:57
…ocabulary

- Promote model and reasoning_effort to typed AgentTask fields instead of the
  stringly-typed metadata['model'] / metadata['reasoning_effort'] magic keys.
  Adapters prefer the fields and fall back to the metadata aliases, so existing
  callers keep working while the typed surface becomes the documented path.
- Add a FinishReason(str, Enum) canonical vocabulary (done/failed/max_turns/
  max_tokens/interrupted) that callers can match against instead of bare string
  literals. finish_reason stays typed str for forward-compat; because FinishReason
  is a str subclass, both == FinishReason.X and == 'x' hold.

Refs REVIEW.md §5.3, §5.4.
…3.11+

(str, Enum) format/str changed in 3.11: f"{FinishReason.FAILED}" produced
"FinishReason.FAILED", leaking the enum name into event summaries for
callers who pass members. Adopt the StrEnum __str__/__format__ assignments
so rendering matches the wire value on every supported Python.
… keyword-only

The first-class model/reasoning_effort fields shipped only half-wired:
Codex consumed both, Claude and Antigravity consumed model only, so a
requested reasoning_effort silently no-oped on two of three adapters.

- Claude maps reasoning_effort -> effort= (claude-agent-sdk >= 0.2.87);
  on an older SDK the drop is recorded in dropped_options, not fatal,
  since effort is a quality preference rather than a security posture.
- Antigravity raises UnsupportedTaskInputError: google-antigravity 0.1.x
  exposes no reasoning-effort control, and an explicit typed request
  must not silently no-op. The legacy metadata alias stays ignored as
  before for this adapter.
- AgentTask.model / .reasoning_effort become kw_only so inserting them
  mid-dataclass does not shift the positional layout that predates them
  (the fourth positional argument is still working_directory).
@ebarti ebarti force-pushed the review-fixes/09-open-kind-lifecycle branch from 23c6d0c to f6537d5 Compare July 2, 2026 15:13
@ebarti ebarti force-pushed the review-fixes/10-typed-fields branch from 3cd343d to 336bc6c Compare July 2, 2026 15:13
@ebarti ebarti merged commit 336bc6c into review-fixes/09-open-kind-lifecycle Jul 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant