Skip to content

harness(openai): native-tool/vision profile toggles + baked provider options#49

Merged
senamakel merged 1 commit into
mainfrom
harness/openai-capability-toggles
Jul 10, 2026
Merged

harness(openai): native-tool/vision profile toggles + baked provider options#49
senamakel merged 1 commit into
mainfrom
harness/openai-capability-toggles

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

Three additive OpenAiModel builders so an OpenAI-compatible ChatModel can 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-native OpenAiModel.

  • with_native_tool_calling(bool) — overrides profile.tool_calling; disabling also clears parallel_tool_calls/streaming_tool_chunks. Local runtimes that 400 on the OpenAI tools parameter 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 with its clear validation error.

The profile toggles mutate the derived profile, so apply them after with_model/with_provider (documented on each). Both invoke and stream translate through translate_request, so baked options + toggles apply to unary and streaming calls alike.

Commands run

  • cargo fmt --check
  • cargo test --lib openai:: — 55 passed
  • cargo clippy --lib -- -D warnings — clean

API / behavior changes

Additive only; no existing behavior changes (defaults preserve the prior profile and empty baked options).

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 33ce99b7-31a6-4973-bce0-3997a9c15cb4

📥 Commits

Reviewing files that changed from the base of the PR and between e85e12d and f5cb1eb.

📒 Files selected for processing (3)
  • src/harness/providers/openai/mod.rs
  • src/harness/providers/openai/test.rs
  • src/harness/providers/openai/transport.rs

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +342 to +345
if !enabled {
self.profile.parallel_tool_calls = false;
self.profile.streaming_tool_chunks = false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
@senamakel senamakel force-pushed the harness/openai-capability-toggles branch from 1057acf to f5cb1eb Compare July 10, 2026 02:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@senamakel senamakel merged commit 7c6e81a into main Jul 10, 2026
3 checks passed
@senamakel senamakel deleted the harness/openai-capability-toggles branch July 10, 2026 03:01
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