openai_endpoint: ✨ Send a typed reasoning_effort - #10
Merged
Merged
Conversation
## Summary The OpenAI-compatible endpoint backend now takes a typed `reasoning_effort` (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`) and sends it in every `/chat/completions` body. Leaving it unset sends nothing, so existing callers see the same request as before. capt-hook's plain-English rewrite drove this. It calls Cerebras `qwen-3.8-27b`, which reasons by default. Over 12 calls on one 850-token prompt, the model spent a median 6,292 reasoning tokens (p95 10,801) to produce about 520 output tokens, taking 4.44s at p50 and 7.41s at p95. With `reasoning_effort: "none"` the same calls took 0.73s at p50 and 1.15s at p95, and the rewrites read as well or better. There was no way to send the field through spawnllm, because the core plans the body. ## Change The core's wire `OpenAiEndpoint` gains `reasoning_effort: Option<ReasoningEffort>`, a snake_case serde enum next to `AppleSampling`. `plan/openai.rs` inserts `reasoning_effort` into the body only when it is set. Like the other config fields it has no serde default, so every host sends it, as `null` when unset. - Python: `OpenAiEndpointBackend(..., reasoning_effort="none")`, typed by the new exported `TReasoningEffort` literal and carried in `openai_section()`. - Go: `OpenAIOpts.ReasoningEffort`, a `ReasoningEffort` string type with `ReasoningEffortNone` … `ReasoningEffortXhigh` constants. The empty string maps to `null` in `coreOpenAI`. - Rust: `OpenAiEndpoint.reasoning_effort` in the crate, with `ReasoningEffort` re-exported behind the `openai` feature. The crate's `OpenAiEndpoint` gains a public field, so a struct literal naming every field has to add it. That makes this release 0.14.0. The run-spec schema fixture lists the enum. `conformance-gen --write` regenerated the two existing endpoint vectors, which gained `"reasoning_effort": null`, and added `openai-endpoint-reasoning-effort`. ## Tests - New core unit test `reasoning_effort_plan_matches_vector` and a new conformance vector, both replayed through the Python and Go hosts against a rebuilt wasm blob. - Go `TestOpenAIEndpointSendsReasoningEffortOnlyWhenSet` checks that the body omits the field when unset and carries `"none"` when set. - Python `test_execute_sends_reasoning_effort`. `test_openai_endpoint_section_set_only_by_owning_backend` now expects `reasoning_effort: None` in the wire section. - `cargo test --workspace` passes except `empty_securestorage_env_reads_the_bare_item_over_config_dir_env`, which reads this machine's Keychain and fails the same way without this change. `cargo clippy --workspace --all-targets` reports no warnings, and `cargo fmt --check` passes. `go vet ./...` and `go test ./...` pass. `uv run pytest` passes with one Apple-sidecar skip, and `ruff check` is clean. Claude-Session-Id: ced006fd-6116-478a-b0f3-56be8ce8183d
yasyf
added a commit
to yasyf/captain-hook
that referenced
this pull request
Sep 25, 2026
Context: Follows #165. The plain-English rewrite calls Cerebras `qwen-3.8-27b`, which reasons by default. On a 2,300-character reply it spent a median 6,300 reasoning tokens for about 520 output tokens, so even with #165's 6-second cap many rewrites timed out and showed the original. Summary: `plain_english` passes `reasoning_effort="none"` to `OpenAiEndpointBackend`, and the spawnllm pin moves to `>=0.14.0,<0.15`, the first release with that field (yasyf/spawnllm#10). Motivation: The owner chose to make `reasoning_effort` a typed field in spawnllm rather than override the backend's request planning here. Details: 20 calls through the real `plain_english.plain_english()` path, same prompt and harness, a fresh nonce per call: | | p50 | p95 | max | fell back to original | |---|---|---|---|---| | #165 (spawnllm 0.13.4, reasoning on) | 4.42s | 6.02s | 6.47s | 3 of 20 (6s cap) | | this PR (spawnllm with reasoning_effort, `"none"`) | 0.52s | 0.98s | 1.13s | 0 of 20 | The "after" row ran against yasyf/spawnllm#10 installed from its branch. After v0.14.0 was published, 12 more calls against the locked release gave 0.52s p50 and 0.74s p95, with no fallbacks. `uv lock --upgrade-package spawnllm` moves the lock from 0.13.4 to 0.14.0. `test_streamed_message_is_rewritten_once` asserts that the backend carries `reasoning_effort == "none"`. Both changelog entries move to Unreleased: #165's landed under 12.56.0, which was tagged before #165 merged. `pytest tests/test_plain_english.py tests/test_plugin_hooks.py` passes.
yasyf
added a commit
to yasyf/captain-hook
that referenced
this pull request
Sep 25, 2026
) Context: Follows #165. The plain-English rewrite calls Cerebras `qwen-3.8-27b`, which reasons by default. On a 2,300-character reply it spent a median 6,300 reasoning tokens for about 520 output tokens, so even with #165's 6-second cap many rewrites timed out and showed the original. Summary: `plain_english` passes `reasoning_effort="none"` to `OpenAiEndpointBackend`, and the spawnllm pin moves to `>=0.14.0,<0.15`, the first release with that field (yasyf/spawnllm#10). Motivation: The owner chose to make `reasoning_effort` a typed field in spawnllm rather than override the backend's request planning here. Details: 20 calls through the real `plain_english.plain_english()` path, same prompt and harness, a fresh nonce per call: | | p50 | p95 | max | fell back to original | |---|---|---|---|---| | #165 (spawnllm 0.13.4, reasoning on) | 4.42s | 6.02s | 6.47s | 3 of 20 (6s cap) | | this PR (spawnllm with reasoning_effort, `"none"`) | 0.52s | 0.98s | 1.13s | 0 of 20 | The "after" row ran against yasyf/spawnllm#10 installed from its branch. After v0.14.0 was published, 12 more calls against the locked release gave 0.52s p50 and 0.74s p95, with no fallbacks. `uv lock --upgrade-package spawnllm` moves the lock from 0.13.4 to 0.14.0. `test_streamed_message_is_rewritten_once` asserts that the backend carries `reasoning_effort == "none"`. Both changelog entries move to Unreleased: #165's landed under 12.56.0, which was tagged before #165 merged. `pytest tests/test_plain_english.py tests/test_plugin_hooks.py` passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAI-compatible endpoint backend now takes a typed
reasoning_effort(none,minimal,low,medium,high,xhigh) and sends it in every/chat/completionsbody. Leaving it unset sends nothing, so existing callers see the same request as before.capt-hook's plain-English rewrite drove this. It calls Cerebras
qwen-3.8-27b, which reasons by default. Over 12 calls on one 850-token prompt, the model spent a median 6,292 reasoning tokens (p95 10,801) to produce about 520 output tokens, taking 4.44s at p50 and 7.41s at p95. Withreasoning_effort: "none"the same calls took 0.73s at p50 and 1.15s at p95, and the rewrites read as well or better. There was no way to send the field through spawnllm, because the core plans the body.Change
The core's wire
OpenAiEndpointgainsreasoning_effort: Option<ReasoningEffort>, a snake_case serde enum next toAppleSampling.plan/openai.rsinsertsreasoning_effortinto the body only when it is set. Like the other config fields it has no serde default, so every host sends it, asnullwhen unset.OpenAiEndpointBackend(..., reasoning_effort="none"), typed by the new exportedTReasoningEffortliteral and carried inopenai_section().OpenAIOpts.ReasoningEffort, aReasoningEffortstring type withReasoningEffortNone…ReasoningEffortXhighconstants. The empty string maps tonullincoreOpenAI.OpenAiEndpoint.reasoning_effortin the crate, withReasoningEffortre-exported behind theopenaifeature. The crate'sOpenAiEndpointgains a public field, so a struct literal naming every field has to add it. That makes this release 0.14.0.The run-spec schema fixture lists the enum.
conformance-gen --writeregenerated the two existing endpoint vectors, which gained"reasoning_effort": null, and addedopenai-endpoint-reasoning-effort.Tests
reasoning_effort_plan_matches_vectorand a new conformance vector, both replayed through the Python and Go hosts against a rebuilt wasm blob.TestOpenAIEndpointSendsReasoningEffortOnlyWhenSetchecks that the body omits the field when unset and carries"none"when set.test_execute_sends_reasoning_effort.test_openai_endpoint_section_set_only_by_owning_backendnow expectsreasoning_effort: Nonein the wire section.cargo test --workspacepasses exceptempty_securestorage_env_reads_the_bare_item_over_config_dir_env, which reads this machine's Keychain and fails the same way without this change.cargo clippy --workspace --all-targetsreports no warnings, andcargo fmt --checkpasses.go vet ./...andgo test ./...pass.uv run pytestpasses with one Apple-sidecar skip, andruff checkis clean.