Repository navigation
Conversation
ASRTarget, DecisionTarget and HTTPAppTarget add an endpoint block (scheme, host, port, via_proxy) to TargetResponse.raw, warn once at construction on plain http to a non-loopback host, and create their client through one helper. ASRTarget uploads the file as audio<suffix>.
reuse_client=True keeps one httpx client per event loop instead of making one per request; aclose() and the async context manager close it. A client from an earlier loop (each sync run() has its own) is replaced, not reused. max_retries and retry_backoff retry transport errors and 429/5xx with a doubling backoff, with ModelTarget's names and defaults (0 and 0.5 s). A Retry-After header on a 429 or 503 replaces the wait, capped at 60 s. Both features default to today's behaviour: one client per request, one attempt.
This branch has not been deployed
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.
Builds on #119. Part of #107.
Until #119 is merged, this branch carries its two commits. The change for review is the last commit, ccd99ee (see commit list).
DecisionTarget.sendcreated a newhttpx.AsyncClientper request and never retried (gaps 3 and 2 in #107). Both fixes are opt-in; the defaults keep current behaviour.reuse_client=Truekeeps one client per event loop for all requests.aclose()andasync with DecisionTarget(...)close it. Each syncrun()gets its own loop, so a client created on an earlier loop is replaced, not reused. The target never closes an injectedclient=.max_retries=Nandretry_backoff(defaults 0 and 0.5 s, matchingModelTarget) retryhttpx.TransportErrorand statuses 429, 500, 502, 503 and 504, waitingretry_backoff * 2**attemptbetween attempts. On 429 or 503, aRetry-Afterheader (seconds or HTTP date) replaces that wait, capped at 60 s. After the last attempt, the original error or the usualHTTP <status>error is raised. Other 4xx responses are not retried.Tested with
pytest -p no:randomlyondevat cdb95cf plus #119, in a fresh venv withpip install -e ".[dev,tracing,plot,inspect]": 1737 passed, 3 skipped, 0 failed. 17 new tests intests/test_decision_target.py.Design questions:
reuse_clientbe the default? It is opt-in here because nothing in the auditor closes a target after a run, so a default client would stay open until garbage collection.AI disclosure: implemented with Claude Code.