Skip to content

fix: sync reasoning effort after parameter overrides - #6566

Open
wildoranges wants to merge 2 commits into
QuantumNous:mainfrom
wildoranges:fix/reasoning-effort-log
Open

fix: sync reasoning effort after parameter overrides#6566
wildoranges wants to merge 2 commits into
QuantumNous:mainfrom
wildoranges:fix/reasoning-effort-log

Conversation

@wildoranges

@wildoranges wildoranges commented Jul 31, 2026

Copy link
Copy Markdown

Problem

Parameter overrides can change the outbound reasoning setting after the adapter has populated RelayInfo.ReasoningEffort. Usage logs then report the stale pre-override value, and reasoning override operations are omitted from the parameter-override audit.

Fix

  • Synchronize RelayInfo.ReasoningEffort from the final outbound JSON for both Responses (reasoning.effort) and Chat Completions (reasoning_effort).
  • Include reasoning paths in the sensitive audit path list.
  • Add regression tests for both request formats and audit output.

This keeps the displayed reasoning effort aligned with the request actually sent upstream without changing routing or persistence behavior.

Verification

  • go test ./relay/common
  • go test ./relay/... ./service/...
  • go test ./... (with the ignored web/dist/index.html build artifact supplied temporarily for the clone; all packages passed)

Summary by CodeRabbit

  • Bug Fixes
    • Reasoning effort settings now stay synchronized when request parameters are overridden.
    • Supports both nested and top-level reasoning effort fields.
    • Invalid reasoning effort values are cleared to prevent stale settings.
    • Parameter override activity is audited even when debug mode is disabled.

Copilot AI review requested due to automatic review settings July 31, 2026 10:22
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b477a9a3-f436-4be5-85a9-3a3a96098626

📥 Commits

Reviewing files that changed from the base of the PR and between ac2770f and ca91d27.

📒 Files selected for processing (2)
  • relay/common/override.go
  • relay/common/override_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • relay/common/override.go

Walkthrough

Parameter overrides now audit reasoning fields and synchronize RelayInfo.ReasoningEffort from the final JSON body. Tests cover nested and top-level reasoning-effort values, including deletion.

Changes

Reasoning override handling

Layer / File(s) Summary
Audit and metadata synchronization
relay/common/override.go, relay/common/override_test.go
Sensitive audit paths include reasoning fields. Post-override processing synchronizes string and non-string reasoning-effort values to RelayInfo. Tests cover nested and top-level fields, deletion, and audit behavior.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Suggested reviewers: seefs001

Poem

A rabbit checks each reasoning trail,
Nested fields hop without fail.
Top-level values join the race,
Relay metadata finds its place.
Audit tracks each careful trace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes synchronizing reasoning effort after parameter overrides, which is the primary change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI 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.

Pull request overview

Fixes a metadata/auditing mismatch in the relay param-override pipeline by syncing RelayInfo.ReasoningEffort from the final outbound JSON after overrides are applied, and ensuring reasoning-related override operations are included in the sensitive audit path list.

Changes:

  • Add reasoning / reasoning_effort to the sensitive param-override audit path prefixes.
  • Sync RelayInfo.ReasoningEffort from the overridden outbound JSON (reasoning.effort for Responses; reasoning_effort for Chat Completions).
  • Add regression tests covering Responses and Chat Completions reasoning-effort sync (and partially audit behavior).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
