Add unit tests for group ratio, cross-group retry, and price calculation:
- Group ratio CRUD and special ratio override (12 tests)
- HandleGroupRatio with auto-group and special ratios (5 tests)
- ModelPriceHelper with group ratio in price/ratio modes (3 tests)
- Channel selection priority, groups, weighted LB (6 tests)
- RetryParam and AutoGroup service logic (7 tests)
Also restore the group pricing card in model detail SideSheet.
Replace bytes.Replace with gjson.GetBytes+sjson.SetBytes in passthrough
mode to correctly handle JSON whitespace variations and avoid silently
sending empty body on read errors. Also add log search count limit to
prevent slow COUNT queries on large log tables.
Use adaptive thinking for Claude requests and rewrite passthrough bodies that still contain the legacy enabled type.
Co-Authored-By: Codex <noreply@anthropic.com>
Delete leftover channel pricing controllers and routes after removing channel pricing, and align relay price helpers with global pricing plus user channel ratio only.
Co-Authored-By: Codex <noreply@anthropic.com>
gpt-5.4 returns `arguments` as a JSON object for some tools (e.g.
apply_patch, tool_search), but ResponsesOutput.Arguments was typed as
string, causing json.Unmarshal to fail on every such SSE event.
The failure silently dropped all output_item events and the
response.completed event from the forwarded stream, so:
- the client never received tool call content
- usage/token counts could not be extracted (billed as 0)
- client reported "stream closed before response.completed"
Fix: change Arguments to json.RawMessage and add GetArguments() which
normalises both forms to a plain string (unescapes JSON strings,
returns raw bytes for objects).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DoApiRequest previously called io.ReadAll on every request body to apply
passthrough model mapping, even when the feature was disabled. This
caused unnecessary memory pressure for large request bodies (long
conversations, multipart image uploads).
Split the guard logic into needsPassthroughModelMapping() so that
ReadAll is only called when all conditions are met (feature enabled +
passthrough mode + model mapped). Non-passthrough requests now pass
the original io.Reader directly to http.NewRequest without buffering.
Rewrite tests to verify combined guard + modify behavior.
This PR fixes three issues:
1. Token bound_channel_id not updating: Add bound field to Update() method
2. Channel pricing quota_type detection: Use QuotaTypeByCall constant instead of magic number 1
3. Log display for ratio-based pricing: Set ModelPrice=-1 for ratio-based pricing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrate channel-specific pricing into the billing logic.
- First tries to get channel pricing using model.GetEffectivePricing
- If found, uses channel pricing (modelRatio, completionRatio, modelPrice, usePrice)
- If not found, falls back to global pricing from ratio_setting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>