Skip to content

Commit 433d9aa

Browse files
authored
fix: align ET budget error strings with gh-aw detection patterns (#2770)
* Initial plan * fix: use 'exceeded' in ET limit event type and message Update the event type, JSON error body type, and error message in proxy-request.js to use 'exceeded' terminology instead of 'reached'. This aligns AWF log events and error responses with the detection patterns in gh-aw's parse_mcp_gateway_log.cjs, which require 'exceeded' after 'effective tokens'. The previous 'reached' wording caused all three detection regexes to fail on AWF log lines: Before: event=effective_tokens_limit_reached type=effective_tokens_limit_reached message='Maximum effective tokens reached (X / Y).' After: event=effective_tokens_limit_exceeded type=effective_tokens_limit_exceeded message='Maximum effective tokens exceeded (X / Y).' The updated strings satisfy the existing gh-aw pattern: /effective[\s_-]*tokens?.*exceeded/i --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent bf10d9d commit 433d9aa

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

containers/api-proxy/proxy-request.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ function resetEffectiveTokenGuardForTests() {
263263
function buildEffectiveTokenLimitError(etState) {
264264
return {
265265
error: {
266-
type: 'effective_tokens_limit_reached',
267-
message: `Maximum effective tokens reached (${etState.totalEffectiveTokens.toFixed(2)} / ${etState.maxEffectiveTokens}).`,
266+
type: 'effective_tokens_limit_exceeded',
267+
message: `Maximum effective tokens exceeded (${etState.totalEffectiveTokens.toFixed(2)} / ${etState.maxEffectiveTokens}).`,
268268
total_effective_tokens: etState.totalEffectiveTokens,
269269
max_effective_tokens: etState.maxEffectiveTokens,
270270
},
@@ -483,7 +483,7 @@ function proxyRequest(req, res, targetHost, injectHeaders, provider, basePath =
483483
metrics.gaugeDec('active_requests', { provider });
484484
metrics.increment('requests_total', { provider, method: req.method, status_class: '4xx' });
485485
metrics.observe('request_duration_ms', duration, { provider });
486-
logRequest('warn', 'effective_tokens_limit_reached', {
486+
logRequest('warn', 'effective_tokens_limit_exceeded', {
487487
request_id: requestId,
488488
provider,
489489
total_effective_tokens: etBlock.totalEffectiveTokens,
@@ -628,7 +628,7 @@ function proxyWebSocket(req, socket, head, targetHost, injectHeaders, provider,
628628

629629
const etBlock = getEffectiveTokenBlockState();
630630
if (etBlock && etBlock.maxExceeded) {
631-
logRequest('warn', 'effective_tokens_limit_reached', {
631+
logRequest('warn', 'effective_tokens_limit_exceeded', {
632632
request_id: requestId,
633633
provider,
634634
total_effective_tokens: etBlock.totalEffectiveTokens,

containers/api-proxy/server.proxy.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ describe('proxyRequest effective token guard', () => {
495495
'Content-Type': 'application/json',
496496
}));
497497
const payload = JSON.parse(res2.end.mock.calls[0][0]);
498-
expect(payload.error.type).toBe('effective_tokens_limit_reached');
498+
expect(payload.error.type).toBe('effective_tokens_limit_exceeded');
499499
expect(payload.error.max_effective_tokens).toBe(10);
500500
expect(payload.error.total_effective_tokens).toBeGreaterThanOrEqual(10);
501501
});

0 commit comments

Comments
 (0)