Claude accounts: route the request with the chat's native session id

The account requests carry the chat in a claude_account body, which the
multi-machine gateway neither routed by nor stripped of its chat@ prefix,
so the server refused them as 'a valid chat session id is required'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 16:23:41 +00:00
parent e80f18969c
commit a1891c818c
4 changed files with 36 additions and 2 deletions
@@ -336,4 +336,33 @@ void main() {
await machine.events.close();
},
);
test('a chat\'s Claude account request reaches its own machine with the '
'native session id', () async {
final a = Machine(), b = Machine();
final sources = {
'a': ChatServerGateway(server('a'), a),
'b': ChatServerGateway(server('b'), b),
};
final all = FederatedChatGateway(
() => sources,
() => 'a',
const Stream.empty(),
);
for (final type in ['claude_accounts', 'claude_account_use']) {
await all.call(type, {
'claude_account': {
'session_id': federatedChatId('b', 'collision'),
'name': 'second',
},
});
final (sent, fields) = b.calls.last;
expect(sent, type);
expect(fields['claude_account'], {
'session_id': 'collision',
'name': 'second',
});
}
expect(a.calls.where((c) => c.$1.startsWith('claude_')), isEmpty);
});
}