fix: detect openclaw user-agent in proxy logs
This commit is contained in:
@@ -125,6 +125,21 @@ describe('detectDownstreamClientContext', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('treats explicit OpenClaw user-agent headers as self-reported app names', () => {
|
||||
expect(detectDownstreamClientContext({
|
||||
downstreamPath: '/v1/responses',
|
||||
headers: {
|
||||
'openai-beta': 'responses-2025-03-11',
|
||||
'user-agent': 'OpenClaw/1.0',
|
||||
},
|
||||
})).toEqual({
|
||||
clientKind: 'codex',
|
||||
clientAppId: 'openclaw',
|
||||
clientAppName: 'OpenClaw',
|
||||
clientConfidence: 'exact',
|
||||
});
|
||||
});
|
||||
|
||||
it('recognizes Claude Code requests from metadata.user_id without mutating the body', () => {
|
||||
const body = {
|
||||
model: 'claude-opus-4-6',
|
||||
|
||||
@@ -263,6 +263,16 @@ function detectExplicitClientSelfReport(headers: NormalizedClientHeaders): Downs
|
||||
};
|
||||
}
|
||||
|
||||
for (const value of headers['user-agent'] || []) {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (!normalized.startsWith('openclaw/')) continue;
|
||||
return {
|
||||
clientAppId: 'openclaw',
|
||||
clientAppName: 'OpenClaw',
|
||||
clientConfidence: 'exact',
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user