A2Agent compatibility testing: optional completion usage metadata
Hi science-codeevolve maintainers,
I represent A2Agent, an OpenAI- and Anthropic-compatible API gateway. We'd like to verify compatibility with your existing provider configuration and contribute a focused PR.
We'd use OpenAILM's existing api_base configuration. A focused starting point is successful text completions that omit optional usage metadata, keeping token-accounting uncertainty separate from request failure.
- A minimal existing-ensemble configuration recipe with placeholder credentials.
- Offline SDK-response fixtures for missing usage, empty choices, and provider errors.
- Checks that missing usage does not cause a valid completed request to be unnecessarily replayed.
Would you prefer a documentation/test-only PR or a broader integration?
Separately, after successful verification, would you consider including A2Agent wherever you document tested providers? We'll follow your preferred wording and placement, without implying endorsement.
We can privately provide a test key with US$10 in one-time API credits, plus technical support. This support is not conditional on merging, endorsement, or listing.
Thanks!
Hi, thanks for raising this. The missing-usage case you described was a real bug, and it's now fixed in #10.
What was happening: OpenAILM.generate read ret.usage.prompt_tokens inside its retry block. With a provider that leaves out usage, a completion that had already succeeded raised an AttributeError. That error was then retried as if it were a network failure. Each generation got sent 4 times (and billed 4 times), and in the end it was thrown away as a ConnectionError. OpenAIEmbedding.embed_batch had the same problem with usage.total_tokens.
With the fix:
- Missing or partial
usagenever causes a retry. Token counts that weren't reported are recorded asNone, so they can't be mistaken for zero, and the ensemble logs a warning. - Empty
choices, or an embedding response with the wrong number of vectors, raises a clear error. That case is still retried, since it can be transient. - Errors that can't succeed on a retry (400, 401, 403, 404, 422) fail right away instead of going through the backoff loop. 429 and 5xx errors are still retried.
- Offline tests cover all of the above. They run the real
AsyncOpenAIclient againsthttpx.MockTransportfixtures, so they need no network access or API key.
So no PR is needed on your side. Any OpenAI-compatible endpoint should now work through the existing api_base setting, including ones that don't return usage metadata.
On the other two points: we don't keep a list of tested or recommended providers, and we'd rather stay vendor-neutral, so we won't be adding one. Thanks for offering the credits!