relay/common/override.go Adds reasoning-sensitive audit prefixes and synchronizes RelayInfo.ReasoningEffort from the final overridden request JSON.
relay/common/override_test.go Adds regression tests for reasoning-effort synchronization (and audit coverage for Responses).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2197 to +2211
func TestApplyParamOverrideWithRelayInfoSyncsChatReasoningEffort(t *testing.T) {
info := &RelayInfo{
ReasoningEffort: "high",
ChannelMeta: &ChannelMeta{
ParamOverride: map[string]interface{}{
"operations": []interface{}{
map[string]interface{}{
"mode": "set",
"path": "reasoning_effort",
"value": "xhigh",
},
},
},
},
}
Comment thread relay/common/override_test.go Outdated
Comment on lines +2224 to +2227
if info.ReasoningEffort != "xhigh" {
t.Fatalf("expected final reasoning effort xhigh, got %q", info.ReasoningEffort)
}
}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@relay/common/override_test.go`:
- Around line 2182-2193: Update both test sites in relay/common/override_test.go
(lines 2182-2193 and 2217-2225): use require.NoError for
ApplyParamOverrideWithRelayInfo errors, and replace manual t.Fatalf checks for
ReasoningEffort and ParamOverrideAudit with assert.Equal while preserving the
existing expected values.

In `@relay/common/override.go`:
- Around line 208-228: Update syncReasoningEffort to clear info.ReasoningEffort
before iterating over the reasoning paths. Preserve the existing loop, but only
assign the field when the final JSON contains a string value, leaving it empty
when both paths are absent or non-string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d3c84571-e052-41c5-a91e-2c46b92c5baf

📥 Commits

Reviewing files that changed from the base of the PR and between 9724ef1 and ac2770f.

📒 Files selected for processing (2)
  • relay/common/override.go
  • relay/common/override_test.go

Comment thread relay/common/override_test.go Outdated
Comment thread relay/common/override.go
Comment on lines +208 to +228
// syncReasoningEffort keeps request metadata aligned with the final outbound
// body after parameter overrides have been applied. Adapters populate this
// field before overrides run, so reading the final JSON prevents logs from
// reporting the pre-override effort.
func syncReasoningEffort(info *RelayInfo, jsonData []byte) {
if info == nil {
return
}

for _, path := range []string{"reasoning.effort", "reasoning_effort"} {
value := gjson.GetBytes(jsonData, path)
if !value.Exists() {
continue
}
if value.Type == gjson.String {
info.ReasoningEffort = value.String()
} else {
info.ReasoningEffort = ""
}
return
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Clear metadata when the final body has no reasoning field.

Line 219 skips absent paths and Line 228 returns without changing info.ReasoningEffort. If an override removes reasoning.effort or reasoning_effort, logs retain the pre-override value.

Clear info.ReasoningEffort before this loop. Then set it only when the final body contains a string value.

Proposed fix
 func syncReasoningEffort(info *RelayInfo, jsonData []byte) {
 	if info == nil {
 		return
 	}
+	info.ReasoningEffort = ""

 	for _, path := range []string{"reasoning.effort", "reasoning_effort"} {

Based on PR objectives, metadata must align with the final outbound request body.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// syncReasoningEffort keeps request metadata aligned with the final outbound
// body after parameter overrides have been applied. Adapters populate this
// field before overrides run, so reading the final JSON prevents logs from
// reporting the pre-override effort.
func syncReasoningEffort(info *RelayInfo, jsonData []byte) {
if info == nil {
return
}
for _, path := range []string{"reasoning.effort", "reasoning_effort"} {
value := gjson.GetBytes(jsonData, path)
if !value.Exists() {
continue
}
if value.Type == gjson.String {
info.ReasoningEffort = value.String()
} else {
info.ReasoningEffort = ""
}
return
}
// syncReasoningEffort keeps request metadata aligned with the final outbound
// body after parameter overrides have been applied. Adapters populate this
// field before overrides run, so reading the final JSON prevents logs from
// reporting the pre-override effort.
func syncReasoningEffort(info *RelayInfo, jsonData []byte) {
if info == nil {
return
}
info.ReasoningEffort = ""
for _, path := range []string{"reasoning.effort", "reasoning_effort"} {
value := gjson.GetBytes(jsonData, path)
if !value.Exists() {
continue
}
if value.Type == gjson.String {
info.ReasoningEffort = value.String()
} else {
info.ReasoningEffort = ""
}
return
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/common/override.go` around lines 208 - 228, Update syncReasoningEffort
to clear info.ReasoningEffort before iterating over the reasoning paths.
Preserve the existing loop, but only assign the field when the final JSON
contains a string value, leaving it empty when both paths are absent or
non-string.

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.

2 participants