harness(openai): native-tool/vision profile toggles + baked provider options#49
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 19 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1057acf2ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !enabled { | ||
| self.profile.parallel_tool_calls = false; | ||
| self.profile.streaming_tool_chunks = false; | ||
| } |
There was a problem hiding this comment.
Restore tool sub-capabilities when re-enabling
When the same builder is applied more than once, such as layered config that disables native tools for a local preset and then a user override enables them, the second call only flips tool_calling back to true; the two dependent flags cleared here stay false. That leaves the profile weaker than a freshly enabled OpenAI-compatible model and causes capability resolution/fallback to skip it for requests requiring parallel_tool_calls or streaming_tool_chunks. Recompute or restore those flags on the enabled path.
Useful? React with 👍 / 👎.
…options
Add three additive OpenAiModel builders so the OpenHuman host can cut its
local-runtime providers (Ollama, LM Studio, MLX, OMLX, local-openai) over to
the crate-native ChatModel without a capability regression:
- with_native_tool_calling(bool): overrides profile.tool_calling (and clears
parallel_tool_calls/streaming_tool_chunks when disabled). Local runtimes that
reject the OpenAI `tools` parameter (HTTP 400) need this off so a harness
embeds tool specs in the prompt instead of sending native tools.
- with_vision(bool): overrides profile.modalities.image_in for text-only models.
- with_default_provider_options(Value): bakes provider options (e.g. Ollama's
{"options":{"num_ctx":8192}}) onto every request, merged under each
request's own provider_options (per-call keys win). A pure merge_provider_options
helper implements the policy and deliberately passes a non-object override
through untouched so provider_extra_options still rejects it.
Both invoke and stream go through translate_request, so the baked options and
profile toggles apply to unary and streaming calls alike. Unit-tested; fmt +
clippy -D warnings clean.
1057acf to
f5cb1eb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5cb1eba39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// [`with_model`](Self::with_model) / [`with_provider`](Self::with_provider) | ||
| /// (which re-derive the profile). | ||
| pub fn with_native_tool_calling(mut self, enabled: bool) -> Self { | ||
| self.profile.tool_calling = enabled; |
There was a problem hiding this comment.
Guard Auto structured output when tools are disabled
When callers use this new toggle for a local model that also lacks native_structured_output (for example .with_model("qwen2.5").with_native_tool_calling(false)) and request ResponseFormat::Auto, the agent loop still chooses the tool-call structured fallback: StructuredStrategy::for_profile returns ToolCall for any non-native profile without checking tool_calling (src/harness/structured/mod.rs:94-98), and run_loop then pushes an artificial tool (src/harness/agent_loop/run_loop.rs:149-157). That sends the tools parameter to exactly the endpoints this flag is meant to avoid, so Auto structured calls 400 instead of being routed or rejected before the provider call.
Useful? React with 👍 / 👎.
Summary
Three additive
OpenAiModelbuilders so an OpenAI-compatibleChatModelcan carry the per-provider capability adjustments that self-hosted/local runtimes need — unblocking OpenHuman's cutover of its local providers (Ollama, LM Studio, MLX, OMLX, local-openai) from a bespoke wire client to the crate-nativeOpenAiModel.with_native_tool_calling(bool)— overridesprofile.tool_calling; disabling also clearsparallel_tool_calls/streaming_tool_chunks. Local runtimes that 400 on the OpenAItoolsparameter need this off so a harness embeds tool specs in the prompt instead of sending native tools.with_vision(bool)— overridesprofile.modalities.image_infor text-only models.with_default_provider_options(Value)— bakes provider options (e.g. Ollama's{"options":{"num_ctx":8192}}) onto every request, merged under each request's ownprovider_options(per-call keys win). A puremerge_provider_optionshelper implements the policy and deliberately passes a non-object override through untouched soprovider_extra_optionsstill rejects it with its clear validation error.The profile toggles mutate the derived profile, so apply them after
with_model/with_provider(documented on each). Bothinvokeandstreamtranslate throughtranslate_request, so baked options + toggles apply to unary and streaming calls alike.Commands run
cargo fmt --checkcargo test --lib openai::— 55 passedcargo clippy --lib -- -D warnings— cleanAPI / behavior changes
Additive only; no existing behavior changes (defaults preserve the prior profile and empty baked options).