feat/220 token counting integration tests#243
Open
mkoushni wants to merge 1 commit into
Open
Conversation
|
PR too large: 768 lines added (limit: 750, excludes Cargo files, tests, docs, examples, and benchmarks). Please split into smaller PRs. Add |
aslakknutsen
reviewed
Jul 3, 2026
7444f6f to
a623efd
Compare
|
Missing Signed-off-by: a623efd. All commits require sign-off (via |
22a8a9f to
4d2a19b
Compare
alexsnaps
reviewed
Jul 6, 2026
praxis-bot
reviewed
Jul 7, 2026
praxis-bot
left a comment
Collaborator
There was a problem hiding this comment.
Review: Token Counting Integration Tests (#243)
Adds integration tests and example config for the token counting pipeline. The test matrix is well structured and the SSE/non-streaming coverage across providers is thorough.
Findings
| # | Severity | File | Description |
|---|---|---|---|
| 1 | Critical | mod.rs |
Duplicate mod token_counting; — will not compile |
| 2 | Large | token_counting.rs |
Missing negative test: Bedrock InvokeModel with absent upstream token-count headers |
| 3 | Medium | token_counting.rs |
Doc comment on test function violates project convention |
| 4 | Medium | token_counting.rs |
Separator says "Helpers" — convention requires "Test Utilities" |
f1f91a7 to
0d5ae40
Compare
89d1c76 to
6fae4bc
Compare
|
Unsigned commits: 6fae4bc. Please sign your commits. |
…ig (praxis-proxy#220) Adds the integration test suite and example configuration described in docs/proposals/00220_token-counting-integration-tests.md. New files: - examples/configs/token-counting.yaml — example pipeline chaining token_count → x_token_headers → access_log with the ordering note that x_token_headers must precede token_count in the filter list. Comments explain that X-Token-* header injection is only possible for bedrock_invoke_model (counts from upstream response headers); for all other providers counts live in FilterContext metadata and access log. - tests/integration/tests/suite/examples/token_counting.rs — 13 tests covering all five provider formats (openai, anthropic, google, bedrock, azure), non-streaming and SSE streaming, noisy SSE, non-JSON passthrough, missing usage fields, and the example-config smoke test. Wiring: - tests/.../examples/mod.rs: add mod token_counting - examples/README.md: add token-counting.yaml entry Signed-off-by: mkoushni <mkoushni@redhat.com>
6fae4bc to
46d6f18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test(examples): add token_counting integration tests and example config (#220)
Summary
Adds an end-to-end integration test suite and example configuration for
the
token_countfilter (merged in #262), covering all five providerresponse formats, both streaming and non-streaming delivery, and
response-body passthrough guarantees, as described in
proposal #220.
Rebased onto current
main: uses the actual merged filter names(
token_count,token_usage_headers) and header names(
Praxis-Token-Input/Output/Total) rather than the placeholder namesfrom the original proposal draft (
x_token_headers,X-Token-*).What changed
examples/configs/token-counting.yamlRewrote the example pipeline to chain
router → token_usage_headers → token_count → access_log → load_balancer,matching the filters that actually exist on
main. Documents thatresponse headers are committed before the response body phase, so
token_usage_headers(declared beforetoken_countto run after itin the reverse response-hook order) has nothing to inject for any of
the currently-supported providers (openai, anthropic, google, bedrock,
azure) — they all extract counts from the response body in
on_response_body, after headers have already been sent. Counts remainavailable in
filter_metadatafor other response-phase filters.tests/integration/tests/suite/examples/token_counting.rs12 integration tests covering the provider/mode matrix from proposal
#220 that's actually supported by the merged filter:
openai_non_streaming_extracts_token_countsanthropic_non_streaming_extracts_token_countsgoogle_non_streaming_extracts_token_countsbedrock_converse_non_streaming_extracts_token_countsazure_non_streaming_extracts_token_countsopenai_streaming_extracts_token_countsanthropic_streaming_split_events_extracts_token_countsmessage_start/message_delta)google_streaming_no_done_sentinel_extracts_token_counts[DONE]sentinel)non_json_response_body_passes_through_unchangedPraxis-Token-*headersmissing_usage_fields_no_token_headers_injectedPraxis-Token-*headers absent when no usageopenai_streaming_whitespace_and_commentsexample_config_token_counting_openaiWiring
tests/.../examples/mod.rs— addsmod token_counting;examples/README.md— addstoken-counting.yamlentryTest plan
make lintpasses (clippy, nightly fmt, separators, filter-docs)make testpasses (full unit + integration + doctest suite)Related