Skip to content

Refactor out-of-band AI code#704

Open
shaneutt wants to merge 5 commits into
praxis-proxy:mainfrom
shaneutt:shaneutt/ai-overlaps
Open

Refactor out-of-band AI code#704
shaneutt wants to merge 5 commits into
praxis-proxy:mainfrom
shaneutt:shaneutt/ai-overlaps

Conversation

@shaneutt

Copy link
Copy Markdown
Member

There were a few general-purpose where AI-specific functionality was starting to bleed in, this PR refactors that to reduce boundary blur.

shaneutt added 5 commits June 23, 2026 17:30
Token usage metadata is an AI inference concern, not a general-purpose
filter infrastructure concern. Move set_token_usage() from the shared
HttpFilterContext method to a free function in the AI token_usage module
behind the AI feature flag.

Signed-off-by: Shane Utt <shaneutt@linux.com>
Remove the AI-specific response_stores field from HttpFilterContext.
The ResponseStoreRegistry is now injected via the general-purpose
RequestExtensions type-map, preventing domain-specific fields from
accumulating on the shared context struct.

Signed-off-by: Shane Utt <shaneutt@linux.com>
The protocol crate's only use of this feature is plumbing the
ResponseStoreRegistry into filter context. The name should reflect
what the crate actually does with it, not the domain it serves.

Signed-off-by: Shane Utt <shaneutt@linux.com>
Replace flat AI-specific re-exports at the filter crate root with a
gated `pub mod ai` namespace. This contains growth as more AI providers
are added, preventing unbounded expansion of provider-named types at
the crate root.

Signed-off-by: Shane Utt <shaneutt@linux.com>
Signed-off-by: Shane Utt <shaneutt@linux.com>
@shaneutt shaneutt force-pushed the shaneutt/ai-overlaps branch from 4ab3b23 to f0d7307 Compare June 23, 2026 21:30
@shaneutt shaneutt added area/ai AI and inference filters area/refinement labels Jun 23, 2026

@leseb leseb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the ci have a test for --no-default-features?

Comment thread Cargo.toml
Comment on lines 66 to +78
@@ -75,7 +75,7 @@ serde = { version = "1.0.228", features = ["derive", "rc"] }
serde_json = "1.0.150"
rcgen = "0.14.8"
regex = "1.12.4"
rustls = "0.23.40"
rustls = "0.23.41"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to the main changes?

};
#[cfg(feature = "ai-inference")]
if let Some(stores) = $pipeline.response_stores() {
fctx.extensions.insert(stores.clone());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to see extensions being used here :)

($ctx:expr, $pipeline:expr, $request:expr, $response_header:expr) => {
praxis_filter::HttpFilterContext {
($ctx:expr, $pipeline:expr, $request:expr, $response_header:expr) => {{
let mut fctx = praxis_filter::HttpFilterContext {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mutation only exists under response-store so cargo clippy -p praxis-proxy-protocol --no-default-features --all-targets -- -D warnings fails. it seems that the codebase documents --no-default-features as supported for the praxis binary so we should fix that:

cargo clippy -p praxis-proxy-protocol --no-default-features --all-targets -- -D warnings
    Checking nix v0.31.3
    Checking praxis-proxy-tls v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/tls)
    Checking quixotic-plecostomus-core v0.8.2
    Checking quixotic-plecostomus-cache v0.8.2
    Checking praxis-proxy-core v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/core)
    Checking quixotic-plecostomus-proxy v0.8.2
    Checking praxis-proxy-filter v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/filter)
    Checking praxis-proxy-protocol v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/protocol)
error: variable does not need to be mutable
   --> protocol/src/http/pingora/context.rs:227:13
    |
227 |         let mut fctx = praxis_filter::HttpFilterContext {
    |             ----^^^^
    |             |
    |             help: remove this `mut`
...
296 |         filter_context!(self, pipeline, request, response_header)
    |         --------------------------------------------------------- in this macro invocation
    |
    = note: `-D unused-mut` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_mut)]`
    = note: this error originates in the macro `filter_context` (in Nightly builds, run with -Z macro-backtrace for more info)

error: variable does not need to be mutable
   --> protocol/src/http/pingora/context.rs:227:13
    |
227 |         let mut fctx = praxis_filter::HttpFilterContext {
    |             ----^^^^
    |             |
    |             help: remove this `mut`
...
331 |         Some(filter_context!(self, pipeline, request, response_header))
    |              --------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `filter_context` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `praxis-proxy-protocol` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `praxis-proxy-protocol` (lib test) due to 2 previous errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ai AI and inference filters area/refinement

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants