fix: interceptor sync bridge + async detection, example fixes#213
Merged
Conversation
- shared run_coroutine_sync bridge (persistent background loop) replaces per-interceptor loop.run_until_complete which crashed inside running loops (async-adapter-bypass class) across all 5 provider interceptors - is_async_callable follows __wrapped__ so AsyncOpenAI/AsyncAnthropic (decorator-wrapped async create) get the async wrap path again - examples read AXONFLOW_USER_TOKEN; gateway_mode block demo uses stacked SQLi and exits non-zero on unexpected approval - runtime-e2e/interceptor_sync_bridge: live-agent bridge + detection proof Signed-off-by: Saurabh Jain <saurabhjain1592@gmail.com>
block_reason or-fallbacks in the 5 interceptors converted to explicit is-not-None form; baseline refreshed (14 entries removed) Signed-off-by: Saurabh Jain <saurabhjain1592@gmail.com>
Member
Author
|
The one red check (Live integration vs try.getaxonflow.com) is pre-existing: the same workflow has failed on |
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.
Summary
Hostile-testing sweep TEST-SDK ahead of the BukuWarung integration — tracking getaxonflow/axonflow-enterprise#2861.
loop.run_until_complete→RuntimeError: This event loop is already runningin FastAPI/Jupyter/any async app driving a sync provider client. Observed live:examples/openai_integration.pycrashed withcoroutine 'AxonFlow.proxy_llm_call' was never awaited. New sharedrun_coroutine_syncbridge (mirrorsSyncAxonFlow._run_sync, but on ONE persistent daemon-thread loop — a throwaway-loop bridge breaks the second call with "Event loop is closed" because the httpx pool is loop-affine) blocks the call site until the verdict is in.AsyncOpenAIclients were silently given the SYNC wrap path. openai>=1/anthropic decorate asynccreatewith a plain-def@required_argswrapper, soasyncio.iscoroutinefunctionreturns False.is_async_callablefollows__wrapped__— verified against realopenai2.44 (async detected, sync stays sync).quickstart,gateway_mode,openai_integrationreadAXONFLOW_USER_TOKENinstead of hardcoded non-JWT literals (they 401'd onDEPLOYMENT_MODE=enterprise).gateway_mode's block demo now uses stacked SQLi (blocked on every posture; PII defaults to redact) and exits non-zero on unexpected approval;openai_integrationprints its block-probe outcome instead of ending silently.Version 8.5.0 → 8.5.1 + CHANGELOG.
Testing
TestSyncWrapInsideRunningLoop(6 tests, one per provider + allowed path) — mutation-verified: fails with the pre-fix openai interceptor restored. NewTestAsyncDetectionThroughDecorators.runtime-e2e/interceptor_sync_bridge/against a LIVE enterprise stack (v9.6.1): REALopenai.OpenAIclient (dummy key — provider never reached) wrapped and driven from insideasyncio.runAND from plain sync code → stacked-SQLi prompt blocked withPolicyViolationErrorboth times, no RuntimeError;AsyncOpenAIdetected async, wrapped create is a coroutine function, blocked verdict awaited on the caller's loop — PASS 5/5. (The plain-sync leg caught the "Event loop is closed" pool-affinity regression during development; the persistent-loop bridge fixes it.)pytest: 1047 passed, 29 skipped. ruff clean.Related Issues