Aias00 opened a new issue, #7911:
URL: https://github.com/apache/shenyu/issues/7911

   ### Behavior and reproduction
   
   The enhanced AI proxy supports OpenAI Responses, but the token-limiter 
response observer recognizes only Chat Completions usage fields. The same 
successful completion is therefore accounted as 12 tokens in Chat format and 
zero after the production Responses conversion.
   
   Executed at `fda742c48e7f553c9964cf74b36732326d0fde00` using the real 
ConnectProtocolAdapter and AiStatisticServerHttpResponse (a recording usage 
consumer replaces Redis persistence):
   
   ```text
   Chat usage: prompt_tokens=3, completion_tokens=12, total_tokens=15
   Recorded Chat completion usage: 12
   Actual converted Responses usage: input_tokens=3, output_tokens=12, 
total_tokens=15
   Recorded Responses completion usage: 0
   ```
   
   The converted body was generated by ShenYu's actual adapter, not a 
hypothetical upstream format. It was fully consumed and forwarded by the 
response observer. Repeated valid Responses calls do not advance the configured 
output-token counter as Chat calls do.
   
   ### Location and cause
   
   - [Streaming observer reads only 
usage.completion_tokens](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-token-limiter/src/main/java/org/apache/shenyu/plugin/ai/token/limiter/AiTokenLimiterPlugin.java#L297)
   - [Buffered fallback matches only 
completion_tokens](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-token-limiter/src/main/java/org/apache/shenyu/plugin/ai/token/limiter/AiTokenLimiterPlugin.java#L310)
   - [Responses 
conversion](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/protocol/ConnectProtocolAdapter.java#L108)
   
   ### Expected behavior / suggested repair
   
   Normalize usage accounting according to the selected AI protocol, including 
Responses output_tokens and its stream event layout, while preserving the 
existing completion/output-token accounting policy. Add integration coverage 
using the actual proxy conversion output and assert both recorded usage and 
unchanged response bytes.
   
   Medium severity, high confidence. Distinct from #7708 (usage split across 
flush publishers), #6515 (split gzip), #6758 (bounded tail retention), and 
#7702 (admission reservations). This issue is the usage-field/protocol mismatch 
on a complete uncompressed body.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to