refactor(llm): type provider tool choices - #2843
Conversation
…penai-required-tool-choice-20260716
…red-tool-choice-20260716' into upstream/refactor-typed-tool-choice-20260716
…yped-tool-choice-20260716 # Conflicts: # hindsight-api-slim/hindsight_api/engine/providers/openai_compatible_llm.py # hindsight-api-slim/hindsight_api/engine/reflect/agent.py # hindsight-api-slim/tests/test_tool_choice_required_downgrade.py
|
Ready for maintainer merge. This is the exact restored replacement for unreopenable #2737. Head 54f14f3 is already merged with current upstream main e07ca1b; the merge tree was independently reconstructed and verified byte-for-byte. All upstream checks are green. Please merge this one first because #2844 builds on the typed tool-choice contract. |
|
cc @nicoloboschi — all checks are green; this is first in the merge order. |
nicoloboschi
left a comment
There was a problem hiding this comment.
Approve. Behavior-preserving typed refactor: verified provider serialization maps 1:1 to the old string/dict logic across all providers, ty check passes, and the four tool-choice unit suites pass (27 tests). Non-blocking follow-ups: Anthropic provider still ignores tool_choice (pre-existing); a small direct unit test for LLMToolChoice invariants would be nice.
Summary
str | dicttool-choice union with a canonical typed valueDependency
This is intentionally stacked on #2734 because it types the named-tool behavior introduced there. Review the final refactor commit
7a71d8c11; after #2734 lands, the base will contain the prerequisite behavior and this PR will show only the typed cutover.Validation
A broader local file-level run reached 82 passing tests; four unrelated integration/setup cases failed because the local environment had no
.envAPI key and two parallel workers timed out waiting on the shared embeddings fixture lock. The focused deterministic suite above is the authoritative change validation.Replacement for #2737. The original PR became unreopenable after its submitting fork was deleted. This PR restores the exact reviewed head commit and preserves the original implementation without modification.