[Bug]: Python SDK admin group methods skip configured gateway-token retry
Issue Origin
Observed or reproduced locally by AI agents through the public SDK with simulated Gateway responses, including an actual loopback HTTP server. Not a live deployment incident.
Description
The six Python SDK admin group methods call the underlying HTTP client directly, bypassing the shared _request gateway-challenge handling. With a configured gateway_token, these methods raise an error on a marked gateway 401 instead of retrying with X-Gateway-Token.
Affected methods: admin_create_group, admin_list_groups, admin_delete_group, admin_list_group_members, admin_add_group_member, and admin_remove_group_member.
This prevents group administration through a gateway requiring its documented token challenge, although an adjacent API such as admin_list_accounts retries successfully under the same conditions.
Expected behavior and contract
The client configuration documentation documents gateway_token as the X-Gateway-Token used when retrying a gateway challenge. The admin API documentation lists the six affected SDK methods.
Group methods should use the existing request handling: retry once after a marked gateway challenge when a token is configured, and preserve the current no-retry behavior for an unmarked 401 or missing token.
Reproduction
Reproduced against commit 4ab22a4923452362b60aef2826c2083ce36168d2, standalone Python SDK, Python 3.12.14 / Linux / httpx 0.28.1.
- Set
OPENVIKING_CLI_CONFIG_FILEto anovcli.confcontaining a URL and syntheticgateway_token. - Create
AsyncHTTPClientand attach anhttpx.MockTransportthat returns HTTP 401 withX-VikingBot-Gateway: trueuntil the configuredX-Gateway-Tokenis present; then return a successful OpenViking response. - Invoke each affected public SDK method and record requests. Use
admin_list_accountsas a control with the same transport behavior.
Observed: the control makes two requests and succeeds. Each group method makes one request without the token and raises OpenVikingError. Routing those methods through _request yields the expected two-request success.
An independent local check also used the public initialize() path and an actual loopback HTTP server emulating the gateway challenge protocol. The unchanged SDK fails on its first challenged group call; the patched SDK passes all 24 combinations (six methods across successful challenge, direct success, unmarked 401, and persistent challenge). Persistent challenges stop after one retry.
These are locally executed SDK reproductions with simulated gateway responses, not a production incident or a full deployed VikingBot gateway/end-to-end test.
Proposed scope
Reuse _request in these six methods, preserving their HTTP verbs, paths, bodies, and response handling. Add parameterized regression coverage for challenge retry, unmarked 401, absent token, explicit gateway header, and request context propagation. No new configuration or public API is needed.
Environment
OpenViking commit: 4ab22a4923452362b60aef2826c2083ce36168d2
Python: 3.12.14
OS: Linux
Model backend: Not applicable (SDK HTTP routing only).